Skip to content

Commit

Permalink
fix(cmp): dont add autobrackets if prev char is a bracket. Closes #2949
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 15, 2024
1 parent fc5ee49 commit c70a78e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/lazyvim/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c70a78e

Please sign in to comment.