Fix completion with Neovim's built-in LSP client (#41)

pull/43/head
Mickaël Menu 3 years ago committed by GitHub
parent b17b42a06f
commit e8cb1d8046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
### Fixed
* Creating a new note from `fzf` in a directory containing spaces.
* Fix completion with Neovim's built-in LSP client (contributed by [@cormacrelf](https://github.com/mickael-menu/zk/pull/39)).
## 0.4.0

@ -163,11 +163,8 @@ func NewServer(opts ServerOpts) *Server {
}
handler.TextDocumentCompletion = func(context *glsp.Context, params *protocol.CompletionParams) (interface{}, error) {
triggerChar := params.Context.TriggerCharacter
if params.Context.TriggerKind != protocol.CompletionTriggerKindTriggerCharacter || triggerChar == nil {
return nil, nil
}
// We don't use the context because clients might not send it. Instead,
// we'll look for trigger patterns in the document.
doc, ok := server.documents.Get(params.TextDocument.URI)
if !ok {
return nil, nil
@ -178,7 +175,12 @@ func NewServer(opts ServerOpts) *Server {
return nil, err
}
switch *triggerChar {
switch doc.LookBehind(params.Position, 2) {
case "[[":
return server.buildLinkCompletionList(doc, notebook, params)
}
switch doc.LookBehind(params.Position, 1) {
case "#":
if notebook.Config.Format.Markdown.Hashtags {
return server.buildTagCompletionList(notebook, "#")
@ -187,10 +189,6 @@ func NewServer(opts ServerOpts) *Server {
if notebook.Config.Format.Markdown.ColonTags {
return server.buildTagCompletionList(notebook, ":")
}
case "[":
if doc.LookBehind(params.Position, 2) == "[[" {
return server.buildLinkCompletionList(doc, notebook, params)
}
}
return nil, nil

Loading…
Cancel
Save