completion only works with autocomplete, not via manual trigger (nvim-cmp)
tjex opened this issue · 3 comments
Check if applicable
- I have searched the existing issues (required)
- I'm willing to help fix the problem and contribute a pull request
Describe the bug
With autocomplete enabled in cmp (meaning completion will begin as soon as I start typing), lsp returns to me my notes for link creation:
~/wikis/test 1m 25s
sys > tree
.
├── 8544.md <-- "AI title"
├── 939q.md <-- "blah"
├── d
│ └── flk.md <-- "asdlf"
└── index.md
2 # index
1
3 [[]] <-- triggered upon typing `[[`
1 ╭──────────────────╮
~ │ blah [LSP] │
~ │ asdlf [LSP] │
~ │ index [LSP] │
~ │ AI title [LSP] │
~ ╰──────────────────╯
However, with autocomplete set to false
, no lsp findings are returned to me:
2 # index
1
3 [[]] <- triggered manually
1 ╭───────────────╮
~ │ index [buf] │
~ ╰───────────────╯
Same goes if I type some characters and then trigger completion (i.e, no lsp results):
2 # index
1
3 [[AI ]]
1 ╭─────────────────────╮
~ │ pandoc~ [snip] │
~ │ simple~ [snip] │
~ │ blog post~ [snip] │
~ │ index [buf] │
~ ╰─────────────────────╯
Furthermore, if keyword_length
is set in nvim-cmp (which sets completion to trigger after n
characters are typed`, it breaks the zk-nvim completion.
Type [[ to trigger completion:
2 # index
1
3 [[]] <-- triggered upon typing `[[`
1 ╭──────────────────╮
~ │ blah [LSP] │
~ │ asdlf [LSP] │
~ │ index [LSP] │
~ │ AI title [LSP] │
~ ╰──────────────────╯
Type A to filter towards "AI title"
2 # index
1
3 [[A]] <-- triggered upon typing `[[A` (completion returns nothing)
~
~
How to reproduce?
zk configuration
[note]
filename = "{{id}}"
template = "default.md"
[extra]
[format.markdown]
hashtags = false
colon-tags = false
multiword-tags = false
[tool]
[lsp]
[lsp.diagnostics]
dead-link = "error"
[lsp.completion]
note-label = "{{title-or-path}}"
[filter]
[alias]
Neovim configuration
local key = vim.keymap.set
require("zk").setup({
picker = "telescope",
lsp = {
config = {
cmd = { "zk", "lsp" },
name = "zk",
on_attach = function()
key("n", "gd", function()
vim.lsp.buf.definition()
end, {})
require("cmp_nvim_lsp").default_capabilities()
end,
},
auto_attach = {
enabled = true,
filetypes = { "markdown" },
},
},
})
local cmp = require("cmp")
local lspkind = require("lspkind")
cmp.setup({
completion = {
autocomplete = false,
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
documentation = cmp.config.disable, -- disable docs popup
completion = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<c-k>"] = cmp.mapping.select_prev_item(),
["<c-j>"] = cmp.mapping.select_next_item(),
["<c-l>"] = cmp.mapping.complete(),
["<c-i>"] = cmp.mapping.confirm({ select = true }), -- Accept item at top of list. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = "nvim_lsp"},
{ name = "luasnip"},
{ name = "buffer"},
{ name = "nvim_lua"},
{ name = "path"},
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
luasnip = "[snip]",
path = "[path]",
nvim_lua = "[api]",
},
}),
},
})
Environment
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1700008891
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.4/share/nvim"
Run :checkhealth for more info
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
I can reproduce this with my neovim config as well.
This is also reproducible when 'autocomplete' is on for cmp when trying to manually trigger completion after coming from normal mode.
Like so:
- In insert mode type ie. "[[AI" so that the completion lists opens up.
- Enter normal mode.
- Enter insert mode again.
- Try to trigger autocompletion => no suggestions from zk lsp.