| Crates.io | shader_language_server |
| lib.rs | shader_language_server |
| version | 1.2.2 |
| created_at | 2024-10-02 17:01:46.258515+00 |
| updated_at | 2025-11-24 22:27:08.710027+00 |
| description | Language server for HLSL / GLSL / WGSL shaders using LSP protocol. |
| homepage | |
| repository | https://github.com/antaalt/shader-sense/tree/main/shader-language-server |
| max_upload_size | |
| id | 1394378 |
| size | 329,636 |
This application is a language server for shaders (HLSL, GLSL, WGSL) that is mainly meant to be used as a server for vscode extension shader-validator. It is following the LSP protocol to communicate with the extension so it could be used with any editor supporting it. It can be built to desktop or WASI. WASI will let the server run even in the browser, but it suffer from limitations. See below for more informations.
It can be launched using the following options:
--config Pass a custom config as a JSON string for server.
--config-file Pass a custom config as a file for server.
--cwd Set current working directory of server. If not set, will be the server executable path.
--version | -v Print server version.
--help | -h Print this helper.
--hlsl Add support for hlsl language id.
--glsl Add support for glsl language id.
--wgsl Add support for wgsl language id.
--stdio Use the stdio transport. Default transport.
--tcp Use tcp transport. Not implemented yet.
--memory Use memory transport. Not implemented yet.
This language server support a few options :
The server support HLSL, GLSL, WGSL diagnostics, but symbol requests are not implemented for WGSL yet.
The server follows the lsp protocol, but it also offer some custom commands specific to this server. Handling them is not mandatory but can improve the experience using the extension.
This server offer a variant concept to handle shader database which can have a lot of entry points, even in a single shader file. In order to offer a better experience with all providers and active regions, you can specify the current variant, aka current entry point, along with some macro and includes for the permutation. Your client can have an interface letting user create variants and select the active one, which will be sent to server through the notification "textDocument/didChangeShaderVariant".
interface DidChangeShaderVariantParams {
shaderVariant: ShaderVariant | null
}
interface ShaderVariant {
url: string, // file of variant
shadingLanguage: string, // language id of variant
entryPoint: string, // The name of the entry point function.
stage: string | null, // Correspond to the value of the enum ShaderStage in shader-sense, case sensitive.
defines: Object, // defines and its values
includes: string[], // include folders for this variant
}
The server offer some specific debug request to help inspect the current state of the server.
interface DumpAstParams {
uri: string,
}
Result will be either a string or null
interface DumpDependencyParams {
uri: string,
}
Result will be either a string or null
Diagnostics are generated following language specifics API:
Symbols are retrieved using queries based on tree-sitter API.
This server can be run in the browser when compiled to WASI. Because of this restriction, we can't use dxc here as it does not compile to WASI and instead rely on glslang, which is more limited in linting (Only support some basic features of SM 6.0, while DXC support all newly added SM (current 6.8)).