You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in nushell/vscode-nushell-lang#117 there is a demand to integrate support for the language server protocol (LSP) into Nushell itself instead of creating an additional command line interface (CLI) protocol (that is the current approach with --ide-* CLI options.
Describe the solution you'd like
Based on the initial draft PR #10723 at least following LSP methods should be supported by Nushell:
The one other thing that I'd like to see added, which I think has to be added on the vscode side is semantic highlighting. Just logging it here to remember.
Not necessarily. This is the tracking issue. We could land #10723 without everything being completed and then have follow-up PRs to complete the remaining tasks.
@schrieveslaach I just heard that the work you've done here has already been added to helix and to zed. Here's a screenshot of zed that was posted on discord.
Reacted by Marc Schreiber and GrabbenD
Reacted by Ron Waldon-Howe, Auca Coyan and Míla Kuchta
Hi! I did a lot of work on nufmt. I checked out the code for the LSP but sadly I understand very little. I do want to help! LSP give life to my everyday code. Is there any help I can give for you? (particulary for @schrieveslaach ) ❤️
@AucaCoyan, thanks for offering help. In the recent weeks hadn't had much time for working on LSP in Nushell and I wasn't sure what to tackle next. Maybe, on workspace/configuration but I'm uncertain how a workspace should behave for a Nushell project.
But what do you think about integrating nufmt as a Document Formatting Request into Nushell? When Nushell's LSP receives the request, it could look for nufmt binary in the PATH variable and then it could format the content kept in memory and sends back the the text edits that the client has to do as well.
Great!
Just for confimation: do you see a better approach to have a different binary called nufmt or do you prefer having a library in nu-lsp that formats code? nufmt it's not close to be ready as a beta yet, it doesn't format a thing. Just checking if you want this or you prefer having everything in one repo for the lsp 👍🏼
@schrieveslaach one thing I think we need to be able to have is the -I include dirs functionality. For vscode, I think that will be a configuration point, but it could also just utilize whatever is in your env.nu NU_LIB_DIRS folders as a starting point.
@schrieveslaach Sorry, this is what I'm talking about. It may not be exactly as I've stated but this is the symptom.
This is my config.nu loaded in nvim. Note that the lsp is failing to find some files.
The reason for this is
I am not specifying any -I parameter to the nu lsp invocation. I'm kind of a nvim noob and I barely got the lsp working.
I'm thinking that the lsp should probably look at NU_LIB_DIRS and apply that automatically. If this were to happen, then I wouldn't have any errors when looking at my config.nu.
In the vscode extension, I get around this by having a config point to manually add Include Dirs.
I'm not saying we should have a config or not. I'm not sure but I am saying that whatever is in NU_LIB_DIRS should be used. This may also assume that a persons env.nu is parsed when launching with nu --lsp which I'm not confident of.
If you are testing with nvim-lspconfig changing the CLI parameters is easy:
This may work but I'm not confident with it because the -I parameter was never meant to be used multiple times when launching nushell. It's meant to be one string with separate folders separated by \x1e, iirc.
Activity
fdncred commentedon Oct 21, 2023
Thanks @schrieveslaach.
The one other thing that I'd like to see added, which I think has to be added on the vscode side is semantic highlighting. Just logging it here to remember.
amtoine commentedon Oct 21, 2023
just to be sure, will #10723 close this issue? 😋
fdncred commentedon Oct 21, 2023
Not necessarily. This is the tracking issue. We could land #10723 without everything being completed and then have follow-up PRs to complete the remaining tasks.
schrieveslaach commentedon Oct 24, 2023
@fdncred,
textDocument/semanticTokensis now in the list. I put an asterisks at the end because there are multiple requests.fdncred commentedon Oct 24, 2023
I'm excited about this!!!!
fdncred commentedon Nov 2, 2023
@schrieveslaach When you get a moment, can you update the tracking items above?
fdncred commentedon Nov 28, 2023
@schrieveslaach I just heard that the work you've done here has already been added to

helixand tozed. Here's a screenshot ofzedthat was posted on discord.AucaCoyan commentedon Dec 1, 2023
Hi! I did a lot of work on
nufmt. I checked out the code for the LSP but sadly I understand very little. I do want to help! LSP give life to my everyday code. Is there any help I can give for you? (particulary for @schrieveslaach ) ❤️schrieveslaach commentedon Dec 3, 2023
@AucaCoyan, thanks for offering help. In the recent weeks hadn't had much time for working on LSP in Nushell and I wasn't sure what to tackle next. Maybe, on
workspace/configurationbut I'm uncertain how a workspace should behave for a Nushell project.But what do you think about integrating
nufmtas a Document Formatting Request into Nushell? When Nushell's LSP receives the request, it could look fornufmtbinary in the PATH variable and then it could format the content kept in memory and sends back the the text edits that the client has to do as well.AucaCoyan commentedon Dec 3, 2023
Great!
Just for confimation: do you see a better approach to have a different binary called
nufmtor do you prefer having a library innu-lspthat formats code?nufmtit's not close to be ready as a beta yet, it doesn't format a thing. Just checking if you want this or you prefer having everything in one repo for the lsp 👍🏼fdncred commentedon Dec 3, 2023
we should not integrate
nufmtyet. it's not very useful in its current state.Send LSP Completion Item Kind (#11443)
fdncred commentedon Mar 31, 2024
@schrieveslaach one thing I think we need to be able to have is the
-Iinclude dirs functionality. For vscode, I think that will be a configuration point, but it could also just utilize whatever is in your env.nu NU_LIB_DIRS folders as a starting point.schrieveslaach commentedon Apr 6, 2024
@fdncred, I'm not so sure if I can follow you. The
-Ioption is evaluated and set put into theengine_statebefore starting the LSP (in the same fashion as for the IDE command line options). If you are talking about this, I'm lost what is not yet working.Or are you talking about the
rootUriLSP init parameter? Here I'm unsure how arootUrishould be treated be nu's LSP.fdncred commentedon Apr 7, 2024
@schrieveslaach Sorry, this is what I'm talking about. It may not be exactly as I've stated but this is the symptom.
This is my config.nu loaded in nvim. Note that the lsp is failing to find some files.

The reason for this is
In the vscode extension, I get around this by having a config point to manually add Include Dirs.

I'm not saying we should have a config or not. I'm not sure but I am saying that whatever is in NU_LIB_DIRS should be used. This may also assume that a persons env.nu is parsed when launching with
nu --lspwhich I'm not confident of.schrieveslaach commentedon Apr 8, 2024
If you are testing with
nvim-lspconfigchanging the CLI parameters is easy:It doesn't parse standard config files. Seems to me that it should in certain cases. Maybe, if there is no
rootUripresent. Let me check something.schrieveslaach commentedon Apr 8, 2024
@fdncred, have a look at #12454 if that solves your issue.
fdncred commentedon Apr 8, 2024
This may work but I'm not confident with it because the
-Iparameter was never meant to be used multiple times when launching nushell. It's meant to be one string with separate folders separated by\x1e, iirc.I'll test #12454 soon.
schrieveslaach commentedon Apr 9, 2024
Providing
-Imultiple time was just a guess. Following should do the trick then.Set Up Config in LSP Mode (#12454)
tombh commentedon Nov 21, 2024
Regarding
nufmt, the relevant part of the spec would be:textDocument/formatting