languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

[FR] support language services for functions inside of an environment

Open shrektan opened this issue 3 years ago • 1 comments

I often use "environment" as the namespace of R, so that I can manage the name conflicts in a large R project. Also, it's much easier to find the source of the function, with such "namespace".

However, using this pattern in VSCode R is not very convenient, as it can't provide any parameter info when calling functions inside of an environment (or a list).

It's probably difficult to provide "static" analysis for environment functions. But I think, at least we should use the current session info, as RStudio IDE does.

Thanks.

normal_fun <- function(a, b) {
  a + b
}

env <- new.env()
env$fun <- function(a, b) {
  a + b
}

# move curser on normal_fun, vscode tips the arguments; type a inside the bracket, it hints `a` is an argument
normal_fun()

# in contrast, a function inside an environment loses such ability
env$fun()
image

shrektan avatar Feb 14 '22 16:02 shrektan

As you have mentioned, it is difficult with only lexical analysis. The LSP itself doesn't have a mechanism to hook into a live session, we will need to have something novel in order to allow such feature.

randy3k avatar Feb 14 '22 21:02 randy3k