I'm interacting with rust-analyzer instance from a python script. I've gotten the script to connect successfully and open a file, but it seems to not be properly handling textDocument/definition
requests. rust-analyzer always returns an empty results array. Does anyone have any insights into whats going on? I'm assuming I'm missing some setting somewhere?
My setup is this:
C:\Users\root\Downloads\rust-test
is a default rust project created with cargo init
and with the contents of main.rs
replaced with:
struct Foo;
enum E { X(Foo) }
based on this test in rust-analyzer.
These are the messages sent and received between rust-analyzer and my script:
SENDING
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"processId": 54316, "rootUri": "file:///C:/users/root/Downloads/rust-test/", "capabilities": {}, "trace": "messages"}}
RECIEVED
{"jsonrpc":"2.0","id":1,"result":{"capabilities":{ (Omitted for brevity) },"serverInfo":{"name":"rust-analyzer","version":"0.3.2045-standalone (4afe0d539 2024-07-21)"}}}
SENDING
{"jsonrpc": "2.0", "method": "initialized", "params": {}}
SENDING
{"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "file:///C:\\Users\\root\\Downloads\\rust-test\\src\\main.rs", "languageId": "rust", "version": 1, "text": "struct Foo;\n\nenum E { X(Foo) }\n"}}}
SENDING
{"jsonrpc": "2.0", "id": 4, "method": "textDocument/definition", "params": {"textDocument": {"uri": "file:///C:\\Users\\root\\Downloads\\rust-test\\src\\main.rs"}, "position": {"line": 2, "character": 13}}}
RECIEVED
{"jsonrpc":"2.0","id":4,"result":[]}