From c70a78e63137ec48e1c78b23413332716f572590 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 15 May 2024 16:23:38 +0200 Subject: [PATCH] fix(cmp): dont add autobrackets if prev char is a bracket. Closes #2949 --- lua/lazyvim/plugins/coding.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 3cdcc668..17380078 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -84,8 +84,11 @@ return { local entry = event.entry local item = entry:get_completion_item() if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then - local keys = vim.api.nvim_replace_termcodes("()", false, false, true) - vim.api.nvim_feedkeys(keys, "i", true) + local prev_char = vim.fn.getline("."):sub(vim.fn.col(".") - 1, vim.fn.col(".")) + if prev_char ~= "(" and prev_char ~= ")" then + local keys = vim.api.nvim_replace_termcodes("()", false, false, true) + vim.api.nvim_feedkeys(keys, "i", true) + end end end) end,