Wed, 22 May 2024 21:14:12 -0500
Change tab completion/snippet maps
.config/nvim/lua/plugins/completion.lua | file | annotate | diff | comparison | revisions |
--- a/.config/nvim/lua/plugins/completion.lua +++ b/.config/nvim/lua/plugins/completion.lua @@ -42,10 +42,10 @@ return { ["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-f>"] = cmp.mapping.scroll_docs(4), ["<Tab>"] = cmp.mapping(function(fallback) - if cmp.visible() then + if vim.snippet.active({direction = 1}) then + vim.snippet.jump(1) + elseif cmp.visible() then cmp.select_next_item() - elseif vim.snippet.active({direction = 1}) then - vim.snippet.jump(1) elseif has_words_before() then cmp.complete() else @@ -53,10 +53,10 @@ return { end end, { "i", "s" }), ["<S-Tab>"] = cmp.mapping(function(fallback) - if cmp.visible() then + if vim.snippet.active({direction = -1}) then + vim.snippet.jump(-1) + elseif cmp.visible() then cmp.select_prev_item() - elseif vim.snippet.active({direction = -1}) then - vim.snippet.jump(-1) else fallback() end