Skip to content

Commit

Permalink
Add support for Nushell (#4303)
Browse files Browse the repository at this point in the history
Co-authored-by: Jen-Chieh Shen <[email protected]>
  • Loading branch information
fredericgiquel and jcs090218 authored Mar 16, 2024
1 parent ef06dcc commit eff7761
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
* Add Hylang support.
* Add support for clojure-ts derived modes.
* Add support for installing Ada Language Server.
* Add Nushell support

** Release 8.0.0
* 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.
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.
Expand Down
59 changes: 59 additions & 0 deletions clients/lsp-nushell.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
;;; lsp-nushell.el --- lsp-mode ansible integration -*- lexical-binding: t; -*-

;; Copyright (C) 2024 emacs-lsp maintainers

;; Author: lsp-mode maintainers
;; Keywords: lsp, nushell

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; LSP Client for the nushell Language

;;; Code:

(require 'lsp-mode)

(defgroup lsp-nushell nil
"LSP support for nushell."
:group 'lsp-mode
:link '(url-link "https://github.com/nushell/nushell"))

(defcustom lsp-nushell-language-server-command
'("nu" "--lsp")
"The command that starts the nushell language server."
:type '(repeat :tag "List of string values" string)
:group 'lsp-nushell)

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection lsp-nushell-language-server-command)
:activation-fn (lsp-activate-on "nushell")
:priority -1
:initialized-fn (lambda (workspace)
;; Nushell server returns an empty list of
;; completion options at initialization
;; so completionProvider capability is {}
;; When using plists, this value is parsed as
;; null/nil so we need to force it to "t"
;; to enable completion
(let ((caps (lsp--workspace-server-capabilities workspace)))
(unless (lsp-get caps :completionProvider)
(lsp:set-server-capabilities-completion-provider? caps t))))
:server-id 'nushell-ls))

(lsp-consistency-check lsp-nushell)

(provide 'lsp-nushell)
;;; lsp-nushell.el ends here
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,14 @@
"installation": "nix-env -i nil || nix profile install nixpkgs#nil",
"debugger": "Not available"
},
{
"name": "nushell",
"full-name": "Nushell",
"server-name": "nu",
"server-url": "https://github.com/nushell/nushell/tree/main/crates/nu-lsp",
"installation": "It is included in Nushell >= 0.87.0",
"debugger": "Not available"
},
{
"name": "ocaml",
"full-name": "OCaml",
Expand Down
7 changes: 5 additions & 2 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ As defined by the Language Server Protocol 3.16."
lsp-groovy lsp-haskell lsp-haxe lsp-idris lsp-java lsp-javascript lsp-json
lsp-kotlin lsp-latex lsp-ltex lsp-lua lsp-markdown lsp-marksman lsp-mdx
lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik lsp-mojo lsp-metals
lsp-mssql lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
lsp-mssql lsp-nushell lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
lsp-pls lsp-php lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
lsp-purescript lsp-r lsp-racket lsp-remark lsp-ruff-lsp lsp-rf lsp-rubocop
lsp-rust lsp-semgrep lsp-shader lsp-solargraph lsp-sorbet lsp-sourcekit
Expand Down Expand Up @@ -780,6 +780,7 @@ Changes take effect only when a new session is started."
("\\.jq$" . "jq")
("\\.lua$" . "lua")
("\\.mdx\\'" . "mdx")
("\\.nu$" . "nushell")
("\\.php$" . "php")
("\\.rs\\'" . "rust")
("\\.spec\\'" . "rpm-spec")
Expand Down Expand Up @@ -954,7 +955,9 @@ Changes take effect only when a new session is started."
(wgsl-mode . "wgsl")
(jq-mode . "jq")
(jq-ts-mode . "jq")
(protobuf-mode . "protobuf"))
(protobuf-mode . "protobuf")
(nushell-mode . "nushell")
(nushell-ts-mode . "nushell"))
"Language id configuration.")

(defvar lsp--last-active-workspaces nil
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ nav:
- Nix (nixd-lsp): page/lsp-nix-nixd.md
- Nix (rnix-lsp): page/lsp-nix-rnix.md
- Nix (nil): page/lsp-nix-nil.md
- Nushell: page/lsp-nushell.md
- OCaml (ocaml-lsp): page/lsp-ocaml-lsp-server.md
- OpenSCAD: page/lsp-openscad.md
- Pascal/Object Pascal: page/lsp-pascal.md
Expand Down

0 comments on commit eff7761

Please sign in to comment.