config

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

lsp-nginx.el (2059B)


      1 ;;; lsp-nginx.el --- Nginx Client settings  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2021-2023  Shen, Jen-Chieh
      4 
      5 ;; Author: Jen-Chieh Shen <jcs090218@gmail.com>
      6 ;; Keywords: nginx lsp
      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 Nginx
     24 ;;
     25 
     26 ;;; Code:
     27 
     28 (require 'lsp-mode)
     29 
     30 (defgroup lsp-nginx nil
     31   "LSP support for Nginx."
     32   :group 'lsp-mode
     33   :link '(url-link "https://github.com/pappasam/nginx-language-server")
     34   :package-version `(lsp-mode . "9.0.0"))
     35 
     36 (defcustom lsp-nginx-server-command '("nginx-language-server")
     37   "Command to start Nginx Language Server."
     38   :risky t
     39   :group 'lsp-nginx
     40   :type '(repeat string)
     41   :package-version `(lsp-mode . "9.0.0"))
     42 
     43 (defun lsp-nginx--download-server (_client callback error-callback update?)
     44   "Install/update Nginx language server using `pip
     45 
     46 Will invoke CALLBACK or ERROR-CALLBACK based on result.
     47 Will update if UPDATE? is t."
     48   (lsp-async-start-process
     49    callback
     50    error-callback
     51    "pip" "install" "nginx-language-server" (when update? "-U")))
     52 
     53 (lsp-register-client
     54  (make-lsp-client :new-connection (lsp-stdio-connection
     55                                    (lambda () lsp-nginx-server-command))
     56                   :major-modes '(nginx-mode)
     57                   :priority -1
     58                   :server-id 'nginx-ls
     59                   :download-server-fn #'lsp-nginx--download-server))
     60 
     61 (lsp-consistency-check lsp-nginx)
     62 
     63 (provide 'lsp-nginx)
     64 ;;; lsp-nginx.el ends here