From 5a4a65bbfc4eb93bf5af47d3c11a06655d43bea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Giquel?= Date: Fri, 19 Jan 2024 19:52:30 +0100 Subject: [PATCH] Add support for Nushell --- CHANGELOG.org | 1 + clients/lsp-nushell.el | 59 ++++++++++++++++++++++++++++++++++++++++++ docs/lsp-clients.json | 8 ++++++ lsp-mode.el | 7 +++-- mkdocs.yml | 1 + 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 clients/lsp-nushell.el diff --git a/CHANGELOG.org b/CHANGELOG.org index 8d55e7dc6d..4f0ea19fba 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -103,6 +103,7 @@ * Add Assembly Language support. * Add Autotools support * Add Jsonnet support + * 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. diff --git a/clients/lsp-nushell.el b/clients/lsp-nushell.el new file mode 100644 index 0000000000..19855e55eb --- /dev/null +++ b/clients/lsp-nushell.el @@ -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 . + +;;; 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 diff --git a/docs/lsp-clients.json b/docs/lsp-clients.json index ef89ebd2ad..e66f19290a 100644 --- a/docs/lsp-clients.json +++ b/docs/lsp-clients.json @@ -636,6 +636,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", diff --git a/lsp-mode.el b/lsp-mode.el index 8e3b5e6aca..bbe08ff147 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -182,7 +182,7 @@ As defined by the Language Server Protocol 3.16." lsp-hack lsp-grammarly 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-mojo lsp-metals 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 @@ -778,6 +778,7 @@ Changes take effect only when a new session is started." ("\\.jq$" . "jq") ("\\.lua$" . "lua") ("\\.mdx\\'" . "mdx") + ("\\.nu$" . "nushell") ("\\.php$" . "php") ("\\.rs\\'" . "rust") ("\\.sql$" . "sql") @@ -946,7 +947,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 diff --git a/mkdocs.yml b/mkdocs.yml index f49ef4776d..b47f1fba4b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -111,6 +111,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