Skip to content

blinklang/tree-sitter-blink

Repository files navigation

tree-sitter-blink

Tree-sitter grammar for the Blink programming language.

Provides syntax highlighting and structural parsing for .bl files in editors and tools that support tree-sitter.


Editor Setup

Neovim (nvim-treesitter)

Add to your nvim-treesitter config:

require("nvim-treesitter.parsers").get_parser_configs().blink = {
  install_info = {
    url = "https://github.com/blinklang/tree-sitter-blink",
    files = { "src/parser.c" },
    branch = "main",
  },
  filetype = "bl",
}

Then install:

:TSInstall blink

Helix

Add to ~/.config/helix/languages.toml:

[[language]]
name = "blink"
scope = "source.blink"
file-types = ["bl"]
roots = []
comment-token = "//"

[language.grammar]
source = { git = "https://github.com/blinklang/tree-sitter-blink", rev = "main" }

Then fetch and build:

hx --grammar fetch && hx --grammar build

ast-grep Setup

ast-grep enables syntax-aware search and rewrite on Blink source files.

Run this one-liner to download, compile, and configure:

curl -sSL https://raw.githubusercontent.com/blinklang/tree-sitter-blink/main/install-ast-grep.sh | bash

This compiles the grammar and installs it to ~/.config/ast-grep/. The script will print an alias to add to your shell profile:

ast-grep() { command ast-grep --config ~/.config/ast-grep/sgconfig.yml "$@"; }

Then:

# Find all calls to foo with one argument
ast-grep run -p 'foo($X)' -l blink src/

# Rename foo to bar across all .bl files
ast-grep run -p 'foo($X)' -r 'bar($X)' -l blink src/

Requirements: a C compiler (gcc or clang) and curl.


Contributing

See CONTRIBUTING.md for how to work on the grammar.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors