Skip to content

Conversation

AlexeyRaga
Copy link
Contributor

@AlexeyRaga AlexeyRaga commented Sep 2, 2025

Description

Switch from using specific --ide-* legacy parameters to using a full LSP server (provided by nu --lsp).

In this mode the plugin will automatically detect capabilities that LSP provides and will enable/support appropriate feature set in the IDE.

In particular, renaming capability works in this mode, which addresses #206 and, likely, delivers other goodness.

nushell-rename

@fdncred
Copy link
Contributor

fdncred commented Sep 2, 2025

wow! thanks for this! I'd like to have a deprecation period and a fallback to the traditional ide commands set via configuration. meaning, it would be nice to default to your new code but have an option in the settings to switch back to ide-* mode. do you think that's possible?

@AlexeyRaga
Copy link
Contributor Author

AlexeyRaga commented Sep 2, 2025

@fdncred

Maybe? I don't know... Having some sort of a switch in the configuration, etc...
I don't really know.
But why? To support ancient versions of nu that doesn't have --lsp in it? Or what would the reason be?

I think we have two simpler options:

  1. publish the new major version. People who for whatever reason want to fallback to --ide commands can just use the previous version of the plugin.

The last time it updated was almost a year ago, so it is not like someone would be missing frequently coming updates etc.

  1. Publish a pre-release version of a plugin and keep it pre-release for that "deprecation period". After then we could finally switch.

I think that any of these is simpler than having a mixed codebase with switching logic etc.

@fdncred
Copy link
Contributor

fdncred commented Sep 2, 2025

But why?

My fear that there will be funky bugs and no one to support the changes. If you want to sign up to support bugs for a little while, let's go ahead and just land it and publish it after the nushell release (which is supposed to be today).

@AlexeyRaga
Copy link
Contributor Author

AlexeyRaga commented Sep 2, 2025

I am fine with supporting bugs on the plugin side (because there is little-to-no code to support, it is all LSP ;) )

But to play it very safe, let's publish a pre-release version of the plugin. People can opt-in for the new version and with one click opt-out if something goes wrong.

This is literally how every other plugin does it, and how VSCode plugins life cycle is designed to be

image

We wait for a month or so, watch the feedback, and then make it as a main release.

Do you agree @fdncred ?

@fdncred
Copy link
Contributor

fdncred commented Sep 2, 2025

Sounds good but I'm not sure how to make it pre-release.

@AlexeyRaga
Copy link
Contributor Author

Docs say it is fairly easy, just by adding --pre-release parameter:

vsce package --pre-release
vsce publish --pre-release

Ref: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions

@fdncred
Copy link
Contributor

fdncred commented Sep 3, 2025

ok, thanks. i can try that. we just released nushell 0.107.0 so it's a good time for me to try and remember how to do this release.

@fdncred fdncred merged commit 92a4208 into nushell:main Sep 3, 2025
1 check passed
@fdncred
Copy link
Contributor

fdncred commented Sep 3, 2025

@AlexeyRaga I'm trying to test the latest main branch on Windows and am getting all kinds of errors. Any ideas?

[Error - 3:49:38 PM] Client Nushell Language Server: connection to server is erroring. Shutting down server.
[Error - 3:49:38 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
	at Fl.shutdown (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:8615)
	at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:8194)
	at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:44100)
	at Fl.handleConnectionError (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:13955)
	at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[Error - 3:49:40 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:49:40 PM] Connection to server got closed. Server will restart.
true
[Error - 3:49:40 PM] Nushell Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:41 PM] Client Nushell Language Server: connection to server is erroring. Shutting down server.
[Error - 3:49:41 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
	at Fl.shutdown (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:8615)
	at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:8194)
	at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:44100)
	at Fl.handleConnectionError (c:\Users\username\source\repos\forks\vscode-nushell-lang\out\extension.js:39:13955)
	at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
[Error - 3:49:43 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:49:43 PM] Connection to server got closed. Server will restart.
true
[Error - 3:49:43 PM] Nushell Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:47 PM] Client Nushell Language Server: connection to server is erroring. Shutting down server.
[Error - 3:49:47 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
    at Fl.shutdown (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:914:19)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:885:21)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\node\main.js:150:22)
    at Fl.handleConnectionError (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:1146:18)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
[Error - 3:49:50 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:49:50 PM] Connection to server got closed. Server will restart.
true
[Error - 3:49:50 PM] Nushell Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:50 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:50 PM] Client Nushell Language Server: connection to server is erroring. Shutting down server.
[Error - 3:49:50 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
    at Fl.shutdown (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:914:19)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:885:21)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\node\main.js:150:22)
    at Fl.handleConnectionError (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:1146:18)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
[Error - 3:49:53 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:49:53 PM] Connection to server got closed. Server will restart.
true
[Error - 3:49:53 PM] Nushell Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:53 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:53 PM] Client Nushell Language Server: connection to server is erroring. Shutting down server.
[Error - 3:49:53 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
    at Fl.shutdown (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:914:19)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:885:21)
    at Fl.stop (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\node\main.js:150:22)
    at Fl.handleConnectionError (c:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\vscode-languageclient\lib\common\client.js:1146:18)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
[Error - 3:49:55 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:55 PM] The Nushell Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 3:49:55 PM] Nushell Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:49:55 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

@fdncred
Copy link
Contributor

fdncred commented Sep 3, 2025

I updated a bunch of deps and now am getting this, along with the other errors.

[Error - 4:25:36 PM] Client Nushell Language Server: connection to server is erroring.
Header must provide a Content-Length property.
{"hello, from env.nu\nhello, from config.nu\nhello, from defs.nu\ncontent-length":"578"}
Shutting down server.

If I run nu --lsp from the repl i get this. it looks like it's trying to send those prints via stdout

❯ nu --lsp
Hello, from env.nu
Hello, from config.nu
Hello, from defs.nu

@fdncred
Copy link
Contributor

fdncred commented Sep 3, 2025

That's it. Those extra "prints" were sending that information to the LSP. If I comment them out it works. I wonder how to get around this?
image

@AlexeyRaga AlexeyRaga deleted the use-lsp branch September 4, 2025 00:13
@fdncred
Copy link
Contributor

fdncred commented Sep 4, 2025

I figured out how to have my cake and eat it too. I can print -e from my config files and the lsp doesn't care since -e is on stderr. The popups are a little wonky though on built-ins. Not sure what the markdown is exactly.
image

@fdncred
Copy link
Contributor

fdncred commented Sep 4, 2025

@AlexeyRaga The new version is published but I don't see the Switch to Pre-Release button. I did vsce package --pre-release but the vsco publish --pre-release has never worked for me. So, I just upload the vsix to the site. Seems like without this step no one will be able to easily use the new version. Any ideas on what to do?

If I uninstall, I can then install the pre-release version though.

@AlexeyRaga
Copy link
Contributor Author

@fdncred I do have it, without having to uninstall etc:
image

Maybe it is some caching, or a VSCode required to restart, I don't know... But worked for me

@fdncred
Copy link
Contributor

fdncred commented Sep 6, 2025

ok, glad it worked for someone. thanks for letting me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants