LSP: Add support for external URLs with `documentLink` (#261)

pull/266/head
Mickaël Menu 2 years ago committed by GitHub
parent cdf4f8e0c1
commit c21c4fc21f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## Unreleased ## Unreleased
### Added
* LSP: Support for external URLs with `documentLink`.
### Fixed ### Fixed
* [#243](https://github.com/mickael-menu/zk/issues/243) LSP: Fixed finding backlink references for notes in a folder. * [#243](https://github.com/mickael-menu/zk/issues/243) LSP: Fixed finding backlink references for notes in a folder.

@ -281,15 +281,24 @@ func NewServer(opts ServerOpts) *Server {
documentLinks := []protocol.DocumentLink{} documentLinks := []protocol.DocumentLink{}
for _, link := range links { for _, link := range links {
target, err := server.noteForLink(link, notebook) var target string
if target == nil || err != nil { if strutil.IsURL(link.Href) {
continue // External link
target = link.Href
} else {
// Internal note link
targetNote, err := server.noteForLink(link, notebook)
if targetNote != nil && err == nil {
target = targetNote.URI
}
} }
documentLinks = append(documentLinks, protocol.DocumentLink{ if target != "" {
Range: link.Range, documentLinks = append(documentLinks, protocol.DocumentLink{
Target: &target.URI, Range: link.Range,
}) Target: &target,
})
}
} }
return documentLinks, err return documentLinks, err

Loading…
Cancel
Save