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

Support LSP Incoming and Outgoing #14

Open
ray-x opened this issue Mar 2, 2024 · 8 comments
Open

Support LSP Incoming and Outgoing #14

ray-x opened this issue Mar 2, 2024 · 8 comments

Comments

@ray-x
Copy link

ray-x commented Mar 2, 2024

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

@Feel-ix-343
Copy link
Owner

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
Copy link
Owner

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

@ray-x
Copy link
Author

ray-x commented Mar 2, 2024

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
Copy link
Owner

You are right that they are different! I will implement incoming ✔️

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:

  • [1, 1]
  • Anywhere in the file that doesn't have another referenceable/reference.
  • .. what you do think?

@ray-x
Copy link
Author

ray-x commented Mar 2, 2024

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
Copy link
Owner

Feel-ix-343 commented Mar 3, 2024

... 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
Copy link
Owner

Feel-ix-343 commented Mar 8, 2024

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
Copy link
Owner

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 Feel-ix-343 added this to the Refined Markdown Oxide milestone May 17, 2024
@Feel-ix-343 Feel-ix-343 changed the title How to show backlink to a markdown file? Support LSP Incoming and Outgoing Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants