lsp-meson.el (4591B)
1 ;;; lsp-meson.el --- lsp client for meson -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2024 emacs-lsp maintainers 4 5 ;; Author: emacs-lsp maintainers 6 ;; Keywords: lsp, meson 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 Meson language. 24 ;; 25 ;;; Code: 26 27 (require 'lsp-mode) 28 29 (defgroup lsp-meson nil 30 "LSP support for Meson." 31 :group 'lsp-mode 32 :link '(url-link "https://github.com/JCWasmx86/mesonlsp")) 33 34 (defcustom lsp-meson-server-executable '("mesonlsp") 35 "The meson language server executable to use." 36 :group 'lsp-meson 37 :risky t 38 :type '(repeat string)) 39 40 (defcustom lsp-meson-ignore-subproject-diagnostics nil 41 "Ignore diagnostics from subprojects." 42 :type '(choice 43 (const :tag "Off" nil) 44 (const :tag "All subprojects" t) 45 (lsp-repeatable-vector :tag "Specific subprojects" string)) 46 :group 'lsp-meson) 47 48 (defcustom lsp-meson-no-auto-downloads nil 49 "Never automatically download subprojects/wraps." 50 :type '(boolean) 51 :group 'lsp-meson) 52 53 (defcustom lsp-meson-disable-inlay-hints nil 54 "Disable inlay hints." 55 :type '(boolean) 56 :group 'lsp-meson) 57 58 (defgroup lsp-meson-linting nil 59 "Linting settings for mesonlsp." 60 :group 'lsp-meson) 61 62 (defcustom lsp-meson-disable-name-linting nil 63 "Disable checking whether variable names are snake_case." 64 :type '(boolean) 65 :group 'lsp-meson-linting) 66 67 (defcustom lsp-meson-disable-all-id-lints nil 68 "Disable linting for unknown string literals relating to compiler/machine IDs." 69 :type '(boolean) 70 :group 'lsp-meson-linting) 71 72 (defcustom lsp-meson-disable-compiler-id-linting nil 73 "Disable lints for unknown IDs compared against `compiler.get_id()'." 74 :type '(boolean) 75 :group 'lsp-meson-linting) 76 77 (defcustom lsp-meson-disable-compiler-argument-id-linting nil 78 "Disable lints for unknown IDs compared against `compiler.get_argument_syntax()'." 79 :type '(boolean) 80 :group 'lsp-meson-linting) 81 82 (defcustom lsp-meson-disable-linker-id-linting nil 83 "Disable lints for unknown IDs compared against `compiler.get_linker_id()'." 84 :type '(boolean) 85 :group 'lsp-meson-linting) 86 87 (defcustom lsp-meson-disable-cpu-family-linting nil 88 "Disable lints for unknown IDs compared against `X_machine.cpu_family()'." 89 :type '(boolean) 90 :group 'lsp-meson-linting) 91 92 (defcustom lsp-meson-disable-os-family-linting nil 93 "Disable lints for unknown IDs compared against `X_machine.system()'." 94 :type '(boolean) 95 :group 'lsp-meson-linting) 96 97 (defun lsp-meson--make-init-options () 98 "Init options for mesonlsp." 99 `(:others (:ignoreDiagnosticsFromSubprojects 100 ,(if (vectorp lsp-meson-ignore-subproject-diagnostics) 101 lsp-meson-ignore-subproject-diagnostics 102 (lsp-json-bool lsp-meson-ignore-subproject-diagnostics)) 103 :neverDownloadAutomatically ,(lsp-json-bool lsp-meson-no-auto-downloads) 104 :disableInlayHints ,(lsp-json-bool lsp-meson-disable-inlay-hints)) 105 :linting (:disableNameLinting ,(lsp-json-bool lsp-meson-disable-name-linting) 106 :disableAllIdLinting ,(lsp-json-bool lsp-meson-disable-all-id-lints) 107 :disableCompilerIdLinting ,(lsp-json-bool lsp-meson-disable-compiler-id-linting) 108 :disableCompilerArgumentIdLinting ,(lsp-json-bool lsp-meson-disable-compiler-argument-id-linting) 109 :disableLinkerIdLinting ,(lsp-json-bool lsp-meson-disable-linker-id-linting) 110 :disableCpuFamilyLinting ,(lsp-json-bool lsp-meson-disable-cpu-family-linting) 111 :disableOsFamilyLinting ,(lsp-json-bool lsp-meson-disable-os-family-linting)))) 112 113 (lsp-register-client 114 (make-lsp-client 115 :new-connection (lsp-stdio-connection (lambda () (append lsp-meson-server-executable '("--lsp")))) 116 :activation-fn (lsp-activate-on "meson") 117 :multi-root nil 118 :priority -1 119 :major-modes '(meson-mode) 120 :initialization-options #'lsp-meson--make-init-options 121 :server-id 'mesonlsp)) 122 123 (lsp-consistency-check lsp-meson) 124 125 (provide 'lsp-meson) 126 ;;; lsp-meson.el ends here