From d0d5896550bb7537075e4ab0bd94bc281d65f96a Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Thu, 15 May 2025 20:24:37 +0530 Subject: lua: plugins: completion: minor changes for nvim >= 0.11.0 Signed-off-by: Brahmajit Das --- lua/plugins/completion.lua | 22 +++++++++++----------- 1 file 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, }, - [''] = cmp.mapping(function(fallback) + [""] = 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" }), - [''] = cmp.mapping(function(fallback) + + [""] = 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('/', { -- cgit v1.2.3