config

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

lsp-cucumber.el (2284B)


      1 ;;; lsp-cucumber.el --- LSP Clients for Cucumber  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2024  Shen, Jen-Chieh
      4 
      5 ;; This file is not part of GNU Emacs.
      6 
      7 ;; This program is free software: you can redistribute it and/or modify
      8 ;; it under the terms of the GNU General Public License as published by
      9 ;; the Free Software Foundation, either version 3 of the License, or
     10 ;; (at your option) any later version.
     11 
     12 ;; This program is distributed in the hope that it will be useful,
     13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;; GNU General Public License for more details.
     16 
     17 ;; You should have received a copy of the GNU General Public License
     18 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
     19 
     20 ;;; Commentary:
     21 ;;
     22 ;; LSP server implementation for Cucumber
     23 ;;
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-cucumber nil
     30   "LSP server implementation for Cucumber."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/cucumber/language-server"))
     33 
     34 (defcustom lsp-cucumber-server-path nil
     35   "Path points for Cucumber language server.
     36 
     37 This is only for development use."
     38   :type 'string
     39   :group 'lsp-cucumber)
     40 
     41 (defcustom lsp-cucumber-active-modes
     42   '( feature-mode)
     43   "List of major mode that work with Cucumber language server."
     44   :type 'list
     45   :group 'lsp-cucumber)
     46 
     47 (defun lsp-cucumber--server-command ()
     48   "Generate startup command for Cucumber language server."
     49   (or (and lsp-cucumber-server-path
     50            (list lsp-cucumber-server-path "--stdio"))
     51       (list (lsp-package-path 'cucumber-language-server) "--stdio")))
     52 
     53 (lsp-dependency 'cucumber-language-server
     54                 '(:system "cucumber-language-server")
     55                 '(:npm :package "@cucumber/language-server"
     56                        :path "cucumber-language-server"))
     57 
     58 (lsp-register-client
     59  (make-lsp-client
     60   :new-connection (lsp-stdio-connection #'lsp-cucumber--server-command)
     61   :major-modes lsp-cucumber-active-modes
     62   :priority -1
     63   :server-id 'cucumber-language-server
     64   :download-server-fn (lambda (_client callback error-callback _update?)
     65                         (lsp-package-ensure 'cucumber-language-server callback error-callback))))
     66 
     67 (provide 'lsp-cucumber)
     68 ;;; lsp-cucumber.el ends here