Open flexagoon opened 3 weeks ago
@flexagoon What is the behaviour of vim.lsp.completion.enable
?
Using nvim v0.10.0 I only seem to get help for vim.lsp.buf.completion(context)
and using nvim-lspconfig and nvim-cmp I don't seem to get a conflict when completing from LSP.
@AlejandroSuero it's not in 0.10, it was added only recently. I'm using 0.11 nightly.
https://github.com/neovim/neovim/pull/27339
Here's the PR that added this functionality
@MariaSolOs do you know what this may be related to?
@AlejandroSuero I think the popup menu that's used here is the regular completion popup, you can trigger the same thing by using omnicompletion (<C-x><C-o>
), the issue will still be there
@flexagoon I am not sure if the PR maybe conflicting with the default keymaps.accept_suggestion = "<Tab>"
that supermaven sets. At a first glance it doesn't seem to do anything more than that which can could be the cause of conflict. Maybe @MariaSolOs has more insight on that.
If you haven't other keymaps using <C-y>
, test this out to see if it resolves it:
require("supermaven-nvim").setup({
accept_suggestion = "<C-y>",
})
Right now supermaven uses this when accepting a completion:
Maybe vim.lsp.util.apply_text_edits
is another cause of the conflict.
@AlejandroSuero this isn't about key bindings, the conflict happens before anything is pressed, when the popup window opens. The completion preview is overriden by supermaven completion
@flexagoon I compared the 2 screenshots and the only difference is, in the 1st one, there's ghost text inserted by Supermaven. Looking at 2nd screenshot, it doesn't seem to have hidden anything?
@hboon supermaven ghost text hides the Handle()
text inserted by completion
@hboon @flexagoon
When using it with supermaven and vim.lsp.completion
it doesn't detect the text provided by vim.lsp.completion
as "text" I would say, seems like it is not "inserting" it.
When using supermaven and nvim-cmp
with cmp.SelectBehaviour.Insert
it inserts the text and doesn't fail.
[!NOTE] When you see colored text in completion is
nvim-cmp
at work, otherwise isvim.lsp.completion
From what I see and testing it manually, it seems like when selecting an option in vim.lsp.completion
it doesn't really "insert" the text as nvim-cmp
does, therefore supermaven it will keep showing ghost text
from the last inserted character. With nvim-cmp
as it seems to insert it fully it detects it and keeps completing after nvim-cmp
inserted text.
If accepting the text provided by vim.lsp.completion
with <C-y>
, supermaven works as expected.
@hboon supermaven ghost text hides the
Handle()
text inserted by completion
@flexagoon ah, I see what you mean now. Thanks.
I think nvim-cmp
use vim.lsp.util.apply_text_edits
when inserting the text I don't know if vim.lsp.completion
does it in any form like this or how exactly it does it.
In nvim v0.10.0
it happens as well as it does in v0.11
, in my version and config I haven't configured vim.lsp.completion
in any way so just triggering like @flexagoon said, with <C-x><C-o>
and cycling through them with <C-n>
or <C-p>
, if not accepting with <C-y>
it will overlay the suggestion on top of vim.lsp.completion
text.
One more update on this nvim-cmp
seems to be triggering InsertCharPre
event but vim.lsp.completion
does not, this may be the cause for which it doesn't detect the changes.
-- using nvim-cmp
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
-- using vim.lsp.completion
event {
buf = 11,
event = "InsertCharPre",
file = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua",
group = 18,
id = 43,
match = "/Users/aome/dev/nvim_plugins/supermaven-nvim/lua/supermaven-nvim/api.lua"
}
[!NOTE] The first registered event is me writting
r
to start completion forrequire
.
I added a little change with the events mentioned in https://github.com/neovim/neovim/issues/25714#issuecomment-1959108102 and here is the result:
@hboon @flexagoon if you have some thoughts on how this looks to start a PR about it, would be helpful.
I added the events on this:
I figure it has to be tested on 0.11.x to be sure though
@hboon it behaves the same as shown in the previous comment both in stable (v0.10.0) and nightly (v0.11.x)
vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "TextChangedP", "CompleteChanged", "CompleteDone" } ...)
I tested it without each one separately and with all together, with the same result.
Seems like nvim-cmp
triggers TextChanged{I,P}
and CompleteDone
when accepting, and vim.lsp.completion
uses TextChangedP
and Complete{Changed,Done}
. For this @MariaSolOS could have more insight I guess.
And something weird happens if you trigger vim.lsp.completion
with <C-x><C-o>
and start writing, the suggestion disappears.
Sorry but I’m honestly unsure as to what may be the source of the conflict here.
When you set up built-in nvim lsp completion like this:
In your LspAttach, and then try to type something, the completion conflicts with Supermaven
Autocompletion inserts the text preview into the buffer, but supermaven writes its ghost text on top of that, so the completion preview isn't visible.
Here's what it looks like with supermaven disabled: