Hello there!
It would be great if Solargraph supported the textDocument/documentHighlight request. This would allow editors to do things such as highlighting occurrences of a variable in given file:
The document highlight request is sent from the client to the server to resolve a document highlights for a given text document position. For programming languages this usually highlights all references to the symbol scoped to this file. [...]
Thanks in advance!
Pyves
The logic behind it should be essentially the same as textDocument/references, but scoped to the current file instead of the entire workspace. I'll add it to the backlog.
The document-highlight branch has the first implementation of the textDocument/documentHighlight capability. A couple of known issues:
I'll try to resolve both issues before merging to master. With any luck, some of the same performance optimizations will benefit textDocument/references as well.
Another note on usage: I expected the feature to work on hover, but in VS Code, it doesn't get called unless you click on the symbol.
If you test document-highlight and run into any issues, please let me know.
Hello @castwide, thanks for looking into this!
I gave the branch a try from within an IDE. The feature works quite well, good job! I did encounter a few strange cases, for example, consider the following bit of code:
def setup_webrick
requests = Queue.new
double = WEBrick::HTTPServer.new
double.mount_proc('/') do |req|
req.body # Read body from socket.
requests << req
end
Thread.new do
double.start
end
end
When the cursor is placed at the very end of Thread.new do on line 8, the highlights result is the following:

The highlight on line 9 should not be there, and given that I've placed the cursor after the do keyword, one could argue that none of the new methods should be highlighted at all in the first place.
I've observed similar cases with variables as well. Hope this helps!
Would be great to see this feature in Solargraph 馃憤