config

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

lsp-rpm-spec.el (2059B)


      1 ;;; lsp-rpm-spec.el --- lsp-mode integration for the rpm-spec-language-server -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2024 emacs-lsp maintainers
      4 
      5 ;; Author: emacs-lsp maintainers
      6 ;; Keywords: lsp, rpm-spec
      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 RPM Spec files
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-rpm-spec nil
     30   "LSP support for RPM spec files using rpm-spec-language-server."
     31   :group 'lsp-mode
     32   :tag "Language Server"
     33   :link '(url-link "https://github.com/dcermak/rpm-spec-language-server"))
     34 
     35 (defcustom lsp-rpm-spec-server-command '("python" "-m" "rpm_spec_language_server" "--stdio")
     36   "Command to start rpm-spec-language-server."
     37   :risky t
     38   :group 'lsp-rpm-spec
     39   :type '(repeat string))
     40 
     41 (defun lsp-rpm-spec--install-server (_client callback error-callback update?)
     42   "Install the rpm-spec-language-server via pip.
     43 
     44 Will invoke CALLBACK or ERROR-CALLBACK based on result.
     45 If UPDATE? is true, then pip will update the server."
     46   (lsp-async-start-process
     47    callback
     48    error-callback
     49    "pip" "install" "--user" "rpm-spec-language-server" (when update? "-U")))
     50 
     51 (lsp-register-client
     52  (make-lsp-client :new-connection (lsp-stdio-connection (lambda () lsp-rpm-spec-server-command))
     53                   :activation-fn (lsp-activate-on "rpm-spec")
     54                   :server-id 'rpm-spec-language-server))
     55 
     56 (lsp-consistency-check lsp-rpm-spec)
     57 
     58 (provide 'lsp-rpm-spec)
     59 
     60 ;;; lsp-rpm-spec.el ends here