How to get nvim cmp to maintain the completion list when items have spaces? #272
-
Hello! I am making a language server for obsidian markdown https://github.com/Feel-ix-343/obsidian-markdown-ls and I am working on completions right now. I am currently facing an issue where there are completions with multiple words separated by spaces, but when typing the space, all nvim cmp completion items disappear! Somehow, this plugin has managed to get around this (if it even was an issue), but I don't know how. I tried looking at the source code, but the lua is difficult for me to understand, and I don't even know if you have specifically addressed this issue in the code anyway. If you have, how is it possible to get completion items with spaces in them? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @Feel-ix-343, getting completion to work properly was by far the hardest part of building this plugin. |
Beta Was this translation helpful? Give feedback.
Hey @Feel-ix-343, getting completion to work properly was by far the hardest part of building this plugin.
nvim-cmp
is not documented very well so it was a lot of trial and error. Obsidian registers 3 different completion sources, and the easiest to understand is probablycmp_obsidian_new
(for creating new notes). I think the key piece that makes it work with spaces is thesource.get_keyword_pattern()
function, which comes from here. That's a Vim pattern, by the way, not a Lua pattern.