mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 19:30:01 +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 {
|
||||
{ import = "user.plugins.tools.finder" },
|
||||
-- { import = "user.plugins.tools.finder" },
|
||||
{
|
||||
"mason-org/mason.nvim",
|
||||
build = ":MasonUpdate",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ local ui = require("user.ui.telescope")
|
|||
local icons = require('user.icons')
|
||||
|
||||
return {
|
||||
{ import = "user.plugins.ui.dashboard" },
|
||||
|
||||
{ import = "user.plugins.ui.editor" },
|
||||
|
||||
{ import = "user.plugins.ui.colorscheme" },
|
||||
|
|
@ -41,50 +39,50 @@ return {
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'stevearc/dressing.nvim',
|
||||
opts = {
|
||||
input = {
|
||||
border = { " " },
|
||||
relative = "editor",
|
||||
title_pos = "center",
|
||||
mappings = {
|
||||
n = {
|
||||
["<Esc>"] = "Close",
|
||||
["<CR>"] = "Confirm",
|
||||
},
|
||||
i = {
|
||||
["<Esc>"] = "Close",
|
||||
["<CR>"] = "Confirm",
|
||||
["<Up>"] = "HistoryPrev",
|
||||
["<Down>"] = "HistoryNext",
|
||||
},
|
||||
},
|
||||
},
|
||||
select = {
|
||||
backend = { "telescope" },
|
||||
telescope = require("telescope.themes").get_dropdown(ui.dropdown),
|
||||
}
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- 'stevearc/dressing.nvim',
|
||||
-- opts = {
|
||||
-- input = {
|
||||
-- border = { " " },
|
||||
-- relative = "editor",
|
||||
-- title_pos = "center",
|
||||
-- mappings = {
|
||||
-- n = {
|
||||
-- ["<Esc>"] = "Close",
|
||||
-- ["<CR>"] = "Confirm",
|
||||
-- },
|
||||
-- i = {
|
||||
-- ["<Esc>"] = "Close",
|
||||
-- ["<CR>"] = "Confirm",
|
||||
-- ["<Up>"] = "HistoryPrev",
|
||||
-- ["<Down>"] = "HistoryNext",
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- select = {
|
||||
-- backend = { "telescope" },
|
||||
-- telescope = require("telescope.themes").get_dropdown(ui.dropdown),
|
||||
-- }
|
||||
-- },
|
||||
-- },
|
||||
-- Nicer notifications
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
opts = {
|
||||
notification = {
|
||||
window = {
|
||||
normal_hl = "NormalFloat",
|
||||
winblend = 0,
|
||||
border = { " " },
|
||||
x_padding = 1,
|
||||
y_padding = 1,
|
||||
}
|
||||
},
|
||||
progress = {
|
||||
display = {
|
||||
done_ttl = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- {
|
||||
-- "j-hui/fidget.nvim",
|
||||
-- opts = {
|
||||
-- notification = {
|
||||
-- window = {
|
||||
-- normal_hl = "NormalFloat",
|
||||
-- winblend = 0,
|
||||
-- border = { " " },
|
||||
-- x_padding = 1,
|
||||
-- y_padding = 1,
|
||||
-- }
|
||||
-- },
|
||||
-- progress = {
|
||||
-- display = {
|
||||
-- done_ttl = 2,
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ local custom_highlights = function(colors)
|
|||
TelescopeIndicatorReadonly = { fg = colors.red },
|
||||
TelescopeIndicatorHidden = { link = "TelescopeResultsComment" },
|
||||
|
||||
-- Snacks picker
|
||||
SnacksPickerInput = { link = "TelescopePromptNormal" },
|
||||
SnacksPickerInputBorder = { link = "TelescopePromptBorder" },
|
||||
SnacksPickerResult = { link = "TelescopeResultsNormal" },
|
||||
|
||||
-- Ufo
|
||||
UfoFoldedEllipsis = { link = "Comment" },
|
||||
|
||||
|
|
@ -79,6 +84,14 @@ local custom_highlights = function(colors)
|
|||
StatusLineCommand = { fg = colors.base, bg = colors.yellow },
|
||||
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
|
||||
NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender },
|
||||
NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 },
|
||||
|
|
@ -255,7 +268,7 @@ return {
|
|||
priority = 1000,
|
||||
opts = {
|
||||
flavour = "mocha",
|
||||
transparent_background = not vim.g.neovide,
|
||||
transparent_background = false,
|
||||
color_overrides = {
|
||||
mocha = {
|
||||
base = "#0E1019",
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ local options = {
|
|||
section_separators = "",
|
||||
disabled_filetypes = {
|
||||
statusline = {
|
||||
"dashboard",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"snacks_dashboard"
|
||||
},
|
||||
winbar = {
|
||||
"neo-tree",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue