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

add option to insert link from telescope #95

Closed
wants to merge 1 commit into from

Conversation

lateef-k
Copy link

@lateef-k lateef-k commented Dec 30, 2022

Hello,

This lets you select notes in telescope and add them as links in the current buffer.

This is already part of my workflow personally, I thought it might be useful to include in the plugin. This works fine but I don't think the PR should be accepted in its current form.

There might be a better way to configure the mapping. And as it stands, this inserts links as a markdown link. It should probably autodetect the desired format from a notebook's config. We could probably read the notebook config and use a pattern search to get the link-format. It's straightforward if it's either markdown or wiki links, but it's more involved if it's custom. Perhaps this is functionality that should be implemented in zk and exposed through the LSP?

@lateef-k lateef-k closed this Dec 31, 2022
@mickael-menu
Copy link
Member

Thanks, that would be a really useful addition.

By the way, you can get a link to a note formatted according to the config option using:

zk list note.md -q --format "{{link}}"

It can even generate relative links with -W:

zk list -W dir ../note.md -q --format "{{link}}"

I don't think format is exposed in the zk.list LSP command but I could add it if needed.

@lateef-k
Copy link
Author

lateef-k commented Jan 5, 2023

Thanks for the tip! It does seem from this line in the zk LSP server that format doesn't get used at all, as opposed to the CLI version of the same command. I can reopen this PR if format gets implemented in the LSP and refactor the code to use it.

I would've made the changes in zk myself but I haven't written a line of Go in my life. I'm curious though, is there a reason that the LSP and the CLI instantiate notes differently? Couldn't they share the exact implementation?

@mickael-menu
Copy link
Member

mickael-menu commented Jan 17, 2023

Okay, I'll let you know when something is available in the zk LSP. There is a pending PR that might be of interest for this as well: zk-org/zk#284

The reason format is not available now is because it's used to format the output of the CLI command. But the LSP command returns a structured JSON, so a custom format doesn't make much sense in this context.

I'm curious though, is there a reason that the LSP and the CLI instantiate notes differently? Couldn't they share the exact implementation?

They do share the same implementation. The only exception is the CLI takes the Note model and produces a formatted output according to format, while the LSP command serializes the Note to JSON.

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

Successfully merging this pull request may close these issues.

2 participants