Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szebniok/tree-sitter-wgsl
WebGPU Shading Language grammar for tree-sitter parser
https://github.com/szebniok/tree-sitter-wgsl
parser tree-sitter webgpu wgsl
Last synced: 18 days ago
JSON representation
WebGPU Shading Language grammar for tree-sitter parser
- Host: GitHub
- URL: https://github.com/szebniok/tree-sitter-wgsl
- Owner: szebniok
- License: mit
- Created: 2021-07-29T22:30:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-10T20:56:27.000Z (9 months ago)
- Last Synced: 2024-07-30T20:56:07.464Z (3 months ago)
- Topics: parser, tree-sitter, webgpu, wgsl
- Language: JavaScript
- Homepage:
- Size: 4.66 MB
- Stars: 47
- Watchers: 4
- Forks: 11
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## About
The goal of this project is to provide a grammar for [WebGPU Shading Lanugage (WGSL)](https://www.w3.org/TR/WGSL/) that would enable [tree-sitter](https://tree-sitter.github.io/tree-sitter/) to efficiently bulid a syntax tree for a source file.
WGSL is a shading language created as a part of [WebGPU](https://www.w3.org/community/gpu/) — 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.
## Showcase
### Code highlighting
![Code highlighting](./assets/code-highlighting.png)
### Incremental selection
![Incremental selection](./assets/incremental-selection.gif)
### Folding
![Folding](./assets/folding.gif)## Setup
*The instructions below are provided for [Neovim](https://neovim.io/) 0.5 and [nvim-treesitter](https://github.com/nvim-treesitter/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*
1. Begin by installing `nvim-treesitter` using your favorite package manager. E.g., if you are using [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
require('packer').startup(function()
-- ...some other packages...
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
end)
```2. Add the following snippet to your config file:
```lua
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
```
3. Copy / Symlink / Whatever the files from [queries folder](https://github.com/szebniok/tree-sitter-wgsl/tree/master/queries) to `$LOCATION_OF_YOUR_CONFIG_FILE/queries/wgsl` folder4. Start `nvim` — the installation of wgsl grammar should begin automatically
5. Restart `nvim` — all `*.wgsl` files should be handled properly now.## License
Distributed under the MIT License. See `LICENSE` for more information.
## References
* [WebGPU Shading Language Working Draft](https://www.w3.org/TR/WGSL/)