REditorSupport / languageserver

An implementation of the Language Server Protocol for R
Other
564 stars 91 forks source link

"glue" function semantic for the expressions inside {} #633

Open Tal500 opened 10 months ago

Tal500 commented 10 months ago

The R package glue helps R developer to print data in a formatted manner, in a similarity to python formatted strings(i.e. f"..." in python). Example usage:

glue("x = {x}", x=42);# prints "x = 42"

As you can see that by the naive highlighter like the one of GitHub(i.e. semantic-free highlighter), the variable inside "{x}" isn't treated as an R expression. Sadly, this happens also in R language server as well.

It would be nice if R language server will treat the glue function as an exceptional function, and treat what appears in "{}" as R expression. Not only it will help on highlighting, but also for other utility of language server(go to def, find reference, rename, auto-complete, ...).

Right now, I prefer to use paste()/paste0() instead of glue(), only because R language server (and the R linter BTW, not related to here) ignores the expression meaning.