config

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

lsp-cmake.el (2089B)


      1 ;;; lsp-cmake.el --- description -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020-2023 emacs-lsp maintainers
      4 
      5 ;; Author: emacs-lsp maintainers
      6 ;; Keywords: lsp, cmake
      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 Clients for the CMake build tool.
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-cmake nil
     30   "LSP support for CMake, using cmake-language-server."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/regen100/cmake-language-server"))
     33 
     34 (defcustom lsp-cmake-server-command "cmake-language-server"
     35   "The binary (or full path to binary) which executes the server."
     36   :type 'string
     37   :group 'lsp-cmake
     38   :package-version '(lsp-mode . "9.0.0"))
     39 
     40 (defun lsp-cmake--download-server (_client callback error-callback update?)
     41   "Install/update CMake language server using `pip
     42 
     43 Will invoke CALLBACK or ERROR-CALLBACK based on result.
     44 Will update if UPDATE? is t."
     45   (lsp-async-start-process
     46    callback
     47    error-callback
     48    "pip" "install" "cmake-language-server" (when update? "-U")))
     49 
     50 (lsp-register-client
     51  (make-lsp-client :new-connection (lsp-stdio-connection
     52                                    (lambda ()
     53                                      lsp-cmake-server-command))
     54                   :activation-fn (lsp-activate-on "cmake")
     55                   :priority -1
     56                   :server-id 'cmakels
     57                   :download-server-fn #'lsp-cmake--download-server))
     58 
     59 (lsp-consistency-check lsp-cmake)
     60 
     61 (provide 'lsp-cmake)
     62 ;;; lsp-cmake.el ends here