vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

LSP (e.g. Go to Definition) not working across files with source

Open fredcallaway opened this issue 7 months ago • 4 comments
trafficstars

I find that all the language server features seem to be unaware of sourced files. This includes "Go to Definition" and "Go to Symbol in Workspace". It also won't pull in completions and tool tips from libraries.

It does work when I have the sourced file open (regardless of whether I actually source the file).

It also works when I use the exact R package directory setup (per chat GPT).

myproject/
├── DESCRIPTION            # <- triggers package behavior
├── R/
│   ├── functions.R        # <- put your function definitions here
├── scripts/
│   └── test.R

However, if I remove the DESCRIPTION or rename the R/ directory (e.g. to "lib") then it stops working.

This seems way more brittle than necessary. Why not just do a recursive walk and index all .r files starting from the workspace directory? At minimum, it would be nice to document this so that future users don't have to go through this whole discovery process.

fredcallaway avatar Mar 26 '25 12:03 fredcallaway