This project is a WIP WGSL language server that hooks directly into naga and supports naga_oil extensions such as preprocessor directives and imports.
wgsl-lsp
is based on the async_lsp
framework. This was chosen instead of the more popular tower-lsp
because I found that crate to be significantly unwieldy and it suffers from handler execution order issues due to everything being forced async fn
, which mandates async synchronization structures over all server state. Other projects chose rust-analyzer
's lsp-server
for similar reasons, but I found that crate to be far too low-level compared with async_lsp
which solves the same issue.
- [issue] - Naga can only return a single validation error at a time, which severely limits the information we can present via diagnostics.
- [no issue yet] - Naga modules can only be built from already-valid source, meaning all other language features (go to definition, hover, function signature help, semantic highlighting, etc) cease functioning if there's a single error.
- [no issue yet] - Naga
Module
s contain lots of spans and semantic information, but it's incomplete in many ways for semantic highlighting.Function
s have spans corresponding to their entire definition, but the spans for the name, arguments, argument types, and return type must all be parsed out manually. Similarly,Expression
s contain a lot of useful info, but they stop short of being very useful for semantic highlighting due to lack of sub-spans or any kind of AST. One example is when anExpression::Math
refers to a function parameter, that reference tells you nothing about where the function parameter appears in the expression source code. - [issue] - Naga-Oil doesn't make it easy to determine error source locations when constructing modules.
- [no issue yet] - Naga-Oil can only report a single error for an entire dependency tree. If there's an error in any ancestor, the current file you're looking at can't be validated.
cargo install --path ./
in this directory to installwgsl-lsp
as a binary- Clone a language client extension that can point to
wgsl-lsp
- there's a minimal one here: https://github.com/Runi-c/wgsl-lsp-client - Open that folder in vscode and hit F5 to launch the extension in an extension host window
- Open a workspace containing one or more WGSL files in the extension host window and the extension should activate automatically and start providing diagnostics