feat: Add simple TextDocumentCompletion example

This commit is contained in:
Myzel394 2024-07-27 19:59:06 +02:00
parent 1d452369d0
commit dba463ff05
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
2 changed files with 22 additions and 0 deletions

17
main.go
View File

@ -27,6 +27,7 @@ func main() {
Initialized: initialized,
Shutdown: shutdown,
SetTrace: setTrace,
TextDocumentCompletion: TextDocumentCompletion,
}
server := server.NewServer(&handler, lsName, false)
@ -59,3 +60,19 @@ func setTrace(context *glsp.Context, params *protocol.SetTraceParams) error {
protocol.SetTraceValue(params.Value)
return nil
}
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (interface{}, error) {
var completions []protocol.CompletionItem
Label := "happyface"
text := "Hello World!"
completions = append(completions, protocol.CompletionItem{
Label: Label,
Detail: &text,
InsertText: &text,
})
return completions, nil
}

5
nvim-lsp-debug.lua Normal file
View File

@ -0,0 +1,5 @@
vim.lsp.start {
name = "config-lsp",
cmd = { "./bin/config-lsp" },
root_dir = vim.fn.getcwd(),
};