Closed ray-x closed 3 weeks 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
And to show the reference count on the end of the line, set up codelens by following the directions here
Oh wait; Are you talking about a neovim command/a lua API function?
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]]
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:
In fact, there is a corner case when [[
is concealed
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.
... it also is easier in guis like zed and vscode as you can click anywhere with the mouse
Ill add this to the list
In 987793e I changed where your cursor should be for files. Let me know what you think!
I am working on incoming right now
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!
(if i forget to do this in v1, please reopen)
The vscode markdown lsp uses customer message
markdown/getReferencesToFileInWorkspace
. How do I get something similar inoxide
?