Skip to content

Commit

Permalink
Add support for mesonlsp
Browse files Browse the repository at this point in the history
Signed-off-by: Julia DeMille <[email protected]>
  • Loading branch information
judemille authored and Your Name committed May 2, 2024
1 parent f4aad9d commit 040afd6
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
126 changes: 126 additions & 0 deletions clients/lsp-meson.el
Original file line number Diff line number Diff line change
@@ -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 string :tag "Specific subprojects"))
: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
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 040afd6

Please sign in to comment.