refactor: comment the tab shortcut for nvim cmp

This commit is contained in:
Dinesh Salunke 2024-12-16 12:46:42 +05:30
parent a9ada7444e
commit 81b0f8593e

View File

@ -93,28 +93,28 @@ return {
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }), ["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }),
["<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()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() -- -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region -- -- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then -- elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() -- luasnip.expand_or_jump()
elseif has_words_before() then -- elseif has_words_before() then
cmp.complete() -- cmp.complete()
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.jumpable(-1) then -- elseif luasnip.jumpable(-1) then
luasnip.jump(-1) -- luasnip.jump(-1)
else -- else
fallback() -- fallback()
end -- end
end, { "i", "s" }), -- end, { "i", "s" }),
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },