summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrahmajit Das <listout@listout.xyz>2025-05-15 20:24:37 +0530
committerBrahmajit Das <listout@listout.xyz>2025-05-15 20:24:37 +0530
commitd0d5896550bb7537075e4ab0bd94bc281d65f96a (patch)
treec59bf6b05b0722a1b95179585400891ce4ac16de
parent6045eb8bb856112dd11e071116ffff2255a54bed (diff)
lua: plugins: completion: minor changes for nvim >= 0.11.0
Signed-off-by: Brahmajit Das <listout@listout.xyz>
-rw-r--r--lua/plugins/completion.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua
index 0340d23..1e82346 100644
--- a/lua/plugins/completion.lua
+++ b/lua/plugins/completion.lua
@@ -21,9 +21,9 @@ return {
"hrsh7th/nvim-cmp",
config = function()
local has_words_before = function()
- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ local line, col = table.unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
- vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
+ vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
-- luasnip setup
@@ -89,26 +89,25 @@ return {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
},
- ['<Tab>'] = cmp.mapping(function(fallback)
+ ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
- elseif luasnip.expand_or_jumpable() then
- luasnip.expand_or_jump()
- elseif has_words_before() then
- cmp.complete()
+ elseif luasnip.locally_jumpable(1) then
+ luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
- ['<S-Tab>'] = cmp.mapping(function(fallback)
+
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
- elseif luasnip.jumpable(-1) then
+ elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
- end, { 'i', 's' }),
+ end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'luasnip', option = { use_show_condition = false } },
@@ -125,10 +124,11 @@ return {
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `cmp_git` source if you were installed it.
+ }, {
{ name = 'buffer' },
}),
- require("cmp_git").setup(),
})
+ require("cmp_git").setup()
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
require 'cmp'.setup.cmdline('/', {