stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.73k stars 32 forks source link

Feature request: more general support for external auto-completion #38

Closed echasnovski closed 2 years ago

echasnovski commented 2 years ago

Right now plugin's vim.ui.input defines its own completion. It seems to conflict with other external (auto-)completion functionality. This is vaguely confirmed by hard-coded 'nvim-cmp' disabling. I understand that 'nvim-cmp' is the completion engine right now, but it would be nice to at least have notice somewhere that external completion engine should be disabled in specified buffer. For example, this caused a hard-to-find behavior in 'mini.completion' (echasnovski/mini.nvim#68).

stevearc commented 2 years ago

Happy to disable mini completion by default, but there should be nothing wrong with having it enabled. I disabled cmp completion because it's usually undesirable in the input buffer, not because it was causing errors. I believe the issues that were reported are coming from some interaction between mini completion and "stopinsert". I can reproduce the issue with the following code:

require("mini.completion").setup()
vim.defer_fn(function()
  vim.api.nvim_feedkeys("Gohelloworld", "t", true)
end, 100)
vim.defer_fn(function()
  vim.cmd([[stopinsert]])
end, 1000)
vim.defer_fn(function()
  -- Now any attempt to insert triggers the error
  vim.api.nvim_feedkeys("i", "t", true)
end, 1500)
echasnovski commented 2 years ago

Thanks for automated disabling. I've added the note in 'mini.completion' docs, so that is not that necessary, but still nice.

Your example left me really puzzled, though. Not really a 'mini.completion' issue, but issue with InsertCharPre autocommand. I think I managed to narrow it down to some sort of weird behavior of Neovim itself. For example, that code works fine if vim.cmd([[stopinsert]]) is replaced with vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, true, true), "t", true). Which is weird because :h stopinsert quite literally says "Works like typing \ in Insert mode".

I'll ponder a bit until submitting an issue and probably close this after. Does this sound good?

stevearc commented 2 years ago

Works for me. I wouldn't be surprised if it were some edge case within Neovim itself; I've noticed some odd behavior for startinsert in the past.

echasnovski commented 2 years ago

So from neovim/neovim#18395 it does indeed seem like a Neovim issue. Thanks for the code example! Closing as irrelevant to the plugin itself.