oxalica / nil

NIx Language server, an incremental analysis assistant for writing in Nix.
Apache License 2.0
1.32k stars 39 forks source link

`textDocument/references` on any occurrence of a variable doesn't currently provide a list of references #86

Closed leungbk closed 1 year ago

leungbk commented 1 year ago

If I have

let x = 1;
    y = x + 1;
    z = x + 42;
in z

then if I have my cursor at the assignment of x, then textDocument/references works as expected. However, if the cursor is at either of the two uses of x, textDocument/references does not work at all.

I think it makes sense to also have textDocument/references work when using it with the cursor on either use of x---this is the behavior I see from some other language servers.

However, I cannot find anything in the protocol about what exactly it ought to return. I have seen at least one server return references while excluding the initial assignment, while others do not exclude the initial assignment. I'm also unsure whether to include the reference at the cursor in the list of returned references, though I would personally prefer to include it.