Giter VIP home page Giter VIP logo

tree-sitter-wgsl's Introduction

tree-sitter-wgsl

WebGPU Shading Language (WGSL) grammar for tree-sitter parser

About

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.

Showcase

Code highlighting

Code highlighting

Incremental selection

Incremental selection

Folding

Folding

Setup

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

  1. 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)
  2. 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
  3. Copy / Symlink / Whatever the files from queries folder to $LOCATION_OF_YOUR_CONFIG_FILE/queries/wgsl folder

  4. 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

tree-sitter-wgsl's People

Contributors

szebniok avatar 0xadk avatar bohjak avatar panekj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.