diff --git a/lazy-lock.json b/lazy-lock.json index 87d4ffb..9e39661 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,40 +1,34 @@ { "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "conform.nvim": { "branch": "master", "commit": "dca1a190aa85f9065979ef35802fb77131911106" }, - "fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" }, + "conform.nvim": { "branch": "master", "commit": "18aeab3d63d350dcf44d64c462cc489a3412af40" }, + "fidget.nvim": { "branch": "main", "commit": "82404b196e73a00b1727a91903beef5ddc319d22" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, - "kulala.nvim": { "branch": "main", "commit": "6656c9d332735ca6a27725e0fb45a1715c4372d9" }, + "kulala.nvim": { "branch": "main", "commit": "aa05c854cc46e235aa24684d0521719570ea489e" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7b01e2974a47d489bb92f47a41e4c0088ea8f86e" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, - "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, - "mini.icons": { "branch": "main", "commit": "bac6317300e205335df425296570d84322730067" }, - "mini.nvim": { "branch": "main", "commit": "48555f1615f08c6318150aacb52bf7d61a5af798" }, - "neo-tree.nvim": { "branch": "main", "commit": "84c75e7a7e443586f60508d12fc50f90d9aee14e" }, - "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, - "neotest-go": { "branch": "main", "commit": "59b50505053f9c45a9febb79e11a56206c3e3901" }, - "neotest-jest": { "branch": "main", "commit": "0e7979d51301dfae5ef839d771bd28cf593fde3f" }, - "neotest-python": { "branch": "master", "commit": "e6df4f1892f6137f58135917db24d1655937d831" }, + "mason.nvim": { "branch": "main", "commit": "cbf8d285e1462dd24acf3507817be2bbcb035919" }, + "mini.icons": { "branch": "main", "commit": "520995f1d75da0e4cc901ee95080b1ff2bc46b94" }, + "mini.nvim": { "branch": "main", "commit": "6791615e48801cbf5b2baefadcea77a7760de3f4" }, + "neo-tree.nvim": { "branch": "main", "commit": "83e7a2982fd12b9c3d35bc39dd5877cd91a02a61" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, - "nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, - "nvim-lint": { "branch": "master", "commit": "eab58b48eb11d7745c11c505e0f3057165902461" }, - "nvim-lspconfig": { "branch": "master", "commit": "31026a13eefb20681124706a79fc1df6bf11ab27" }, + "nvim-lint": { "branch": "master", "commit": "d48f3a76189d03b2239f6df1b2f7e3fa8353743b" }, + "nvim-lspconfig": { "branch": "master", "commit": "a4ed4e761c400849e8c9f8bda33e5083f890268c" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, - "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, + "nvim-web-devicons": { "branch": "master", "commit": "0d7d35fa946837b8738b17c18d1faa1ac351e7f9" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "render-markdown.nvim": { "branch": "main", "commit": "3f3eea97b80839f629c951ca660ffd125bfa5b34" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "f04ab730b8f9c6bf3f54a206d0dcddfd70c52d59" }, + "render-markdown.nvim": { "branch": "main", "commit": "629eb9533ec989d9d5c6cab8f3ad5372422c24e0" }, + "snacks.nvim": { "branch": "main", "commit": "0770753c88228f7f15449c6a5b242e3f7cd0d71c" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, diff --git a/lua/config/git_links.lua b/lua/config/git_links.lua deleted file mode 100644 index 0348e70..0000000 --- a/lua/config/git_links.lua +++ /dev/null @@ -1,64 +0,0 @@ ---[[ - Path: lua/config/git_links.lua - Module: config.git_links - - Purpose - Opens the current buffer’s file on GitHub (or compatible origin) in the - browser, including a line or range anchor from Normal or Visual mode. - - Rationale - Used by `config.keymaps` (`go`). - - Dependencies: git(1); `vim.ui.open` when available, else `open` / `xdg-open` / `cmd start`. -]] - -local M = {} - ----@param url string -local function open_url(url) - if vim.ui and vim.ui.open then - vim.ui.open(url) - return - end - local cmd - if vim.fn.has 'win32' == 1 then - cmd = { 'cmd', '/c', 'start', '', url } - elseif vim.fn.has 'macunix' == 1 then - cmd = { 'open', url } - else - cmd = { 'xdg-open', url } - end - vim.fn.jobstart(cmd, { detach = true }) -end - -M.open_github = function() - local file_path = vim.fn.systemlist('git ls-files --full-name ' .. vim.fn.expand '%')[1] - if not file_path or file_path == '' then - print 'File not tracked by git.' - return - end - - local remote = vim.fn.system('git config --get remote.origin.url'):gsub('\n', ''):gsub('%.git$', '') - if remote:match '^git@' then - remote = remote:gsub(':', '/'):gsub('git@', 'https://') - end - - local branch = vim.fn.system('git rev-parse --abbrev-ref HEAD'):gsub('\n', '') - - local line_start = vim.fn.line 'v' - local line_end = vim.fn.line '.' - if line_start > line_end then - line_start, line_end = line_end, line_start - end - - local line_anchor = 'L' .. line_end - if vim.fn.mode():match '[vV]' then - line_anchor = 'L' .. line_start .. '-L' .. line_end - end - - local url = string.format('%s/blob/%s/%s#%s', remote, branch, file_path, line_anchor) - open_url(url) - print 'Opened in GitHub' -end - -return M diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index c565383..1f1edde 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -3,37 +3,35 @@ Module: config.keymaps Purpose - Non-plugin (or minimally coupled) normal-mode maps: search, diagnostics - quickfix, terminal escape, window navigation, GitHub “open in browser,” + Non-plugin (or minimally coupled) normal-mode maps: terminal escape, + window navigation, GitHub “open in browser,” Neo-tree toggles, and visual paste without clobbering a register. Rationale Keeping these maps here avoids scattering `vim.keymap.set` across plugin config files and ensures they exist even before lazy.nvim finishes loading. - See `:help vim.keymap.set()`, `:help diagnostic-loclist`. + See `:help vim.keymap.set()`. ]] -vim.keymap.set('n', '', 'nohlsearch') +vim.thing.set('n', '', 'nohlsearch') -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +vim.thing.set('t', '', '', { desc = 'Exit terminal mode' }) -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) +vim.thing.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.thing.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.thing.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.thing.set('n', '', '', { desc = 'Move focus to the upper window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.thing.set('n', 'th', ':split | terminal', { desc = 'Terminal horizontal split' }) +vim.thing.set('n', 'tv', ':vsplit | terminal', { desc = 'Terminal vertical split' }) +vim.thing.set('n', 'tt', ':tabnew | terminal', { desc = 'Terminal in new tab' }) +vim.thing.set('n', 'tf', ':ToggleTerm', { desc = 'Toggle floating terminal' }) -vim.keymap.set('n', 'th', ':split | terminal', { desc = 'Terminal horizontal split' }) -vim.keymap.set('n', 'tv', ':vsplit | terminal', { desc = 'Terminal vertical split' }) -vim.keymap.set('n', 'tt', ':tabnew | terminal', { desc = 'Terminal in new tab' }) -vim.keymap.set('n', 'tf', ':ToggleTerm', { desc = 'Toggle floating terminal' }) - -vim.keymap.set('x', 'p', '"_dP', { noremap = true, silent = true }) +vim.thing.set('x', 'p', '"_dP', { noremap = true, silent = true }) local git_links = require 'config.git_links' -vim.keymap.set({ 'n', 'v' }, 'go', git_links.open_github, { desc = 'Open in GitHub' }) +vim.thing.set({ 'n', 'v' }, 'go', git_links.open_github, { desc = 'Open in GitHub' }) -vim.keymap.set('n', 'x', 'Neotree toggle', { desc = 'NeoTree Toggle' }) -vim.keymap.set('n', 'z', 'Neotree reveal', { desc = 'NeoTree Reveal' }) +vim.thing.set('n', 'x', 'Neotree toggle', { desc = 'NeoTree Toggle' }) +vim.thing.set('n', 'z', 'Neotree reveal', { desc = 'NeoTree Reveal' }) diff --git a/lua/config/plugins/gitsigns.lua b/lua/config/plugins/gitsigns.lua index abedb46..bfc0e50 100644 --- a/lua/config/plugins/gitsigns.lua +++ b/lua/config/plugins/gitsigns.lua @@ -34,7 +34,7 @@ return { local function map(mode, l, r, opts) opts = opts or {} opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) + vim.thing.set(mode, l, r, opts) end -- Detect branch once per buffer attach diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua index e2cae73..7097f06 100644 --- a/lua/config/plugins/lsp.lua +++ b/lua/config/plugins/lsp.lua @@ -61,7 +61,7 @@ return { -- for LSP related items. It sets the mode, buffer and description for us each time. local map = function(keys, func, desc, mode) mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + vim.thing.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end -- Rename the variable under your cursor. @@ -76,20 +76,20 @@ return { -- For example, in C this would take you to the header. map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - -- Defer requiring Telescope until keypress: on `nvim file.py`, LspAttach can run - -- before VimEnter, when lazy.nvim has not loaded telescope.nvim yet. + -- Defer Snacks picker until keypress: on `nvim file.py`, LspAttach can run before VimEnter, + -- when lazy.nvim has not loaded snacks.nvim yet. -- -- Nvim 0.11+ (incl. 0.12) sets *global* defaults grr/gri/grt/gO → vim.lsp.buf.* (quickfix / loclist). - -- Buffer-local maps override defaults; grr/gri/grd/gO/gW/grt use Telescope pickers. - -- `grd` is not a core default mapping; it maps goto-definition through Telescope here. - map('grr', function() require('telescope.builtin').lsp_references() end, '[R]eferences') - map('gri', function() require('telescope.builtin').lsp_implementations() end, '[I]mplementation') - map('grd', function() require('telescope.builtin').lsp_definitions() end, '[G]oto [D]efinition') - map('gO', function() require('telescope.builtin').lsp_document_symbols() end, 'Open Document Symbols') - map('gW', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, 'Open Workspace Symbols') + -- Buffer-local maps override defaults; grr/gri/grd/gO/gW/grt use Snacks pickers. + -- `grd` is not a core default mapping; it maps goto-definition through the picker here. + map('grr', function() Snacks.picker.lsp_references() end, '[R]eferences') + map('gri', function() Snacks.picker.lsp_implementations() end, '[I]mplementation') + map('grd', function() Snacks.picker.lsp_definitions() end, '[G]oto [D]efinition') + map('gO', function() Snacks.picker.lsp_symbols() end, 'Open Document Symbols') + map('gW', function() Snacks.picker.lsp_workspace_symbols() end, 'Open Workspace Symbols') -- gopls may error on anonymous func types ("cannot find type name from type func(...)"): -- put the cursor on a named identifier, or use grd on the symbol name — same LSP limit. - map('grt', function() require('telescope.builtin').lsp_type_definitions() end, '[G]oto [T]ype Definition') + map('grt', function() Snacks.picker.lsp_type_definitions() end, '[G]oto [T]ype Definition') local function client_supports_method(client, method, bufnr) return client:supports_method(method, bufnr) diff --git a/lua/config/plugins/snacks.lua b/lua/config/plugins/snacks.lua new file mode 100644 index 0000000..fc91ae1 --- /dev/null +++ b/lua/config/plugins/snacks.lua @@ -0,0 +1,95 @@ +--[[ + Path: lua/config/plugins/snacks.lua + Module: config.plugins.snacks + + Purpose + folke/snacks.nvim: picker (Telescope replacement), bigfile, quickfile, + input, gitbrowse, and words (LSP reference highlights + / [[ jumps). + + Rationale + `priority` + `lazy = false` so quickfile can run before VimEnter on + `nvim file`. LSP maps in `lsp.lua` still use Snacks.picker on keypress. + + See https://github.com/folke/snacks.nvim +]] + +---@type LazySpec +return { +{ + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + dependencies = { + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + ---@type snacks.Config + opts = { + picker = { + ui_select = true, + }, + bigfile = {}, + quickfile = {}, + input = {}, + gitbrowse = { + what = 'file', + }, + words = {}, + }, + config = function() + local picker = Snacks.picker + + vim.keymap.set('n', 'sh', picker.help, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', picker.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', picker.files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', function() picker() end, { desc = '[S]earch [S]elect Snacks' }) + vim.keymap.set({ 'n', 'v' }, 'sw', picker.grep_word, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', picker.grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', picker.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sq', picker.diagnostics_buffer, { desc = '[S]earch buffer diagnostics [Q]uickfix' }) + vim.keymap.set('n', 'sD', function() + local current_dir = vim.fn.expand '%:p:h' + picker.diagnostics { cwd = current_dir, title = 'Diagnostics in current directory' } + end, { desc = '[S]earch [D]iagnostics in current directory' }) + vim.keymap.set('n', 'sr', picker.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', picker.recent, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'sc', picker.commands, { desc = '[S]earch [C]ommands' }) + vim.keymap.set('n', '', picker.buffers, { desc = '[ ] Find existing buffers' }) + + vim.keymap.set('n', '/', function() + picker.lines { + layout = { preset = 'ivy', hidden = { 'preview' } }, + title = 'Fuzzily search in current buffer', + } + end, { desc = '[/] Fuzzily search in current buffer' }) + + vim.keymap.set('n', 's/', picker.grep_buffers, { desc = '[S]earch [/] in Open Files' }) + + vim.keymap.set('n', 'sn', function() + picker.files { cwd = vim.fn.stdpath 'config', title = 'Neovim config files' } + end, { desc = '[S]earch [N]eovim files' }) + + vim.keymap.set('n', 'sag', function() + picker.grep { + title = 'Live Grep (All Files)', + hidden = true, + ignored = true, + exclude = { '.git/' }, + } + end, { desc = '[S]earch [A]ll Files [G]rep' }) + + vim.keymap.set('n', 'saf', function() + picker.files { + title = 'Find All Files (Hidden + Ignored)', + hidden = true, + ignored = true, + exclude = { '.git/' }, + } + end, { desc = '[S]earch [A]ll [F]iles' }) + + vim.keymap.set({ 'n', 'v' }, 'go', function() Snacks.gitbrowse() end, { desc = 'Open in browser (git)' }) + + vim.keymap.set({ 'n', 't' }, ']]', function() Snacks.words.jump(vim.v.count1) end, { desc = 'Next LSP reference' }) + vim.keymap.set({ 'n', 't' }, '[[', function() Snacks.words.jump(-vim.v.count1) end, { desc = 'Prev LSP reference' }) + end, +}, +} diff --git a/lua/config/plugins/spec.lua b/lua/config/plugins/spec.lua index f7b3374..1a8cc39 100644 --- a/lua/config/plugins/spec.lua +++ b/lua/config/plugins/spec.lua @@ -33,7 +33,7 @@ local mods = { 'config.plugins.gitsigns', 'config.plugins.which_key', 'config.plugins.render_markdown', - 'config.plugins.telescope', + 'config.plugins.snacks', 'config.plugins.lsp', 'config.plugins.conform', 'config.plugins.blink', diff --git a/lua/config/plugins/telescope.lua b/lua/config/plugins/telescope.lua deleted file mode 100644 index cede97a..0000000 --- a/lua/config/plugins/telescope.lua +++ /dev/null @@ -1,175 +0,0 @@ ---[[ - Path: lua/config/plugins/telescope.lua - Module: config.plugins.telescope - - Purpose - Lazy spec for telescope.nvim: fuzzy finder for files, grep, diagnostics, - git, help, and LSP pickers; includes fzf-native and ui-select extensions. - - Rationale - Large `config` function registers `s*` maps and theme extensions. - Deferred `require('telescope.builtin')` from LSP attach remains valid. - - See `:help telescope`, `:help telescope.setup()`. -]] - ----@type LazySpec -return { -{ -- Fuzzy Finder (files, lsp, etc) - 'nvim-telescope/telescope.nvim', - -- By default, Telescope is included and acts as your picker for everything. - - -- If you would like to switch to a different picker (like snacks, or fzf-lua) - -- you can disable the Telescope plugin by setting enabled to false and enable - -- your replacement picker by requiring it explicitly in `config.plugins.spec` - - -- Note: If you customize your config for yourself, - -- it’s best to remove the Telescope plugin config entirely - -- instead of just disabling it here, to keep your config clean. - enabled = true, - event = 'VimEnter', - dependencies = { - 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions - 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() return vim.fn.executable 'make' == 1 end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - - -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! - - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ['ui-select'] = { require('telescope.themes').get_dropdown() }, - }, - } - - -- Enable Telescope extensions if they are installed - pcall(require('telescope').load_extension, 'fzf') - pcall(require('telescope').load_extension, 'ui-select') - - -- See `:help telescope.builtin` - local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set({ 'n', 'v' }, 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sD', function() - local current_dir = vim.fn.expand '%:p:h' -- Gets the absolute path to the current file's folder - require('telescope.builtin').diagnostics { - cwd = current_dir, - -- This ensures it searches within the directory, not just the file - root_dir = current_dir, - } - end, { desc = '[S]earch [D]iagnostics in current directory' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', 'sc', builtin.commands, { desc = '[S]earch [C]ommands' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - - -- vim.keymap.set('n', 'g', '', { desc = '[Git]' }) - -- vim.keymap.set('n', 'gl', builtin.git_bcommits, { desc = '[Git] Buffer Commits' }) - -- vim.keymap.set('n', 'gr', builtin.git_bcommits_range, { desc = '[Git] Buffer Commits Range' }) - -- vim.keymap.set('n', 'gb', builtin.git_branches, { desc = '[Git] Branches' }) - -- vim.keymap.set('n', 'gc', builtin.git_commits, { desc = '[Git] Commits' }) - -- vim.keymap.set('n', 'gf', builtin.git_files, { desc = '[Git] Files' }) - -- vim.keymap.set('n', 'gt', builtin.git_stash, { desc = '[Git] Stash' }) - -- vim.keymap.set('n', 'gs', builtin.git_status, { desc = '[Git] Status' }) - -- vim.keymap.set('n', 'gm', function() - -- builtin.git_commits { - -- git_command = { 'git', 'log', '--oneline', '--decorate', 'main..HEAD' }, - -- } - -- end, { desc = '[Git] Commits ahead of main' }) - - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) - end, { desc = '[/] Fuzzily search in current buffer' }) - - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set( - 'n', - 's/', - function() - builtin.live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } - end, - { desc = '[S]earch [/] in Open Files' } - ) - - -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() - builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) - - vim.keymap.set('n', 'sag', function() - builtin.live_grep { - prompt_title = 'Live Grep (All Files)', - -- This function adds the flags to the underlying grep command - additional_args = function(args) - return { '--hidden', '--no-ignore', '--no-ignore-parent', '--glob=!**/.git/*' } - end, - } - end, { desc = '[S]earch [A]ll Files [G]rep)' }) - - vim.keymap.set('n', 'saf', function() - builtin.find_files { - prompt_title = 'Find All Files (Hidden + Ignored)', - hidden = true, -- Show hidden dotfiles - no_ignore = true, -- Ignore .gitignore rules - no_ignore_parent = true, -- Ignore .gitignore rules of all parents, too - file_ignore_patterns = { '.git/' }, -- <--- Explicitly remove the .git folder - } - end, { desc = '[S]earch [A]ll [F]iles' }) - end, -}, -} diff --git a/lua/config/plugins/which_key.lua b/lua/config/plugins/which_key.lua index 5d1b87e..1e5a334 100644 --- a/lua/config/plugins/which_key.lua +++ b/lua/config/plugins/which_key.lua @@ -8,7 +8,7 @@ Rationale Loaded on `VimEnter` so it does not delay first screen paint. `spec` entries - document chains used elsewhere (Telescope, gitsigns, LSP maps). + document chains used elsewhere (Snacks picker, gitsigns, LSP maps). See `:help which-key.nvim.txt`. ]]