-
-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 8c57bcf Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Tue Nov 7 11:52:54 2023 +0100 Add missing mkdocs entry commit 253ef1f Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Tue Nov 7 11:51:01 2023 +0100 Add lsp-clients docs entry commit 8a0b65d Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Fri Nov 3 18:46:22 2023 +0100 Add changelog entry for wgsl-analyzer commit 7627a27 Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Fri Nov 3 18:44:49 2023 +0100 Commented out non-working config paameter commit f9b27f5 Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Fri Nov 3 18:05:31 2023 +0100 Added the rest of the configuration properties commit 70cb86e Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Fri Nov 3 17:46:57 2023 +0100 Sending configuration now finally works commit 52811aa Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Wed Oct 18 14:21:52 2023 +0200 Add function to execute the lsp extension full source commit 71bbf89 Author: Marie Katrine Ekeberg <mke@themkat.net> Date: Mon Oct 16 16:48:44 2023 +0200 Add barebones wgsl-analyzer support
- Loading branch information
Showing
5 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
;;; lsp-wgsl.el --- description -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2023 emacs-lsp maintainers | ||
|
||
;; Author: emacs-lsp maintainers | ||
;; Keywords: lsp, wgsl, shaders, graphics programming, | ||
|
||
;; 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 Clients for WGSL (WebGPU Shading Language). | ||
|
||
;;; Code: | ||
|
||
(defgroup lsp-wgsl nil | ||
"LSP support for wgsl, using wgsl-analyzer." | ||
:group 'lsp-mode | ||
:link '(url-link "https://github.com/wgsl-analyzer/wgsl-analyzer") | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
|
||
(defcustom lsp-wgsl-server-command "wgsl_analyzer" | ||
"Command to run the wgsl-analyzer executable." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
;; Various toggling settings for the lsp server | ||
(defcustom lsp-wgsl-diagnostics-type-errors t | ||
"Whether to show type errors in diagnostics or not." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-diagnostics-naga-parsing-errors t | ||
"Whether to show naga parsing errors in diagnostics or not." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-diagnostics-naga-validation-errors t | ||
"Whether to show naga validation errors in diagnostics or not." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-diagnostics-naga-version "main" | ||
"Naga version to use." | ||
:type 'string | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-inlayhints-enabled t | ||
"Whether to enable inlay hints or not." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-inlayhints-typehints t | ||
"Whether to enable type hints or not when using inlay hints." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-inlayhints-parameterhints t | ||
"Whether to enable parameter hints or not when using inlay hints." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-inlayhints-structlayout t | ||
"Whether to enable struct layout hints or not when using inlay hints." | ||
:type 'boolean | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
;; TODO: maybe type choice instead? | ||
(defcustom lsp-wgsl-inlayhints-type-verbosity "compact" | ||
"The type verbosity to use for inlay hints." | ||
:type '(choice (string "full") | ||
(string "compact") | ||
(string "inner")) | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
(defcustom lsp-wgsl-custom-imports (lsp-ht) | ||
"List of custom imports in the style of Bevy" | ||
:type 'ht | ||
:group 'lsp-wgsl | ||
:package-version '(lsp-mode . "8.0.1")) | ||
|
||
;; (defcustom lsp-wgsl-shaderdefs [] | ||
;; "Defines that should be valid for preprocessor operations like ifdef." | ||
;; :type 'vector | ||
;; :group 'lsp-wgsl | ||
;; :package-version '(lsp-mode . "8.0.1")) | ||
|
||
;; wgsl-analyzer is a bit weird with how it gets config. | ||
;; Currently it relies on a custom extension to query the clients. | ||
;; (could not get standard custom-settings blocks to work) | ||
(defun lsp-wgsl--send-configuration (&rest _) | ||
;; TODO: why doesnt this behave like the normal lists?!?!? I cant just send a list?!?!?! why the fuck?!?! | ||
(list :customImports lsp-wgsl-custom-imports | ||
:diagnostics (list :typeErrors (lsp-json-bool lsp-wgsl-diagnostics-type-errors) | ||
:nagaParsingErrors (lsp-json-bool lsp-wgsl-diagnostics-naga-parsing-errors) | ||
:nagaValidationErrors (lsp-json-bool lsp-wgsl-diagnostics-naga-validation-errors) | ||
:nagaVersion lsp-wgsl-diagnostics-naga-version) | ||
:inlayHints (list :enabled (lsp-json-bool lsp-wgsl-inlayhints-enabled) | ||
:typeHints (lsp-json-bool lsp-wgsl-inlayhints-typehints) | ||
:parameterHints (lsp-json-bool lsp-wgsl-inlayhints-parameterhints) | ||
:structLayoutHints (lsp-json-bool lsp-wgsl-inlayhints-structlayout) | ||
:typeVerbosity lsp-wgsl-inlayhints-type-verbosity) | ||
:shaderDefs [] | ||
;; not configurable at the moment, as they don't seem to have much effect. | ||
;; Fails if not given. | ||
:trace (list :extension t | ||
:server t))) | ||
|
||
|
||
;; Various interactive functions to use the custom LSP extensions from the server | ||
(defun lsp-wgsl-full-source () | ||
"Gets the full source of the file with all imports and preprocessor definitions resolved." | ||
(interactive) | ||
(lsp-request-async | ||
"wgsl-analyzer/fullSource" | ||
(list :textDocument (list :uri (lsp--buffer-uri))) | ||
(lambda (source) | ||
(let ((buffer (get-buffer-create "*WGSL-full-source*"))) | ||
(with-current-buffer buffer | ||
(setq-local buffer-read-only nil) | ||
(erase-buffer) | ||
(insert source) | ||
(read-only-mode) | ||
;; activate only syntax highlighting | ||
(font-lock-add-keywords nil wgsl-font-lock-keywords) | ||
(font-lock-mode)) | ||
(switch-to-buffer buffer))))) | ||
|
||
|
||
(lsp-register-client | ||
(make-lsp-client :new-connection (lsp-stdio-connection | ||
(lambda () | ||
lsp-wgsl-server-command)) | ||
:initialized-fn (lambda (workspace) | ||
(with-lsp-workspace workspace | ||
;; wgsl-analyzer handles configuration in a VERY non-standard way | ||
;; https://github.com/wgsl-analyzer/wgsl-analyzer/issues/77 | ||
(lsp--set-configuration '()))) | ||
:request-handlers (lsp-ht ("wgsl-analyzer/requestConfiguration" #'lsp-wgsl--send-configuration)) | ||
:activation-fn (lsp-activate-on "wgsl") | ||
:priority -1 | ||
:server-id 'wgsl-analyzer)) | ||
|
||
|
||
(lsp-consistency-check lsp-wgsl) | ||
|
||
(provide 'lsp-wgsl) | ||
;;; lsp-wgsl.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters