Smooth starup if Snacks isn't loaded

Wrap Snacks keybindings in functions, so that I only see the error when
the keybinding is executed instead of when vim starts
This commit is contained in:
Thomas Ruoff
2025-07-21 17:44:08 +02:00
parent 811d1df4b9
commit 13b85bab50

View File

@@ -69,16 +69,16 @@ return {
map('<space>ca', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) map('<space>ca', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
-- Find references for the word under your cursor. -- Find references for the word under your cursor.
map('grr', Snacks.picker.lsp_references, '[G]oto [R]eferences') map('grr', function() Snacks.picker.lsp_references() end, '[G]oto [R]eferences')
-- Jump to the implementation of the word under your cursor. -- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation. -- Useful when your language has ways of declaring types without an actual implementation.
map('gri', Snacks.picker.lsp_implementations, '[G]oto [I]mplementation') map('gri', function() Snacks.picker.lsp_implementations() end, '[G]oto [I]mplementation')
-- Jump to the definition of the word under your cursor. -- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc. -- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>. -- To jump back, press <C-t>.
map('grd', Snacks.picker.lsp_definitions, '[G]oto [D]efinition') map('grd', function() Snacks.picker.lsp_definitions() end, '[G]oto [D]efinition')
-- WARN: This is not Goto Definition, this is Goto Declaration. -- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header. -- For example, in C this would take you to the header.
@@ -86,16 +86,16 @@ return {
-- Fuzzy find all the symbols in your current document. -- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc. -- Symbols are things like variables, functions, types, etc.
map('gO', Snacks.picker.lsp_symbols, 'Open Document Symbols') map('gO', function() Snacks.picker.lsp_symbols() end, 'Open Document Symbols')
-- Fuzzy find all the symbols in your current workspace. -- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project. -- Similar to document symbols, except searches over your entire project.
map('gW', Snacks.picker.lsp_workspace_symbols, 'Open Workspace Symbols') map('gW', function() Snacks.picker.lsp_workspace_symbols() end, 'Open Workspace Symbols')
-- Jump to the type of the word under your cursor. -- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see -- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*. -- the definition of its *type*, not where it was *defined*.
map('grt', Snacks.picker.lsp_type_definitions, '[G]oto [T]ype Definition') map('grt', function() Snacks.picker.lsp_type_definitions() end, '[G]oto [T]ype Definition')
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client ---@param client vim.lsp.Client