From b05fccb1c37fdfd3475ba9c8dda7ad92b894e23b Mon Sep 17 00:00:00 2001 From: daUnknownCoder Date: Wed, 24 Jan 2024 23:52:19 +0530 Subject: [PATCH] feat(tab): tab not working in between words (fixed) --- lua/NeutronVim/plugins/Coding/cmp.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/NeutronVim/plugins/Coding/cmp.lua b/lua/NeutronVim/plugins/Coding/cmp.lua index 2db99ea..f237ff1 100644 --- a/lua/NeutronVim/plugins/Coding/cmp.lua +++ b/lua/NeutronVim/plugins/Coding/cmp.lua @@ -75,6 +75,10 @@ return { return false end end + local has_words_before = function() + local line, col = 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 + end vim.api.nvim_set_hl(0, "NeutronCmpNormal", { fg = "silver", bg = "NONE" }) vim.api.nvim_set_hl(0, "NeutronCmpBorder", { fg = "lightblue", bg = "NONE" }) vim.api.nvim_set_hl(0, "NeutronCmpCursorLine", { fg = "aqua", bg = "NONE", italic = true }) @@ -166,7 +170,9 @@ return { elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() elseif check_back_space() then - feedkey("", "n") + feedkey("", "i") + elseif has_words_before() then + cmp.complete() else vim.fn["codeium#Accept"]() end