config

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

lsp-marksman.el (3841B)


      1 ;;; lsp-marksman.el --- lsp-mode marksman integration -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2021 lsp-mode maintainers
      4 
      5 ;; Author: lsp-mode maintainers
      6 ;; Keywords: languages
      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 marksman
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 ;;; Marksman
     30 (defgroup lsp-marksman nil
     31   "Settings for the marksman language server client."
     32   :group 'lsp-mode
     33   :link '(url-link "https://github.com/artempyanykh/marksman")
     34   :package-version '(lsp-mode . "8.0.0"))
     35 
     36 (defcustom lsp-marksman-server-command "marksman"
     37   "The binary (or full path to binary) which executes the server."
     38   :type 'string
     39   :group 'lsp-marksman
     40   :package-version '(lsp-mode . "8.0.0"))
     41 
     42 (defcustom lsp-marksman-server-command-args '()
     43   "Command-line arguments for the marksman lsp server. Not normally Needed."
     44   :type '(repeat 'string)
     45   :group 'lsp-marksman
     46   :package-version '(lsp-mode . "8.0.0"))
     47 
     48 (defcustom lsp-marksman-download-url
     49   (format "https://github.com/artempyanykh/marksman/releases/latest/download/%s"
     50           (pcase system-type
     51             ('gnu/linux
     52              (if (string-match "^aarch64-.*" system-configuration)
     53                  "marksman-linux-arm64"
     54                "marksman-linux-x64"))
     55             ('darwin "marksman-macos")
     56             ('windows-nt "marksman.exe")))
     57   "Automatic download url for Marksman."
     58   :type 'string
     59   :group 'lsp-marksman
     60   :package-version '(lsp-mode . "8.0.0"))
     61 
     62 (defcustom lsp-marksman-store-path (f-join lsp-server-install-dir
     63                                                 "marksman"
     64                                                 (if (eq system-type 'windows-nt)
     65                                                     "marksman.exe"
     66                                                   "marksman"))
     67   "The path to the file in which `marksman' will be stored."
     68   :type 'file
     69   :group 'lsp-marksman
     70   :package-version '(lsp-mode . "8.0.0"))
     71 
     72 (lsp-dependency 'marksman
     73                 '(:system "marksman")
     74                 `(:download :url lsp-marksman-download-url
     75                             :store-path lsp-marksman-store-path
     76                             :set-executable? t))
     77 
     78 (lsp-register-client
     79  (make-lsp-client :new-connection (lsp-stdio-connection
     80                                    (lambda ()
     81                                      (cons (or (executable-find lsp-marksman-server-command)
     82                                                (lsp-package-path 'marksman)
     83                                                "marksman")
     84                                            lsp-marksman-server-command-args)))
     85                   :activation-fn (lsp-activate-on "markdown")
     86                   :initialized-fn (lambda (workspace)
     87                                     (with-lsp-workspace workspace
     88                                       (lsp--set-configuration (lsp-configuration-section "marksman"))))
     89                   :priority -1
     90                   :server-id 'marksman
     91                   :download-server-fn (lambda (_client callback error-callback _update?)
     92                                         (lsp-package-ensure 'marksman callback error-callback))))
     93 
     94 (lsp-consistency-check lsp-marksman)
     95 
     96 (provide 'lsp-marksman)
     97 ;;; lsp-marksman.el ends here