-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make sure nvim-cmp keymaps are registered #2087
fix: make sure nvim-cmp keymaps are registered #2087
Conversation
e255ad7
to
7491c46
Compare
IMO, you can use check out it. require('cmp').setup({
...
completion = {
get_trigger_characters = function(trigger_characters)
return vim.iter(trigger_characters):filter(function(char)
return not chat:match('^%s*$')
end)
end
}
...
}) |
Damn, nice, seems to work, but I am not finding this in the doc? |
With your config option there is a problem, When completing a function the signature help and completion window does not open by itself anymore (which I want) |
Do you see any problems with this fix? |
this seems to work get_trigger_characters = function(trigger_characters)
if #vim.trim(vim.api.nvim_get_current_line()) == 0 then
return {}
end
return trigger_characters
end, |
This commit introduced a bug where the 'enabled' option is not respected in prompt buffers. For example, in the Telescope prompt, it provides autocomplete, which is quite annoying. |
hmm i cant seem to reproduce, what is your config? |
The configuration is fairly standard. With this commit enabled, you can open Telescope's live grep, type a few characters, and try navigating the search results using the standard Ctrl+n and Ctrl+p shortcuts. However, instead of navigating through the Telescope search results, the nvim-cmp completion menu appears. |
This happens because nvim-cmp is disabled in prompt buffers. However, with this commit, it is enabled in prompts. |
doesnt happen in my config which I havent touched the |
It's default: nvim-cmp/lua/cmp/config/default.lua Line 10 in ed31156
|
I don't know if it helps, but nvim-cmp mappings are the same as telescope: ["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "c", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "c", "s" }), |
thanks, however it shouldn't matter based on your keymaps, maybe I misunderstood what cmp:prepare does, I just pushed a quick commit that tries to call less stuff, can you check it? If it still does not work then I will just use the alternative which is in an earlier comment and close the PR |
Well, I think it matters because this issue wouldn’t occur if the mappings in Telescope and nvim-cmp were different, and ctrl+n and ctrl+p didn’t trigger nvim-cmp completion. Thanks, I'll look at your fix tomorrow. |
I have the same c-n c-p mappings |
closing in favor of #2087 (comment) |
Context
When editing files with the https://github.com/microsoft/compose-language-service LSP, the popup would always appear on new lines like so:
Completion appears on fully whitespace line
As you can see, this interferes with my fallback Tab keymap which indents the code and its very annoying
2024-11-09.17-20-25.mp4
This is with
keyword_length = 1
The underlying issue
I think the underlying issue is:
keyword_length = 1
still shows the menu when there are no keywords (fully whitespace line), unless this is the expected behaviorWorkaround
I started using this config to workaround the issue
But then I saw that sometimes my completion selection just stopped working altogether like so:
Completion stops
2024-11-09.17-08-10.mp4
This PR
This pr makes the workaround actually work
With this PR
2024-11-09.17-07-44.mp4