|
pub(crate) fn external_scope(&self, file: &Url) -> ExternalScope { |
Right now external_scope() assumes that file is inside the workspace.
i.e. if you open Desktop/test.R while you have a package's workspace open, it assumes you are trying to create a scope chain for a file in the package.
That is not right for a number of reasons, but in particular I noticed that all of my package's Imports were trying to be made available to test.R because of this.
I think external_scope() probably shouldn't use self.root at all, instead maybe we can discover the project type by walking the ancestors of file each time. I think this would allow:
Desktop/test.R to be discovered as a script because there is no package root
vctrs/R/file.R to still be discovered as part of a package because we find package root info
And then most importantly I'm somewhat hopeful that this can mean that if you goto definition from vctrs into an rlang function, then rlang_cache/R/file.R can be discovered as part of the rlang package rather than the vctrs workspace you might have open at the time, resulting in an entirely different set of goto definition capabilities and diagnostics, etc. Just like what you can do in rust-analyzer
ark/crates/ark/src/lsp/state.rs
Line 97 in 97f1f48
Right now
external_scope()assumes thatfileis inside the workspace.i.e. if you open
Desktop/test.Rwhile you have a package's workspace open, it assumes you are trying to create a scope chain for a file in the package.That is not right for a number of reasons, but in particular I noticed that all of my package's Imports were trying to be made available to
test.Rbecause of this.I think
external_scope()probably shouldn't useself.rootat all, instead maybe we can discover the project type by walking the ancestors offileeach time. I think this would allow:Desktop/test.Rto be discovered as a script because there is no package rootvctrs/R/file.Rto still be discovered as part of a package because we find package root infoAnd then most importantly I'm somewhat hopeful that this can mean that if you goto definition from vctrs into an rlang function, then
rlang_cache/R/file.Rcan be discovered as part of the rlang package rather than the vctrs workspace you might have open at the time, resulting in an entirely different set of goto definition capabilities and diagnostics, etc. Just like what you can do in rust-analyzer