feat: migrate old config
This commit is contained in:
1 parent
1a2ce09da2
commit
92c21d8d6a
31 files changed
+918
-38
No files matched your search
@@ -32,19 +32,91 @@ local function grep()
|
||||
end
|
||||
end
|
||||
|
||||
local function fuzzy_grep()
|
||||
if use_fff() then
|
||||
require("fff").live_grep({ grep = { modes = { "fuzzy", "plain" } } })
|
||||
else
|
||||
Snacks.picker.grep()
|
||||
end
|
||||
end
|
||||
|
||||
-- The dashboard centres every line on its own, so pad them all to one width to keep the art aligned.
|
||||
local header = (function()
|
||||
local lines = {
|
||||
[[ __ __]],
|
||||
[[ |__| ____ | | _________ ____ ______ ____ ___________]],
|
||||
[[ | |/ _ \| |/ /\_ __ \_/ __ \ / ___// \_/ __ \_ __ \]],
|
||||
[[ | ( <_> ) < | | \/\ ___/ \___ \| | \ ___/| | \/]],
|
||||
[[/\__| |\____/|__|_ \ |__| \___ >____ >___| /\___ >__|]],
|
||||
[[\______| \/ \/ \/ \/ \/]],
|
||||
}
|
||||
local width = 0
|
||||
for _, line in ipairs(lines) do
|
||||
width = math.max(width, #line)
|
||||
end
|
||||
for i, line in ipairs(lines) do
|
||||
lines[i] = line .. string.rep(" ", width - #line)
|
||||
end
|
||||
return table.concat(lines, "\n")
|
||||
end)()
|
||||
|
||||
-- The finder entries press the same leader maps as below, so fff and the snacks fallback stay in one place.
|
||||
local dashboard = {
|
||||
enabled = true,
|
||||
width = 66, -- the header is 64 columns wide
|
||||
preset = {
|
||||
header = header,
|
||||
keys = {
|
||||
{ icon = " ", key = "f", desc = "Find file", action = "<leader>ff" },
|
||||
{ icon = " ", key = "r", desc = "Recent files", action = "<leader>fr" },
|
||||
{ icon = " ", key = "w", desc = "Find word", action = "<leader>fw" },
|
||||
{ icon = " ", key = "g", desc = "Grep", action = "<leader>fg" },
|
||||
{ icon = " ", key = "p", desc = "Projects", action = "<leader>fp" },
|
||||
{
|
||||
icon = " ",
|
||||
key = "s",
|
||||
desc = "Restore session",
|
||||
action = function()
|
||||
require("persistence").load()
|
||||
end,
|
||||
},
|
||||
{ icon = " ", key = "l", desc = "Lazy", action = ":Lazy" },
|
||||
{ icon = " ", key = "q", desc = "Quit", action = ":qa" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local keys = {
|
||||
{ "<leader>ff", files, desc = "Find files" },
|
||||
{ "<leader><leader>", files, desc = "Find files" },
|
||||
{ "<leader>,", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
||||
{ "<leader>fr", function() Snacks.picker.recent() end, desc = "Recent files" },
|
||||
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
||||
{ "<leader>fR", function() Snacks.picker.resume() end, desc = "Resume last picker" },
|
||||
{ "<leader>fu", function() Snacks.picker.undo() end, desc = "Undo history" },
|
||||
{ "<leader>fG", fuzzy_grep, desc = "Fuzzy grep" },
|
||||
{ "<leader>gB", function() Snacks.picker.git_branches() end, desc = "Git branches" },
|
||||
{ "<leader>gc", function() Snacks.picker.git_log() end, desc = "Git log" },
|
||||
{ "<leader>gC", function() Snacks.picker.git_log_file() end, desc = "Git log (file)" },
|
||||
{ "<leader>gx", function() Snacks.picker.git_status() end, desc = "Git status" },
|
||||
{ "<leader>bd", function() Snacks.bufdelete() end, desc = "Delete buffer" },
|
||||
{ "<leader>bD", function() Snacks.bufdelete({ force = true }) end, desc = "Delete buffer (force)" },
|
||||
{ "<leader>bo", function() Snacks.bufdelete.other() end, desc = "Delete other buffers" },
|
||||
{ "<leader>bb", "<cmd>e #<cr>", desc = "Alternate buffer" },
|
||||
{ "<leader>fg", grep, desc = "Live grep" },
|
||||
{ "<leader>fw", function() Snacks.picker.grep_word() end, desc = "Grep word under cursor", mode = { "n", "x" } },
|
||||
{ "<leader>fb", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
||||
{ "<leader>fh", function() Snacks.picker.help() end, desc = "Help" },
|
||||
{ "<leader>fk", function() Snacks.picker.keymaps() end, desc = "Keymaps" },
|
||||
{ "<leader>fd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" },
|
||||
{ "<leader>cn", function() Snacks.words.jump(vim.v.count1) end, desc = "Next reference", mode = { "n", "t" } },
|
||||
{ "<leader>cp", function() Snacks.words.jump(-vim.v.count1) end, desc = "Previous reference", mode = { "n", "t" } },
|
||||
{ "<C-/>", function() Snacks.terminal.toggle(nil, { win = { position = "float" } }) end, desc = "Toggle terminal", mode = { "n", "t" } },
|
||||
{ "<C-_>", function() Snacks.terminal.toggle(nil, { win = { position = "float" } }) end, desc = "which_key_ignore", mode = { "n", "t" } },
|
||||
}
|
||||
if full then
|
||||
table.insert(keys, { "<leader>fs", function() Snacks.picker.lsp_workspace_symbols() end, desc = "Workspace symbols" })
|
||||
table.insert(keys, { "<leader>fo", function() Snacks.picker.lsp_symbols() end, desc = "Document symbols" })
|
||||
end
|
||||
if vim.fn.executable("lazygit") == 1 then
|
||||
table.insert(keys, { "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" })
|
||||
@@ -70,11 +142,19 @@ return {
|
||||
priority = 1000,
|
||||
keys = keys,
|
||||
opts = {
|
||||
dashboard = dashboard,
|
||||
picker = picker,
|
||||
lazygit = {},
|
||||
terminal = {},
|
||||
image = { enabled = full },
|
||||
words = { enabled = true },
|
||||
statuscolumn = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("snacks").setup(opts)
|
||||
require("core.toggles").setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"dmtrKovalenko/fff.nvim",
|
||||
|
||||
Reference in new issue
Block a user