diff --git a/home-manager/features/neovim/config/lua/plugins/snacks.lua b/home-manager/features/neovim/config/lua/plugins/snacks.lua index ca76d01..9e76d9f 100644 --- a/home-manager/features/neovim/config/lua/plugins/snacks.lua +++ b/home-manager/features/neovim/config/lua/plugins/snacks.lua @@ -1,37 +1,15 @@ return { "folke/snacks.nvim", - ---@type snacks.Config - opts = { - picker = { - smart = { - -- Remove the "recent" picker so we don't get things from other directories. - multi = { "buffers", "files" }, - matcher = { - -- sort even when the search string is empty - sort_empty = true, - -- Enable frecensy for matchers. This puts more common files near the top - frecency = false, - -- Make sure files in the current directory are prioritized - cwd_bonus = true, - -- Give more weight to files that are more recent - history_bonus = true, - }, - }, - }, - }, - keys = { - { - "", - function() - Snacks.picker.smart({ + opts = function(_, opts) + vim.tbl_deep_extend("force", opts, { + picker = { + smart = { -- Remove the "recent" picker so we don't get things from other directories. multi = { "buffers", "files" }, matcher = { -- sort even when the search string is empty - sort_empty = false, - -- Enable frecensy for matchers. This puts more common files near - -- the top This includes files that aren't open and can put files I - -- am done with above open files, so it's off. + sort_empty = true, + -- Enable frecensy for matchers. This puts more common files near the top frecency = false, -- Make sure files in the current directory are prioritized cwd_bonus = true, @@ -40,261 +18,37 @@ return { -- Give more weight to places where the filename is part of the match filename_bonus = true, }, - }) + }, + sources = { + explorer = { + layout = { layout = { position = "right" } }, + }, + }, + }, + }) + Snacks.toggle({ + name = "Color Column", + get = function() + return vim.o.colorcolumn == "80" + end, + set = function(state) + if state then + vim.o.colorcolumn = "80" + vim.cmd([[highlight ColorColumn guibg=#202020]]) + else + vim.o.colorcolumn = "" + vim.cmd([[highlight ColorColumn guibg=None]]) + end + end, + }):map("ut", { desc = "Toggle Color Column" }) + end, + keys = { + { + "", + function() + Snacks.picker.smart() end, desc = "Smart Find Files", }, - - -- The rest of these are just default bindings. Setting the one binding above seems to override the others. - { - ",", - function() - Snacks.picker.buffers() - end, - desc = "Buffers", - }, - { "/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" }, - { - ":", - function() - Snacks.picker.command_history() - end, - desc = "Command History", - }, - { - "n", - function() - Snacks.picker.notifications() - end, - desc = "Notification History", - }, - -- find - { - "fb", - function() - Snacks.picker.buffers() - end, - desc = "Buffers", - }, - { - "fB", - function() - Snacks.picker.buffers({ hidden = true, nofile = true }) - end, - desc = "Buffers (all)", - }, - { "fc", LazyVim.pick.config_files(), desc = "Find Config File" }, - { "ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" }, - { "fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" }, - { - "fg", - function() - Snacks.picker.git_files() - end, - desc = "Find Files (git-files)", - }, - { "fr", LazyVim.pick("oldfiles"), desc = "Recent" }, - { - "fR", - function() - Snacks.picker.recent({ filter = { cwd = true } }) - end, - desc = "Recent (cwd)", - }, - { - "fp", - function() - Snacks.picker.projects() - end, - desc = "Projects", - }, - -- git - { - "gd", - function() - Snacks.picker.git_diff() - end, - desc = "Git Diff (hunks)", - }, - { - "gs", - function() - Snacks.picker.git_status() - end, - desc = "Git Status", - }, - { - "gS", - function() - Snacks.picker.git_stash() - end, - desc = "Git Stash", - }, - -- Grep - { - "sb", - function() - Snacks.picker.lines() - end, - desc = "Buffer Lines", - }, - { - "sB", - function() - Snacks.picker.grep_buffers() - end, - desc = "Grep Open Buffers", - }, - { "sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" }, - { "sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" }, - { - "sp", - function() - Snacks.picker.lazy() - end, - desc = "Search for Plugin Spec", - }, - { "sw", LazyVim.pick("grep_word"), desc = "Visual selection or word (Root Dir)", mode = { "n", "x" } }, - { - "sW", - LazyVim.pick("grep_word", { root = false }), - desc = "Visual selection or word (cwd)", - mode = { "n", "x" }, - }, - -- search - { - 's"', - function() - Snacks.picker.registers() - end, - desc = "Registers", - }, - { - "s/", - function() - Snacks.picker.search_history() - end, - desc = "Search History", - }, - { - "sa", - function() - Snacks.picker.autocmds() - end, - desc = "Autocmds", - }, - { - "sc", - function() - Snacks.picker.command_history() - end, - desc = "Command History", - }, - { - "sC", - function() - Snacks.picker.commands() - end, - desc = "Commands", - }, - { - "sd", - function() - Snacks.picker.diagnostics() - end, - desc = "Diagnostics", - }, - { - "sD", - function() - Snacks.picker.diagnostics_buffer() - end, - desc = "Buffer Diagnostics", - }, - { - "sh", - function() - Snacks.picker.help() - end, - desc = "Help Pages", - }, - { - "sH", - function() - Snacks.picker.highlights() - end, - desc = "Highlights", - }, - { - "si", - function() - Snacks.picker.icons() - end, - desc = "Icons", - }, - { - "sj", - function() - Snacks.picker.jumps() - end, - desc = "Jumps", - }, - { - "sk", - function() - Snacks.picker.keymaps() - end, - desc = "Keymaps", - }, - { - "sl", - function() - Snacks.picker.loclist() - end, - desc = "Location List", - }, - { - "sM", - function() - Snacks.picker.man() - end, - desc = "Man Pages", - }, - { - "sm", - function() - Snacks.picker.marks() - end, - desc = "Marks", - }, - { - "sR", - function() - Snacks.picker.resume() - end, - desc = "Resume", - }, - { - "sq", - function() - Snacks.picker.qflist() - end, - desc = "Quickfix List", - }, - { - "su", - function() - Snacks.picker.undo() - end, - desc = "Undotree", - }, - -- ui - { - "uC", - function() - Snacks.picker.colorschemes() - end, - desc = "Colorschemes", - }, }, }