lsp-rpm-spec.el (2239B)
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" "-vvv") 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 (defun lsp-rpm-spec-server-start-fun (port) 52 "Command to start the language server in TCP mode, requires PORT." 53 (append lsp-rpm-spec-server-command (list "--port" (number-to-string port)))) 54 55 (lsp-register-client 56 (make-lsp-client :new-connection (lsp-tcp-connection 'lsp-rpm-spec-server-start-fun) 57 :activation-fn (lsp-activate-on "rpm-spec") 58 :server-id 'rpm-spec-language-server)) 59 60 (lsp-consistency-check lsp-rpm-spec) 61 62 (provide 'lsp-rpm-spec) 63 64 ;;; lsp-rpm-spec.el ends here