Skip to content

Runi-c/wgsl-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WGSL-LSP

This project is a WIP WGSL language server that hooks directly into naga and supports naga_oil extensions such as preprocessor directives and imports.

Architecture

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.

Naga/Naga-Oil Pain Points (as of April 2024)

  • [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 Modules contain lots of spans and semantic information, but it's incomplete in many ways for semantic highlighting. Functions 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, Expressions 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 an Expression::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.

How to Run on VSCode

  1. cargo install --path ./ in this directory to install wgsl-lsp as a binary
  2. 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
  3. Open that folder in vscode and hit F5 to launch the extension in an extension host window
  4. Open a workspace containing one or more WGSL files in the extension host window and the extension should activate automatically and start providing diagnostics

About

WIP language server for WGSL that supports naga-oil extensions

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages