REditorSupport / languageserver

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

autocompletion not work on vscode remote-ssh #329

Open ddzhang3 opened 3 years ago

ddzhang3 commented 3 years ago

VScode-R gives me a wonderful experience on a local machine (macOS) with R and R LSP client extension installed. However it fails to work on a remote linux server when I connect from VScode remote-ssh extension. Particularly the autocompletion doesn't work anymore. I have R 1.4.4 extension and R LSP client 0.1.10 installed on the remote server. So how can I get the autocompletion work also on my remote linux server? the Rterm.linux was set the R binary on linux server in the remote settings in vscode. I use the original R binary on both local and remote machine. Thank you

renkun-ken commented 3 years ago

If R is installed under default settings, everything should work out of the box including via remote-ssh.

Have you properly installed languageserver on your remote machine?

If so, and it is still not working, would you like to turn on r.lsp.debug in your settings, reload vscode, and see if the vscode-r-lsp extension is activated or stopped on error via the "R Language Server" in output panel? It should print the logs from the language server.

ddzhang3 commented 3 years ago

The R is installed using --prefix=/the/R/bin/location with the remaining setting leave as it is. I turn the r.lsp.debug on: "r.lsp.debug": true And the output from the R language server is below:

R Language Server (23252) started R Language Server (23252) exited with exit code 0

renkun-ken commented 3 years ago

It looks like you installed R into a customized location. Then you need to set r.lsp.path to your R executable.

ddzhang3 commented 3 years ago

Thank you. It seems to work, but the suggestion for the function comes rather slowly, usually after >= 1 min. And when I meant to type "t.test" the "R language server" output is like this: [2020-08-27 21:31:46.088] handling request: textDocument/completion

[2020-08-27 21:31:46.089] token: { "full_token": "t", "right_token": "", "package": null, "accessor": "", "token": "t" }

[2020-08-27 21:31:55.538] bracket is

[2020-08-27 21:31:55.539] completions: 85

[2020-08-27 21:31:55.539] deliver: ["Response", "Message", "R6"]

[2020-08-27 21:31:55.622] received: Content-Length: 63

[2020-08-27 21:31:55.633] received payload.

[2020-08-27 21:31:55.633] unknown notification: $/cancelRequest

[2020-08-27 21:31:55.634] received: Content-Length: 226

[2020-08-27 21:31:55.645] received payload.

[2020-08-27 21:31:55.645] handling notification: textDocument/didChange

There's an unknown notification above. Is the slow autocompletion can be avoided in some ways?

renkun-ken commented 3 years ago

Do other features look slow, such as hover, function signature? It looks like your sever is too busy or the network condition is not good?

ddzhang3 commented 3 years ago

The hover feature is a litter faster than autocompletion, yet slower than on the local machine. I think you are right, the network is slow when transferring between local and remote machines. Another question: The "Preference: Open user settings" contain 3 panels: User, Remote, workplace, and I find that the User settings on Rterm seems to influence the remote server. Is there a priority among these three?

renkun-ken commented 3 years ago

To my knowledge, the priority should be User, Remote, and then workspace. In your case, you specify the R path in your user settings. It will be applied to all remotes and workspaces, unless you specify in remote settings or workspace settings to override.

ddzhang3 commented 3 years ago

Last question maybe not associated with r language server: the vscode remote-ssh logins into the login node rather than compute node in our department cluster, while the computation using R should be conducted on the compute nodes. My workaround is to let the R codes run on the active terminal in which I switch to the computer node. This works well when running non-GUI commands, but failed on GUI-ones such as "plot". Even after I install "Remote X11" extension, the plot command stucks on the R console in the compute node within the vscode terminal. Do you have experience about this topic?

Thank you and apologize to ask unrelated questions.

renkun-ken commented 3 years ago

Do you have an idea how the login node sends commands to the compute node?

ddzhang3 commented 3 years ago

They don't send commands each other. In our cluster settings, we logon to the login node through "ssh -Y user@remoteserver" using iterm2, and then we can switch to compute node through another "ssh -Y computenode1". Maybe different from your own configures.

ddzhang3 commented 3 years ago

https://renkun.me/2019/12/26/writing-r-in-vscode-interacting-with-an-r-session/ How the ggplot and basic plots are shown in your blog? Is this on a remote-ssh ? looks terrific

renkun-ken commented 3 years ago

They don't send commands each other. In our cluster settings, we logon to the login node through "ssh -Y user@remoteserver" using iterm2, and then we can switch to compute node through another "ssh -Y computenode1". Maybe different from your own configures.

You may take a look at https://www.tecmint.com/access-linux-server-using-a-jump-host/ and use the following .ssh/config:

Host login-server
    HostName remoteserver
    User user
Host computenode1
    HostName computenode1
    User user
    ProxyJump login-server

Then you could use ssh computenode1 to login computenode1 via login-server automatically, which also works with VSCode Remote-SSH as I tried before.

How the ggplot and basic plots are shown in your blog? Is this on a remote-ssh ? looks terrific

It should work under remote-ssh. You need to turn on r.sessionWatcher and I suggest that you take a look at https://github.com/Ikuyadeu/vscode-R/wiki/R-Session-watcher.