config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-nushell.el (2376B)


      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