diff options
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index dcf9b6ba70..7440af1a96 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -218,6 +218,27 @@ do end, { desc = 'vim.lsp.buf.signature_help()' }) end + do + ---@param direction vim.snippet.Direction + ---@param key string + local function set_snippet_jump(direction, key) + vim.keymap.set({ 'i', 's' }, key, function() + if vim.snippet.active({ direction = direction }) then + return string.format('<Cmd>lua vim.snippet.jump(%d)<CR>', direction) + else + return key + end + end, { + desc = 'vim.snippet.jump if active, otherwise ' .. key, + expr = true, + silent = true, + }) + end + + set_snippet_jump(1, '<Tab>') + set_snippet_jump(-1, '<S-Tab>') + end + --- Map [d and ]d to move to the previous/next diagnostic. Map <C-W>d to open a floating window --- for the diagnostic under the cursor. --- |