Skip to content

Commit eff7761

Browse files
Add support for Nushell (#4303)
Co-authored-by: Jen-Chieh Shen <[email protected]>
1 parent ef06dcc commit eff7761

File tree

5 files changed

+75
-2
lines changed

5 files changed

+75
-2
lines changed

CHANGELOG.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
* Add Hylang support.
110110
* Add support for clojure-ts derived modes.
111111
* Add support for installing Ada Language Server.
112+
* Add Nushell support
113+
112114
** Release 8.0.0
113115
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
114116
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.

clients/lsp-nushell.el

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
;;; lsp-nushell.el --- lsp-mode ansible integration -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2024 emacs-lsp maintainers
4+
5+
;; Author: lsp-mode maintainers
6+
;; Keywords: lsp, nushell
7+
8+
;; This program is free software; you can redistribute it and/or modify
9+
;; it under the terms of the GNU General Public License as published by
10+
;; the Free Software Foundation, either version 3 of the License, or
11+
;; (at your option) any later version.
12+
13+
;; This program is distributed in the hope that it will be useful,
14+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
;; GNU General Public License for more details.
17+
18+
;; You should have received a copy of the GNU General Public License
19+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
21+
;;; Commentary:
22+
23+
;; LSP Client for the nushell Language
24+
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
29+
(defgroup lsp-nushell nil
30+
"LSP support for nushell."
31+
:group 'lsp-mode
32+
:link '(url-link "https://github.com/nushell/nushell"))
33+
34+
(defcustom lsp-nushell-language-server-command
35+
'("nu" "--lsp")
36+
"The command that starts the nushell language server."
37+
:type '(repeat :tag "List of string values" string)
38+
:group 'lsp-nushell)
39+
40+
(lsp-register-client
41+
(make-lsp-client :new-connection (lsp-stdio-connection lsp-nushell-language-server-command)
42+
:activation-fn (lsp-activate-on "nushell")
43+
:priority -1
44+
:initialized-fn (lambda (workspace)
45+
;; Nushell server returns an empty list of
46+
;; completion options at initialization
47+
;; so completionProvider capability is {}
48+
;; When using plists, this value is parsed as
49+
;; null/nil so we need to force it to "t"
50+
;; to enable completion
51+
(let ((caps (lsp--workspace-server-capabilities workspace)))
52+
(unless (lsp-get caps :completionProvider)
53+
(lsp:set-server-capabilities-completion-provider? caps t))))
54+
:server-id 'nushell-ls))
55+
56+
(lsp-consistency-check lsp-nushell)
57+
58+
(provide 'lsp-nushell)
59+
;;; lsp-nushell.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,14 @@
654654
"installation": "nix-env -i nil || nix profile install nixpkgs#nil",
655655
"debugger": "Not available"
656656
},
657+
{
658+
"name": "nushell",
659+
"full-name": "Nushell",
660+
"server-name": "nu",
661+
"server-url": "https://github.com/nushell/nushell/tree/main/crates/nu-lsp",
662+
"installation": "It is included in Nushell >= 0.87.0",
663+
"debugger": "Not available"
664+
},
657665
{
658666
"name": "ocaml",
659667
"full-name": "OCaml",

lsp-mode.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ As defined by the Language Server Protocol 3.16."
183183
lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json
184184
lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
185185
lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik lsp-mojo lsp-metals
186-
lsp-mssql lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
186+
lsp-mssql lsp-nushell lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
187187
lsp-pls lsp-php lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
188188
lsp-purescript lsp-r lsp-racket lsp-remark lsp-ruff-lsp lsp-rf lsp-rubocop
189189
lsp-rust lsp-semgrep lsp-shader lsp-solargraph lsp-sorbet lsp-sourcekit
@@ -780,6 +780,7 @@ Changes take effect only when a new session is started."
780780
("\\.jq$" . "jq")
781781
("\\.lua$" . "lua")
782782
("\\.mdx\\'" . "mdx")
783+
("\\.nu$" . "nushell")
783784
("\\.php$" . "php")
784785
("\\.rs\\'" . "rust")
785786
("\\.spec\\'" . "rpm-spec")
@@ -954,7 +955,9 @@ Changes take effect only when a new session is started."
954955
(wgsl-mode . "wgsl")
955956
(jq-mode . "jq")
956957
(jq-ts-mode . "jq")
957-
(protobuf-mode . "protobuf"))
958+
(protobuf-mode . "protobuf")
959+
(nushell-mode . "nushell")
960+
(nushell-ts-mode . "nushell"))
958961
"Language id configuration.")
959962

960963
(defvar lsp--last-active-workspaces nil

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ nav:
113113
- Nix (nixd-lsp): page/lsp-nix-nixd.md
114114
- Nix (rnix-lsp): page/lsp-nix-rnix.md
115115
- Nix (nil): page/lsp-nix-nil.md
116+
- Nushell: page/lsp-nushell.md
116117
- OCaml (ocaml-lsp): page/lsp-ocaml-lsp-server.md
117118
- OpenSCAD: page/lsp-openscad.md
118119
- Pascal/Object Pascal: page/lsp-pascal.md

0 commit comments

Comments
 (0)