GitHub - wgsl-analyzer/wgsl-analyzer: A language server implementation for WGSL and WESL

wgsl-analyzer

wgsl-analyzer logo

Discord

wgsl-analyzer is a language server plugin for the WebGPU Shading language (WGSL). It also supports WGSL Extended Shader Language (WESL). Note: (support for WESL is experimental and in-progress)

You can use it with any editor that supports the Language Server Protocol (for example, VS Code, Vim, Emacs, Zed).

wgsl-analyzer's features include go-to-definition, type checking, code completion, and much more is planned. wgsl-analyzer also supports integrated diagnostics (with naga).

Internally, wgsl-analyzer is structured as a set of libraries for analyzing Rust code. See Architecture in the manual.

It comes with a VS Code extension located in ./editors/code. Due to the nature of the language server protocol, it should be possible to create plugins for other editors as well.

Quick Start

See the installation guide in the manual.

Building from source

The easiest way to build the language server and extension and install it all in one command:

The following instructions describe the manual steps:

The LSP server can be built using cargo build --release -p wgsl-analyzer.

The VS Code extension can either be built as a platform-specific extension which bundles the language server binary, or as a platform-independent one.

1. Install node modules:

npm --prefix editors/code install

2. Package extension: (choose one)

Platform independent extension:

npm --prefix editors/code run package

Platform-specific extension:

Copy the server binary (either wgsl-analyzer or wgsl-analyzer.exe) into ./editors/code/server/:

mkdir editors/code/server
cp target/release/wgsl-analyzer editors/code/server/wgsl-analyzer

Next, run:

npm --prefix editors/code run package -- --target <target> -o wgsl-analyzer-<target>.vsix

Example: npm --prefix editors/code run package -- --target linux-x64 -o wgsl-analyzer-linux-x64.vsix

where the target is one of the targets listed as platform-specific extension targets.

The output is a file such as editors/code/wgsl-analyzer-linux-x64.vsix

3. Install the extension:

Open the VSIX with VS Code, for example, by running the VS Code command (F1):

> Extensions: Install from VSIX...