lsp-autotools.el (2504B)
1 ;;; lsp-autotools.el --- Support configure.ac, Makefile.am, Makefile -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2023 Jen-Chieh Shen 4 5 ;; Author: Jen-Chieh Shen <jcs090218@gmail.com> 6 ;; Keywords: autotools 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 ;; Support configure.ac, Makefile.am, Makefile 24 25 ;;; Code: 26 27 (require 'lsp-mode) 28 29 (defgroup lsp-autotools nil 30 "LSP support for Autotools." 31 :group 'lsp-mode 32 :link '(url-link "https://github.com/Freed-Wu/autotools-language-server") 33 :package-version `(lsp-mode . "9.0.0")) 34 35 (defcustom lsp-autotools-active-modes 36 '( autoconf-mode 37 makefile-mode 38 makefile-automake-mode 39 makefile-gmake-mode 40 makefile-makepp-mode 41 makefile-bsdmake-mode 42 makefile-imake-mode) 43 "List of major mode that work with Autotools." 44 :type 'list 45 :group 'lsp-autotools) 46 47 (defun lsp-autotools--download-server (_client callback error-callback update?) 48 "Install/update Autotools language server using `pip 49 50 Will invoke CALLBACK or ERROR-CALLBACK based on result. 51 Will update if UPDATE? is t." 52 (lsp-async-start-process 53 callback 54 error-callback 55 "pip" "install" "autotools-language-server" (when update? "-U"))) 56 57 (defun lsp-autotools--server-command () 58 "Startup command for Autotools language server." 59 (list "autotools-language-server")) 60 61 (defun lsp-autotools--test-present () 62 "Return non-nil if Autotools language server is installed globally." 63 (executable-find "autotools-language-server")) 64 65 (lsp-register-client 66 (make-lsp-client 67 :new-connection (lsp-stdio-connection 68 #'lsp-autotools--server-command 69 #'lsp-autotools--test-present) 70 :major-modes lsp-autotools-active-modes 71 :priority -1 72 :server-id 'autotools-ls 73 :download-server-fn #'lsp-autotools--download-server)) 74 75 (lsp-consistency-check lsp-autotools) 76 77 (provide 'lsp-autotools) 78 ;;; lsp-autotools.el ends here