tree-sitter-gh-actions-expressions

Crates.iotree-sitter-gh-actions-expressions
lib.rstree-sitter-gh-actions-expressions
version0.3.2
created_at2025-09-18 03:29:19.185829+00
updated_at2025-09-24 16:23:44.39718+00
descriptionGithub Actions expressions grammar for tree-sitter
homepage
repositoryhttps://github.com/hdoc1509/tree-sitter-gh-actions-expressions
max_upload_size
id1844210
size153,281
Héctor Ochoa (Hdoc1509)

documentation

README

tree-sitter-gh-actions-expressions

CI discord matrix crates npm pypi

Tree-sitter grammar for Github Actions expressions

Parser requirements

  • gitignore (optional): for hashFiles() function
  • json (optional): for fromJSON() function
  • yaml: injection to its block_mapping_pair node

Usage in Editors

Neovim

Requirements

Installation

  1. Add the following to your nvim-treesitter configuration:

    local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
    
    -- NOTE: add the parser to `parser_config` before calling `setup()`
    parser_config.gh_actions_expressions = {
      install_info = {
        url = 'https://github.com/Hdoc1509/tree-sitter-gh-actions-expressions',
        files = { "src/parser.c" },
        branch = 'release',
        -- if ABI version from neovim doesn't match the one from this grammar
        -- requires Node.js and tree-sitter cli to be installed
        requires_generate_from_grammar = true,
      },
    }
    
    require('nvim-treesitter.configs').setup({
      ensure_installed = {
        -- other parsers
        'gh_actions_expressions',
      },
      -- other options
    })
    
  2. Copy the queries from queries directory to queries/gh_actions_expression directory in your neovim configuration directory:

    With Path
    Unix ~/.config/nvim
    Windows ~/AppData/Local/nvim
    XDG_CONFIG_HOME set $XDG_CONFIG_HOME/nvim
  3. Add the following queries to after/queries/yaml/injections.scm in your neovim configuration directory:

    ; extends
    ; don't forget to include `extends` modeline!
    ((block_mapping_pair
      key: (flow_node) @_key
      value: [
        (block_node
          (block_scalar) @_value)
        (flow_node
          [
            (plain_scalar
              (string_scalar) @_value)
            (double_quote_scalar) @_value
          ])
      ]
      (#lua-match? @_value "${{")) @injection.content
      ; NOTE: to avoid weird behaviours with `bash` injections
      (#not-eq? @_key "run")
      (#set! injection.language "gh_actions_expressions")
      (#set! injection.include-children))
    
    ((block_mapping_pair
      key: (flow_node) @_key
      (#eq? @_key "if")
      value: (flow_node
        (plain_scalar
          (string_scalar) @_value)
        (#not-lua-match? @_value "${{"))) @injection.content
      (#set! injection.language "gh_actions_expressions")
      (#set! injection.include-children))
    

Helix

WIP

Emacs

WIP

In General

You can get the built files from the release branch. If you have specific instructions for your editor, PR's are welcome.

Implementations

WIP

References

Thanks

Thanks to @disrupted for creating tree-sitter-github-actions grammar, which is the base I used to create this grammar.

Commit count: 143

cargo fmt