mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
nvim: add snacks (WIP)
This commit is contained in:
parent
4df7150497
commit
ab5999f91f
5 changed files with 215 additions and 50 deletions
153
nvim/lua/user/plugins/core.lua
Normal file
153
nvim/lua/user/plugins/core.lua
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
local icons = require('user.icons')
|
||||||
|
|
||||||
|
local backdrop = user.backdrop or 80
|
||||||
|
|
||||||
|
local border = {" "}
|
||||||
|
|
||||||
|
local toggle_preview = function(picker)
|
||||||
|
local layout = vim.deepcopy(picker.resolved_layout)
|
||||||
|
|
||||||
|
-- helper: find the "preview" node in the layout tree
|
||||||
|
local function find_preview(root)
|
||||||
|
if root.win == "preview" then
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
if #root > 0 then
|
||||||
|
for _, child in ipairs(root) do
|
||||||
|
local found = find_preview(child)
|
||||||
|
if found then
|
||||||
|
return found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local preview = find_preview(layout.layout)
|
||||||
|
if not preview then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
layout.hidden = layout.hidden or {}
|
||||||
|
|
||||||
|
local hidden = false
|
||||||
|
for i, name in ipairs(layout.hidden) do
|
||||||
|
if name == "preview" then
|
||||||
|
hidden = true
|
||||||
|
table.remove(layout.hidden, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if hidden then
|
||||||
|
-- preview was hidden -> show it again
|
||||||
|
-- restore your preferred normal width/height
|
||||||
|
if layout.layout.width then
|
||||||
|
layout.layout.width = 0.8
|
||||||
|
end
|
||||||
|
if layout.layout.height then
|
||||||
|
layout.layout.height = 0.8
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- preview was visible -> hide it and compact the picker
|
||||||
|
table.insert(layout.hidden, "preview")
|
||||||
|
|
||||||
|
-- make the main picker smaller when preview is hidden
|
||||||
|
-- tweak this depending on your preset
|
||||||
|
if layout.layout.width then
|
||||||
|
layout.layout.width = 0.4
|
||||||
|
end
|
||||||
|
if layout.layout.height then
|
||||||
|
layout.layout.height = 0.4
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
picker:set_layout(layout)
|
||||||
|
end
|
||||||
|
|
||||||
|
local finder = {
|
||||||
|
prompt = " ",
|
||||||
|
layouts = {
|
||||||
|
default = {
|
||||||
|
hidden = { "preview" },
|
||||||
|
layout = {
|
||||||
|
box = "horizontal",
|
||||||
|
width = 0.4,
|
||||||
|
height = 0.4,
|
||||||
|
border = false,
|
||||||
|
{
|
||||||
|
box = "vertical",
|
||||||
|
{ win = "list", border = border, title = "Results" },
|
||||||
|
{ win = "input", border = border, height = 1, title = "{title} {live} {flags}" },
|
||||||
|
},
|
||||||
|
{ win = "preview", border = border, title = "{preview}", width = 0.5 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
toggle_preview_compact = toggle_preview
|
||||||
|
},
|
||||||
|
win = {
|
||||||
|
input = {
|
||||||
|
keys = {
|
||||||
|
["<Esc>"] = { "close", mode = { "n", "i" } },
|
||||||
|
["<c-p>"] = { "toggle_preview_compact", mode = { "i", "n" } },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"folke/snacks.nvim",
|
||||||
|
priority = 1000,
|
||||||
|
lazy = false,
|
||||||
|
---@type snacks.Config
|
||||||
|
opts = {
|
||||||
|
picker = finder,
|
||||||
|
dashboard = {
|
||||||
|
preset = {
|
||||||
|
header = [[
|
||||||
|
███▄ █ ▓█████ ▒█████ ██▒ █▓ ██▓ ███▄ ▄███▓
|
||||||
|
██ ▀█ █ ▓█ ▀ ▒██▒ ██▒▓██░ █▒▓██▒▓██▒▀█▀ ██▒
|
||||||
|
▓██ ▀█ ██▒▒███ ▒██░ ██▒ ▓██ █▒░▒██▒▓██ ▓██░
|
||||||
|
▓██▒ ▐▌██▒▒▓█ ▄ ▒██ ██░ ▒██ █░░░██░▒██ ▒██
|
||||||
|
▒██░ ▓██░░▒████▒░ ████▓▒░ ▒▀█░ ░██░▒██▒ ░██▒
|
||||||
|
░ ▒░ ▒ ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▐░ ░▓ ░ ▒░ ░ ░
|
||||||
|
░ ░░ ░ ▒░ ░ ░ ░ ░ ▒ ▒░ ░ ░░ ▒ ░░ ░ ░
|
||||||
|
░ ░ ░ ░ ░ ░ ░ ▒ ░░ ▒ ░░ ░
|
||||||
|
░ ░ ░ ░ ░ ░ ░ ░
|
||||||
|
░ ]],
|
||||||
|
keys = {
|
||||||
|
{ icon = " ", key = "c", desc = "Config", action = ":lua Snacks.dashboard.pick('files', {cwd = vim.fn.stdpath('config')})" },
|
||||||
|
{ icon = " ", key = "s", desc = "Restore Session", section = "session" },
|
||||||
|
{ icon = " ", key = "q", desc = "Quit", action = ":qa" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
notifier = {
|
||||||
|
style = 'minimal',
|
||||||
|
margin = { top = 0, right = 2, bottom = 2 },
|
||||||
|
gap = 1,
|
||||||
|
level = vim.log.levels.INFO,
|
||||||
|
icons = {
|
||||||
|
info = icons.diagnostics.info .. " ",
|
||||||
|
warn = icons.diagnostics.warn .. " ",
|
||||||
|
error = icons.diagnostics.error .. " ",
|
||||||
|
debug = icons.diagnostics.debug .. " ",
|
||||||
|
trace = icons.diagnostics.trace .. " "
|
||||||
|
},
|
||||||
|
top_down = false,
|
||||||
|
},
|
||||||
|
styles = {
|
||||||
|
float = {
|
||||||
|
backdrop = {
|
||||||
|
blend = backdrop,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
input = {
|
||||||
|
backdrop = {
|
||||||
|
blend = backdrop,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
return {
|
return {
|
||||||
{ import = "user.plugins.tools.finder" },
|
-- { import = "user.plugins.tools.finder" },
|
||||||
{
|
{
|
||||||
"mason-org/mason.nvim",
|
"mason-org/mason.nvim",
|
||||||
build = ":MasonUpdate",
|
build = ":MasonUpdate",
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ local ui = require("user.ui.telescope")
|
||||||
local icons = require('user.icons')
|
local icons = require('user.icons')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{ import = "user.plugins.ui.dashboard" },
|
|
||||||
|
|
||||||
{ import = "user.plugins.ui.editor" },
|
{ import = "user.plugins.ui.editor" },
|
||||||
|
|
||||||
{ import = "user.plugins.ui.colorscheme" },
|
{ import = "user.plugins.ui.colorscheme" },
|
||||||
|
|
@ -41,50 +39,50 @@ return {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
-- {
|
||||||
'stevearc/dressing.nvim',
|
-- 'stevearc/dressing.nvim',
|
||||||
opts = {
|
-- opts = {
|
||||||
input = {
|
-- input = {
|
||||||
border = { " " },
|
-- border = { " " },
|
||||||
relative = "editor",
|
-- relative = "editor",
|
||||||
title_pos = "center",
|
-- title_pos = "center",
|
||||||
mappings = {
|
-- mappings = {
|
||||||
n = {
|
-- n = {
|
||||||
["<Esc>"] = "Close",
|
-- ["<Esc>"] = "Close",
|
||||||
["<CR>"] = "Confirm",
|
-- ["<CR>"] = "Confirm",
|
||||||
},
|
-- },
|
||||||
i = {
|
-- i = {
|
||||||
["<Esc>"] = "Close",
|
-- ["<Esc>"] = "Close",
|
||||||
["<CR>"] = "Confirm",
|
-- ["<CR>"] = "Confirm",
|
||||||
["<Up>"] = "HistoryPrev",
|
-- ["<Up>"] = "HistoryPrev",
|
||||||
["<Down>"] = "HistoryNext",
|
-- ["<Down>"] = "HistoryNext",
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
select = {
|
-- select = {
|
||||||
backend = { "telescope" },
|
-- backend = { "telescope" },
|
||||||
telescope = require("telescope.themes").get_dropdown(ui.dropdown),
|
-- telescope = require("telescope.themes").get_dropdown(ui.dropdown),
|
||||||
}
|
-- }
|
||||||
},
|
-- },
|
||||||
},
|
-- },
|
||||||
-- Nicer notifications
|
-- Nicer notifications
|
||||||
{
|
-- {
|
||||||
"j-hui/fidget.nvim",
|
-- "j-hui/fidget.nvim",
|
||||||
opts = {
|
-- opts = {
|
||||||
notification = {
|
-- notification = {
|
||||||
window = {
|
-- window = {
|
||||||
normal_hl = "NormalFloat",
|
-- normal_hl = "NormalFloat",
|
||||||
winblend = 0,
|
-- winblend = 0,
|
||||||
border = { " " },
|
-- border = { " " },
|
||||||
x_padding = 1,
|
-- x_padding = 1,
|
||||||
y_padding = 1,
|
-- y_padding = 1,
|
||||||
}
|
-- }
|
||||||
},
|
-- },
|
||||||
progress = {
|
-- progress = {
|
||||||
display = {
|
-- display = {
|
||||||
done_ttl = 2,
|
-- done_ttl = 2,
|
||||||
}
|
-- }
|
||||||
}
|
-- }
|
||||||
}
|
-- }
|
||||||
},
|
-- },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,11 @@ local custom_highlights = function(colors)
|
||||||
TelescopeIndicatorReadonly = { fg = colors.red },
|
TelescopeIndicatorReadonly = { fg = colors.red },
|
||||||
TelescopeIndicatorHidden = { link = "TelescopeResultsComment" },
|
TelescopeIndicatorHidden = { link = "TelescopeResultsComment" },
|
||||||
|
|
||||||
|
-- Snacks picker
|
||||||
|
SnacksPickerInput = { link = "TelescopePromptNormal" },
|
||||||
|
SnacksPickerInputBorder = { link = "TelescopePromptBorder" },
|
||||||
|
SnacksPickerResult = { link = "TelescopeResultsNormal" },
|
||||||
|
|
||||||
-- Ufo
|
-- Ufo
|
||||||
UfoFoldedEllipsis = { link = "Comment" },
|
UfoFoldedEllipsis = { link = "Comment" },
|
||||||
|
|
||||||
|
|
@ -79,6 +84,14 @@ local custom_highlights = function(colors)
|
||||||
StatusLineCommand = { fg = colors.base, bg = colors.yellow },
|
StatusLineCommand = { fg = colors.base, bg = colors.yellow },
|
||||||
StatusLineReplace = { fg = colors.base, bg = colors.maroon },
|
StatusLineReplace = { fg = colors.base, bg = colors.maroon },
|
||||||
|
|
||||||
|
-- Notifications
|
||||||
|
Notification = { bg = colors.red },
|
||||||
|
|
||||||
|
-- Dashboard
|
||||||
|
SnacksDashboardIcon = { fg = colors.lavender },
|
||||||
|
SnacksDashboardDesc = { fg = colors.text },
|
||||||
|
SnacksDashboardKey = { fg = colors.lavender },
|
||||||
|
|
||||||
-- Neotree
|
-- Neotree
|
||||||
NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender },
|
NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender },
|
||||||
NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 },
|
NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 },
|
||||||
|
|
@ -255,7 +268,7 @@ return {
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
opts = {
|
opts = {
|
||||||
flavour = "mocha",
|
flavour = "mocha",
|
||||||
transparent_background = not vim.g.neovide,
|
transparent_background = false,
|
||||||
color_overrides = {
|
color_overrides = {
|
||||||
mocha = {
|
mocha = {
|
||||||
base = "#0E1019",
|
base = "#0E1019",
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ local options = {
|
||||||
section_separators = "",
|
section_separators = "",
|
||||||
disabled_filetypes = {
|
disabled_filetypes = {
|
||||||
statusline = {
|
statusline = {
|
||||||
"dashboard",
|
|
||||||
"alpha",
|
"alpha",
|
||||||
|
"dashboard",
|
||||||
|
"snacks_dashboard"
|
||||||
},
|
},
|
||||||
winbar = {
|
winbar = {
|
||||||
"neo-tree",
|
"neo-tree",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue