From 6e7ba50141b1cda415c9391fd345a1e428bad9b6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 16 May 2024 08:07:29 +0200 Subject: [PATCH] fix(cmp): never auto bracket for snippets and correct prev char check. Fixes #2949 --- lua/lazyvim/plugins/coding.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 17380078..e279187d 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -83,8 +83,9 @@ return { end local entry = event.entry local item = entry:get_completion_item() - if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then - local prev_char = vim.fn.getline("."):sub(vim.fn.col(".") - 1, vim.fn.col(".")) + if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) and item.insertTextFormat ~= 2 then + local cursor = vim.api.nvim_win_get_cursor(0) + local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1] if prev_char ~= "(" and prev_char ~= ")" then local keys = vim.api.nvim_replace_termcodes("()", false, false, true) vim.api.nvim_feedkeys(keys, "i", true)