Open Spo0on opened 2 years ago
I'm running into the same/similar behaviour as well when trying to get the completion menu to trigger for imports (using another library which feeds in information for what can be imported but the main issue lies with the completion menu not triggering).
Example
import { } from '..';
If you place the cursor between { }
and try to trigger the menu it used to display the import options previously but currently no longer works
Hm. I have checked the code.
nvim-cmp registers CompleteChanged
event only.
So InsertEnter
event does not work.
It may fix the problem.
https://github.com/hrsh7th/nvim-cmp/issues/287#issuecomment-938693674
@Shougo Thanks for sharing!! I'm still new to using neovim so it took me a while to get it to work with your comment.
@Spo0on I found that by using the following config I'm able to trigger the completion menu again so this might also help you:
cmp.setup({
...
completion = {
autocomplete = {
cmp.TriggerEvent.TextChanged,
cmp.TriggerEvent.InsertEnter,
},
completeopt = "menuone,noinsert,noselect",
keyword_length = 0,
},
...
})
EDIT: Using the settings above I've noticed that performance takes a bit of a hit, so you may have to adjust accordingly.
@bbqben Very weird, if we remove the cmp.TriggerEvent.TextChanged
line, it doesn't trigger anymore when we enter insert mode by typing o
cmp.setup({ ... completion = { autocomplete = { cmp.TriggerEvent.TextChanged, cmp.TriggerEvent.InsertEnter, }, completeopt = "menuone,noinsert,noselect", keyword_length = 0, }, ... })
@bbqben does this make it so that a menu shows up immediately once you press i
, a
, or c
? Even with this, I still have to type and delete a letter to make the menu show up
local lsp = require('lsp-zero').preset({})
lsp.extend_cmp()
local cmp = require("cmp")
cmp.setup({
completion = {
completeopt = 'menu,menuone,noinsert,noselect',
autocomplete = {
cmp.TriggerEvent.TextChanged,
cmp.TriggerEvent.InsertEnter,
},
keyword_length = 0,
},
... rest of conf
}
For me this is what worked using lsp-zero
FAQ
Announcement
Minimal reproducible full config
my lsp-config.lua file
my cmp.lua file
Description
When i enter insert mode with cursor just after a word it should trigger completion menu for that word, but this does not happen.
Steps to reproduce
Expected behavior
`
include
int main(void) { prin } ` when i enter in insert mode with cursor just after the "prin" word nothing happens, no completion menu appears
Actual behavior
`
include
int main(void) { prin } ` completion menu appearing in insert enter with print related completions
Additional context
No response