admin管理员组文章数量:1352857
I'm writing a language server in typescript. The idea of the language server is to provide snippets, go-to-def, and hover in CSS files for design tokens (aka css variables)
Here's the handler for textDocument/completion
:
export function completion({ params }: CompletionRequestMessage): null | CompletionList {
tokens ??= getAllTokens();
const word = getCSSWordAtPosition(params.textDocument.uri, params.position);
if (!word) return null;
const items: CompletionItem[] = tokens
.filter(x => x.name?.replaceAll('-','').startsWith(word.replaceAll('-','')))
.map(token => ({
label: token.name!.replaceAll('-', '')!,
kind: CompletionItemKind.Snippet,
insertText: `var(--${token.name})$0`,
documentation: token.$description && {
value: getTokenMarkdown(token),
kind: MarkupKind.Markdown,
},
}) satisfies CompletionItem);
return {
items,
isIncomplete: false,
itemDefaults: {
insertTextFormat: InsertTextFormat.Snippet,
}
}
}
Which produces this ResponseMessage
for a document change in which the current word is rhcolorblue10
:
Content-Length: 457
{"id":7,"result":{"items":[{"label":"rhcolorblue10","kind":15,"insertText":"var(--rh-color-blue-10)$0","documentation":{"value":"`--rh-color-blue-10` *<`color`>*:\n\n **#e0f0ff**\n\nAlert - Info background","kind":"markdown"}},{"label":"rhcolorblue10hsl","kind":15,"insertText":"var(--rh-color-blue-10-hsl)$0"},{"label":"rhcolorblue10rgb","kind":15,"insertText":"var(--rh-color-blue-10-rgb)$0"}],"isIncomplete":false,"itemDefaults":{"insertTextFormat":2}}}
As far as I can tell, that should be all kosher. Nonetheless, completion items are not appearing in neovim, via blink.cmp, when then do appear for other LSP servers.
here is the LSP configuration I'm using, which works for my textDocument/hover
implementation:
---@type vim.lsp.ClientConfig
return {
cmd = { 'design-tokens-languageserver' },
root_markers = { '.git' },
filetypes = {
'css',
},
settings = { },
}
Am I missing something? Why are completion items not appearing in the completion menu?
Update 02-04-2025: I get the same behaviour when returning all of the snippets every time with isIncomplete: false
, and the same when returning an CompletionItem[]
with all snippets every time. I have also reproduced the same behaviour in vscodium and zed.
本文标签: language server protocolCompletion items not appearing with LSP in neovimStack Overflow
版权声明:本文标题:language server protocol - Completion items not appearing with LSP in neovim - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743919367a2561803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论