From 65cde445f02d528f1ab556b662caeaff1c2c5ca7 Mon Sep 17 00:00:00 2001 From: glepnir Date: Sat, 4 Nov 2023 17:37:12 +0800 Subject: [PATCH] fix wrong cursor position --- lua/epo/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/epo/init.lua b/lua/epo/init.lua index 376fa67..f479d46 100644 --- a/lua/epo/init.lua +++ b/lua/epo/init.lua @@ -216,6 +216,12 @@ local function complete_ondone(bufnr) -- end -- lsp.util.apply_text_edits({ completion_item.textEdit }, bufnr, client.offset_encoding) + -- in C when i complete a function which has brackets () + -- the cursor is before brackets so adjust cursor if needed. + if item.kind == 'f' and newText:find('%(%)$') then + local curpos = api.nvim_win_get_cursor(0) + api.nvim_win_set_cursor(0, { curpos[1], curpos[2] + 2 }) + end end elseif completion_item.insertTextFormat == protocol.InsertTextFormat.Snippet then offset_snip = completion_item.insertText