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

How to use "findReferences" code lens (arguments seem to be missing) #337

Open
krobelus opened this issue Oct 16, 2024 · 2 comments
Open
Labels
question General question about functionality, integrations, etc.

Comments

@krobelus
Copy link

Given this markdown file

link 1 [section]
link 2 [section]
link 3 [section]

[section]: asdf

if I open it in Kakoune there'll be a code lens sign in the last line.
If I move to that line and try to run it via :lsp-code-lens that doesn't work.
Perhaps this is because the arguments field is omitted?
Even if I interpret missing arguments as [], performing the code lens gives no results.

I suspect we need to pass the position as arguments

LSP: DEBG To server marksman: {"jsonrpc":"2.0","method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///home/johannes/git/kakoune-lsp/t/test.md"}},"id":1}
LSP: DEBG From server marksman: {"jsonrpc":"2.0","id":1,"result":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":15}},"command":{"title":"3 references","command":"marksman.findReferences"}}]}

LSP: DEBG To server marksman: {"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":[],"command":"marksman.findReferences"},"id":10}
LSP: DEBG From server marksman: {"jsonrpc":"2.0","id":10,"result":0}

If I try in Neovim, I don't get a code lens at all, not sure why.

krobelus added a commit to kakoune-lsp/kakoune-lsp that referenced this issue Oct 17, 2024
marksman sends a workspace/executeCommand without arguments,
which seems to be allowed by LSP.
Let's interpret it as empty array.

The code lens still doesn't actually seem to do anything, see
artempyanykh/marksman#337
@artempyanykh
Copy link
Owner

artempyanykh commented Nov 19, 2024

Thanks for asking @krobelus! There are 2 parts to the answer:

  1. The findReferences command is supposed to trigger editor's 'show references' dialog. Since this part is editor-specific, generating arguments is currently gated by an experimental flag. The implementation is nothing fancy though. This works as most LSP clients just ignore commands without arguments.
  2. The lens itself is supposed to provide a visual 'at-a-glance' indication of usage. Even without the command arguments this is good enough and the user (if needed) can trigger 'find references' themselves.

Are you looking to make findReferences command work with kakoune-lsp?

P.S. I'm not sure why you don't get the lens in nvim. What's your setup?

@artempyanykh artempyanykh added the question General question about functionality, integrations, etc. label Nov 19, 2024
@artempyanykh
Copy link
Owner

This is the relevant part in the server: https://github.com/artempyanykh/marksman/blob/main/Marksman/Lenses.fs#L24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question about functionality, integrations, etc.
Projects
None yet
Development

No branches or pull requests

2 participants