Add support for mesonlsp (#4442)

pull/4448/head
Julia DeMille 2024-05-02 13:52:42 -05:00 committed by GitHub
parent f4aad9dd53
commit db54f20da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 137 additions and 1 deletions

View File

@ -2,6 +2,7 @@
** Unreleased 9.0.1
* Add support for GNAT Project (~gpr-mode~, ~gpr-ts-mode~).
* Add SQL support
* Add support for Meson build system. (~meson-mode~).
** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
* Add new configuration options for lsp-html. Now able to toggle documentation hovers. Custom data is no longer experimental, and is now a vector.

126
clients/lsp-meson.el Normal file
View File

@ -0,0 +1,126 @@
;;; lsp-meson.el --- lsp client for meson -*- lexical-binding: t; -*-
;; Copyright (C) 2024 emacs-lsp maintainers
;; Author: emacs-lsp maintainers
;; Keywords: lsp, meson
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; LSP client for Meson language.
;;
;;; Code:
(require 'lsp-mode)
(defgroup lsp-meson nil
"LSP support for Meson."
:group 'lsp-mode
:link '(url-link "https://github.com/JCWasmx86/mesonlsp"))
(defcustom lsp-meson-server-executable '("mesonlsp")
"The meson language server executable to use."
:group 'lsp-meson
:risky t
:type '(repeat string))
(defcustom lsp-meson-ignore-subproject-diagnostics nil
"Ignore diagnostics from subprojects."
:type '(choice
(const :tag "Off" nil)
(const :tag "All subprojects" t)
(lsp-repeatable-vector :tag "Specific subprojects" string))
:group 'lsp-meson)
(defcustom lsp-meson-no-auto-downloads nil
"Never automatically download subprojects/wraps."
:type '(boolean)
:group 'lsp-meson)
(defcustom lsp-meson-disable-inlay-hints nil
"Disable inlay hints."
:type '(boolean)
:group 'lsp-meson)
(defgroup lsp-meson-linting nil
"Linting settings for mesonlsp."
:group 'lsp-meson)
(defcustom lsp-meson-disable-name-linting nil
"Disable checking whether variable names are snake_case."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-all-id-lints nil
"Disable linting for unknown string literals relating to compiler/machine IDs."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-compiler-id-linting nil
"Disable lints for unknown IDs compared against `compiler.get_id()'."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-compiler-argument-id-linting nil
"Disable lints for unknown IDs compared against `compiler.get_argument_syntax()'."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-linker-id-linting nil
"Disable lints for unknown IDs compared against `compiler.get_linker_id()'."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-cpu-family-linting nil
"Disable lints for unknown IDs compared against `X_machine.cpu_family()'."
:type '(boolean)
:group 'lsp-meson-linting)
(defcustom lsp-meson-disable-os-family-linting nil
"Disable lints for unknown IDs compared against `X_machine.system()'."
:type '(boolean)
:group 'lsp-meson-linting)
(defun lsp-meson--make-init-options ()
"Init options for mesonlsp."
`(:others (:ignoreDiagnosticsFromSubprojects
,(if (vectorp lsp-meson-ignore-subproject-diagnostics)
lsp-meson-ignore-subproject-diagnostics
(lsp-json-bool lsp-meson-ignore-subproject-diagnostics))
:neverDownloadAutomatically ,(lsp-json-bool lsp-meson-no-auto-downloads)
:disableInlayHints ,(lsp-json-bool lsp-meson-disable-inlay-hints))
:linting (:disableNameLinting ,(lsp-json-bool lsp-meson-disable-name-linting)
:disableAllIdLinting ,(lsp-json-bool lsp-meson-disable-all-id-lints)
:disableCompilerIdLinting ,(lsp-json-bool lsp-meson-disable-compiler-id-linting)
:disableCompilerArgumentIdLinting ,(lsp-json-bool lsp-meson-disable-compiler-argument-id-linting)
:disableLinkerIdLinting ,(lsp-json-bool lsp-meson-disable-linker-id-linting)
:disableCpuFamilyLinting ,(lsp-json-bool lsp-meson-disable-cpu-family-linting)
:disableOsFamilyLinting ,(lsp-json-bool lsp-meson-disable-os-family-linting))))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection (lambda () (append lsp-meson-server-executable '("--lsp"))))
:activation-fn (lsp-activate-on "meson")
:multi-root nil
:priority -1
:major-modes '(meson-mode)
:initialization-options #'lsp-meson--make-init-options
:server-id 'mesonlsp))
(lsp-consistency-check lsp-meson)
(provide 'lsp-meson)
;;; lsp-meson.el ends here

View File

@ -591,6 +591,14 @@
"installation-url": "https://github.com/artempyanykh/marksman",
"debugger": "Not available"
},
{
"name": "meson",
"full-name": "Meson",
"server-name": "mesonlsp",
"server-url": "https://github.com/JCWasmx86/mesonlsp",
"installation-url": "https://github.com/JCWasmx86/mesonlsp",
"debugger": "Not available"
},
{
"name": "millet",
"full-name": "Standard ML (Millet)",

View File

@ -181,7 +181,7 @@ As defined by the Language Server Protocol 3.16."
lsp-gdscript lsp-gleam lsp-glsl lsp-go lsp-golangci-lint lsp-grammarly
lsp-graphql lsp-groovy lsp-hack lsp-haskell lsp-haxe lsp-idris lsp-java
lsp-javascript lsp-jq lsp-json lsp-kotlin lsp-latex lsp-lisp lsp-ltex
lsp-lua lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-metals lsp-mint
lsp-lua lsp-magik lsp-markdown lsp-marksman lsp-mdx lsp-meson lsp-metals lsp-mint
lsp-mojo lsp-move lsp-mssql lsp-nginx lsp-nim lsp-nix lsp-nushell lsp-ocaml
lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms

View File

@ -108,6 +108,7 @@ nav:
- Magik: page/lsp-magik.md
- Markdown: page/lsp-markdown.md
- Marksman: page/lsp-marksman.md
- Meson: page/lsp-meson.md
- Move: page/lsp-move.md
- MDX: page/lsp-mdx.md
- MSSQL: https://emacs-lsp.github.io/lsp-mssql