Feel-ix-343 / markdown-oxide

Robust PKM on the LSP
https://oxide.md
GNU General Public License v3.0
928 stars 15 forks source link

Support LSP Incoming and Outgoing #14

Closed ray-x closed 3 weeks ago

ray-x commented 7 months ago

The vscode markdown lsp uses customer message markdown/getReferencesToFileInWorkspace. How do I get something similar in oxide?

Feel-ix-343 commented 7 months ago

In the readme I documented the lsp_references functionality! (if it was not descriptive enough, give me some tell me!)

To get references to a file, put your cursor in the first character of the first line of a file, and call lua vim.lsp.buf.references(). Map this to a keymapping for easier use.

This behavior with the Quickfix list is okay, but I STRONGLY recommend using a plugin like telescope or lspsaga to show the references; the UX is infinitely better.

If you are using Telescope, like I am, call Telescope lsp_references to show the references. I set up keymappings for this in my config.

Here is a quick video to better show it

lspreferences.zip

And to show the reference count on the end of the line, set up codelens by following the directions here

Feel-ix-343 commented 7 months ago

Oh wait; Are you talking about a neovim command/a lua API function?

ray-x commented 7 months ago

I do not think reference and doc backlink are the same. You can show references/backlinks to a file if your cursor is on [[filename]] in filename-b.md But the backlink works in a way that you already opened filename.md and need to find all references to [[filename]]. A similar feature in obsidian.nvim is

:ObsidianBacklinks for getting a picker list of references to the current buffer.

Alternatively, the lsp server can use incomingCall message to achieve that.

Showing backlink on file when put cursor on position [1, 1] may have some ambiguity. What if the first line of markdown is a link, e.g.

[[reference-to-file-c]]
Feel-ix-343 commented 7 months ago

You are right that they are different! I will implement incoming :heavy_check_mark:

As for the position: it does work because all forms of references/referenceables (tags, headings, links, ...) are more than one character; so the user can also move to [1, 2] to get references to them -- while [1, 1] will always be for the file.

But is this ideal? I am not so sure; I am okay with it but I am very open to other ideas. I can think of:

ray-x commented 7 months ago

In fact, there is a corner case when [[ is concealed

image

I prefer

Anywhere in the file that doesn't have another referenceable/reference.

As it does not require jumping to the very beginning of file to check back-links.

Feel-ix-343 commented 7 months ago

... it also is easier in guis like zed and vscode as you can click anywhere with the mouse

Ill add this to the list

Feel-ix-343 commented 6 months ago

In 987793e I changed where your cursor should be for files. Let me know what you think!

I am working on incoming right now

Feel-ix-343 commented 5 months ago

Hey this' been open for a while; I am doing a major refactor right now which will cover it. Just wanted to let you know.

I am also realizing that incoming and outgoing links are give a much more powerful UI experience for backlinking because the LS can attach descriptions (which in moxide's case are backlink previews) to the view. Very excited; big things incoming!

Feel-ix-343 commented 3 weeks ago

(if i forget to do this in v1, please reopen)