hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
505 stars 41 forks source link

incsearch highlight problem #29

Closed tzachar closed 2 years ago

tzachar commented 2 years ago

Hi.

'incsearch' stopped working for me while using cmdline. Using the default config from cmp, this is what I get: cmp.txt Peek 2022-01-10 11-09

hrsh7th commented 2 years ago

I think we can't support this. In my previous investigation, the wilder.nvim has the same problem.

If you have a solution, Please tell me that.

tzachar commented 2 years ago

Do you have any idea what causes this?

tzachar commented 2 years ago

Looking at wilder, it seems they solved the problem. This also works for cmp:

diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua
index d84baee..98aec26 100644
--- a/lua/cmp/view/custom_entries_view.lua
+++ b/lua/cmp/view/custom_entries_view.lua
@@ -177,6 +177,8 @@ custom_entries_view.open = function(self, offset, entries)
   else
     self:_select(0, { behavior = types.cmp.SelectBehavior.Select })
   end
+ local keys = vim.api.nvim_replace_termcodes('<C-R><BS>', true, false, true);
+ vim.api.nvim_feedkeys(keys, 'n', true)
 end

 custom_entries_view.close = function(self)

Would be better to condition this behaviour on whether the user has incsearch set.

see https://github.com/gelguy/wilder.nvim/pull/65

tzachar commented 2 years ago

There is still a flicker though.

hrsh7th commented 2 years ago

Thank you for pointing me out it. Hm... It's a bit problematic with nvim-cmp's text changed detection mechanism. I'll consider it.