Skip to content

Commit

Permalink
feat(cmp): press <Tab>/<S-Tab> to jump in snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesChiuGit committed Jun 27, 2024
1 parent a15fdae commit 82d6258
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ return function()
},
-- You can set mappings if you want
mapping = cmp.mapping.preset.insert({
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select, count = 1 }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-w>"] = cmp.mapping.abort(),
["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select, count = 1 }),
["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select, count = 1 }),
["<Tab>"] = cmp.mapping(function()
if require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
end
end, { "i", "s" }),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
Expand Down

0 comments on commit 82d6258

Please sign in to comment.