changed the autocompletion keymap for selecting a snippet or lsp suggestion

This commit is contained in:
lowell 2025-02-04 19:44:55 -05:00
parent 0172fecd84
commit 81a3e4d280

View File

@ -96,7 +96,8 @@ return { -- Autocompletion
-- If you prefer more traditional completion keymaps, -- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines -- you can uncomment the following lines
['<CR>'] = cmp.mapping.confirm { select = true }, -- ['<CR>'] = cmp.mapping.confirm { select = true },
['<Tab>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(), --['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(), --['<S-Tab>'] = cmp.mapping.select_prev_item(),
@ -127,24 +128,24 @@ return { -- Autocompletion
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
-- Select next/previous item with Tab / Shift + Tab -- Select next/previous item with Tab / Shift + Tab
['<Tab>'] = cmp.mapping(function(fallback) -- ['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then -- if cmp.visible() then
cmp.select_next_item() -- cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then -- elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() -- luasnip.expand_or_jump()
else -- else
fallback() -- fallback()
end -- end
end, { 'i', 's' }), -- end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback) -- ['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then -- if cmp.visible() then
cmp.select_prev_item() -- cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then -- elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1) -- luasnip.jump(-1)
else -- else
fallback() -- fallback()
end -- end
end, { 'i', 's' }), -- end, { 'i', 's' }),
}, },
sources = { sources = {
{ {