Fallback LSP references to the current note (#79)

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

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
* Use the `{{abs-path}}` template variable when [formatting notes](docs/template-format.md) to print the absolute path to the note (contributed by [@pstuifzand](https://github.com/mickael-menu/zk/pull/60)).
* Allow setting the `--working-dir` and `--notebook-dir` flags before the `zk` subcommand when using aliases, e.g. `zk -W ~/notes my-alias`.
* Support for LSP references to browse the backlinks of the current note, if the caret is not over a link.
### Fixed

@ -397,15 +397,22 @@ func NewServer(opts ServerOpts) *Server {
return nil, nil
}
link, err := doc.DocumentLinkAt(params.Position)
if link == nil || err != nil {
notebook, err := server.notebookOf(doc)
if err != nil {
return nil, err
}
notebook, err := server.notebookOf(doc)
link, err := doc.DocumentLinkAt(params.Position)
if err != nil {
return nil, err
}
if link == nil {
href, err := notebook.RelPath(doc.Path)
if err != nil {
return nil, err
}
link = &documentLink{Href: href}
}
target, err := server.noteForHref(link.Href, doc, notebook)
if link == nil || target == nil || err != nil {

Loading…
Cancel
Save