Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP can't resolve documents with custom link-format #481

Closed
1 of 2 tasks
ahmedelgabri opened this issue Dec 16, 2024 · 3 comments
Closed
1 of 2 tasks

LSP can't resolve documents with custom link-format #481

ahmedelgabri opened this issue Dec 16, 2024 · 3 comments

Comments

@ahmedelgabri
Copy link

Check if applicable

  • I have searched the existing issues (required)
  • I'm willing to help fix the problem and contribute a pull request

Describe the bug

I have the same exact problem right now as #264 . My link-format is taken from the docs https://zk-org.github.io/zk/notes/note-format.html#customizing-the-markdown-links-generated-by-zk

link-format = "[[{{metadata.id}}|{{title}}]]"

But the LSP fails to resolve the link. The document does have an id inside its frontmatter and the autocompletion works fine, but the LSP can't find the doc.

How to reproduce?

test.zip

Check the link in b.md, LSP can't resolve a.md using the custom link-format inside .zk/config.toml

zk configuration

[format.markdown]
link-format = "[[{{metadata.id}}|{{title}}]]"

Environment

zk 0.14.1
system: Darwin 24.2.0 arm64 Darwin
@sivaplaysmC
Copy link

Hello, @ahmedelgabri. I thing the issue is with your link-format. LSP works pretty fine with the following custom format:

link-format = "[[{{filename}}|{{title}}]]"

@ahmedelgabri
Copy link
Author

Hello, @ahmedelgabri. I thing the issue is with your link-format. LSP works pretty fine with the following custom format:


link-format = "[[{{filename}}|{{title}}]]"

Thanks @sivaplaysmC, that was also my guess but what confused me, is that I took it from the docs website and I assumed because it was there that it will work. Maybe the docs need to be updated and avoid adding examples that doesn't work to avoid confusion.

@tjex
Copy link
Member

tjex commented Dec 21, 2024

Markdown links resolve to the actual filenames. This is why {{filename}} is working for you.

Otherwise put, the problem is that your files do not have the id in their filename

So link-format = "[[{{metadata.id}}|{{title}}]]" still works, but only if your config is setup to use metadata.id as the filename.

I've implemented this in the notebook you shared.
test-tjex.zip

Merry christmas 🎅

@tjex tjex closed this as completed Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants