fix(cmp): dont add autobrackets if prev char is a bracket. Closes #2949

This commit is contained in:
Folke Lemaitre 2024-05-15 16:23:38 +02:00
parent fc5ee49495
commit c70a78e631
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -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("()<left>", 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("()<left>", false, false, true)
vim.api.nvim_feedkeys(keys, "i", true)
end
end
end)
end,