WebGPU Shading Language (WGSL) grammar for tree-sitter parser
The goal of this project is to provide a grammar for WebGPU Shading Lanugage (WGSL) that would enable tree-sitter to efficiently bulid a syntax tree for a source file.
WGSL is a shading language created as a part of WebGPU — future web standard that aims to provide "modern 3D graphics and computation capabilities".
Please note that both the WebGPU and WGSL spec are still under development.



The instructions below are provided for Neovim 0.5 and nvim-treesitter, but it should be possible to get it running in any environment supporting tree-sitter parsers. I am making an assumption that you are using init.lua config file
Begin by installing nvim-treesitter using your favorite package manager. E.g., if you are using packer.nvim:
require('packer').startup(function()
-- ...some other packages...
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
end)
Add the following snippet to your config file:
vim.filetype.add({extension = {wgsl = "wgsl"}})
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.wgsl = {
install_info = {
url = "https://github.com/szebniok/tree-sitter-wgsl",
files = {"src/parser.c"}
},
}
require'nvim-treesitter.configs'.setup {
ensure_installed = {"wgsl"},
highlight = {
enable = true
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
}
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldlevelstart = 99 -- do not close folds when a buffer is opened
Copy / Symlink / Whatever the files from queries folder to $LOCATION_OF_YOUR_CONFIG_FILE/queries/wgsl folder
Start nvim — the installation of wgsl grammar should begin automatically
Restart nvim — all *.wgsl files should be handled properly now.
Distributed under the MIT License. See LICENSE for more information.
JavaScript
71.2%
Rust
15.1%
Scheme
8.0%
C++
4.1%
Python
1.6%
WebGPU Shading Language (WGSL) grammar for tree-sitter parser
The goal of this project is to provide a grammar for WebGPU Shading Lanugage (WGSL) that would enable tree-sitter to efficiently bulid a syntax tree for a source file.
WGSL is a shading language created as a part of WebGPU — future web standard that aims to provide "modern 3D graphics and computation capabilities".
Please note that both the WebGPU and WGSL spec are still under development.



The instructions below are provided for Neovim 0.5 and nvim-treesitter, but it should be possible to get it running in any environment supporting tree-sitter parsers. I am making an assumption that you are using init.lua config file
Begin by installing nvim-treesitter using your favorite package manager. E.g., if you are using packer.nvim:
require('packer').startup(function()
-- ...some other packages...
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
end)
Add the following snippet to your config file:
vim.filetype.add({extension = {wgsl = "wgsl"}})
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.wgsl = {
install_info = {
url = "https://github.com/szebniok/tree-sitter-wgsl",
files = {"src/parser.c"}
},
}
require'nvim-treesitter.configs'.setup {
ensure_installed = {"wgsl"},
highlight = {
enable = true
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
}
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
vim.o.foldlevelstart = 99 -- do not close folds when a buffer is opened
Copy / Symlink / Whatever the files from queries folder to $LOCATION_OF_YOUR_CONFIG_FILE/queries/wgsl folder
Start nvim — the installation of wgsl grammar should begin automatically
Restart nvim — all *.wgsl files should be handled properly now.
Distributed under the MIT License. See LICENSE for more information.
JavaScript
71.2%
Rust
15.1%
Scheme
8.0%
C++
4.1%
Python
1.6%