languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

Add `::` after the package name

Open eitsupi opened this issue 3 years ago • 3 comments

On RStudio or radian, we will see a candidate like package::, and we don't have to type :: ourselves when writing a function name without omitting the package name package::function().

image

I wonder if languageserver could present such candidates.

eitsupi avatar Feb 08 '22 14:02 eitsupi

It should be an easy pick https://github.com/REditorSupport/languageserver/blob/master/R/completion.R#L65.

randy3k avatar Feb 08 '22 18:02 randy3k

If we use ggplot2 as the label but ggplot2:: as the insert text, it would be undesired if the user is typing in function calls like library(ggplot2::).

Also, user typing :: also triggers completion of exported objects in the package, but inserting ggplot2:: will not trigger completion in vscode.

renkun-ken avatar Feb 09 '22 00:02 renkun-ken

Thank you both !

If we use ggplot2 as the label but ggplot2:: as the insert text, it would be undesired if the user is typing in function calls like library(ggplot2::).

~~It looks like radian has two independent candidates.~~

Does radian detect the library and change which one to show?

https://github.com/randy3k/radian/blob/ddca690893e7c6197ce7afd2f9f36d52f1201c4d/radian/completion.py#L16-L18

image

image

Also, user typing :: also triggers completion of exported objects in the package, but inserting ggplot2:: will not trigger completion in vscode.

I get it. It would certainly be great to see all the candidates displayed. However, if we remember the name of the desired function, for example ggplot(), typing g will list the candidates starting with g.

image

So, I think it will be more convenient in actual use.

eitsupi avatar Feb 09 '22 14:02 eitsupi