Twig grammar for tree-sitter.
Grammar is available with nvim-treesitter
.
:TSInstall twig
Twig grammar for Tree-sitter
Home Page: https://gb-prod.fr/tree-sitter-twig/
License: Do What The F*ck You Want To Public License
Twig grammar for tree-sitter.
Grammar is available with nvim-treesitter
.
:TSInstall twig
Highlighting for the rest of the file is removed/buggy when wrapping empty strings in double quotes. It does not get removed if using single quotes or if the string is not empty.
Empty string with single quotes:
Empty string with double quotes:
:checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
- WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK: `node` found v18.10.0 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- turtle ✓ ✓ ✓ ✓ ✓
- svelte ✓ . ✓ ✓ ✓
- beancount ✓ . ✓ . .
- gleam ✓ ✓ ✓ ✓ ✓
- rnoweb ✓ . ✓ . ✓
- eex ✓ . . . ✓
- heex ✓ ✓ ✓ ✓ ✓
- bibtex ✓ . ✓ ✓ .
- python ✓ ✓ ✓ ✓ ✓
- ocaml_interface✓ ✓ ✓ . ✓
- fortran ✓ . ✓ ✓ .
- regex ✓ . . . .
- menhir ✓ . . . ✓
- help ✓ . . . .
- org . . . . .
- json5 ✓ . . . ✓
- pioasm ✓ . . . ✓
- hjson ✓ ✓ ✓ ✓ ✓
- todotxt ✓ . . . .
- hocon ✓ . . . ✓
- typescript ✓ ✓ ✓ ✓ ✓
- llvm ✓ . . . .
- meson ✓ . ✓ . ✓
- qmljs ✓ . ✓ . .
- supercollider ✓ ✓ ✓ ✓ ✓
- prisma ✓ . . . .
- diff ✓ . . . .
- slint ✓ . . ✓ .
- rasi ✓ ✓ ✓ ✓ .
- haskell ✓ . ✓ . ✓
- hack ✓ . . . .
- norg . . . . .
- embedded_template✓ . . . ✓
- markdown_inline✓ . . . ✓
- javascript ✓ ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ . ✓
- tlaplus ✓ ✓ ✓ . ✓
- vala ✓ . ✓ . .
- bash ✓ ✓ ✓ . ✓
- vim ✓ ✓ ✓ . ✓
- html ✓ ✓ ✓ ✓ ✓
- lalrpop ✓ ✓ . . .
- tsx ✓ ✓ ✓ ✓ ✓
- cuda ✓ ✓ ✓ ✓ ✓
- solidity ✓ . . . .
- glimmer ✓ . . . .
- pug ✓ . . . ✓
- cooklang ✓ . . . .
- latex ✓ . ✓ . ✓
- v ✓ ✓ ✓ ✓ ✓
- dockerfile ✓ . . . ✓
- foam ✓ ✓ ✓ ✓ ✓
- astro ✓ ✓ ✓ ✓ ✓
- markdown ✓ . ✓ . ✓
- elm ✓ . . . ✓
- wgsl ✓ . ✓ ✓ .
- c_sharp ✓ ✓ ✓ . ✓
- yang ✓ . ✓ ✓ .
- ledger ✓ . ✓ ✓ ✓
- agda ✓ . ✓ . .
- dart ✓ ✓ . ✓ ✓
- tiger ✓ ✓ ✓ ✓ ✓
- http ✓ . . . ✓
- sxhkdrc ✓ . ✓ . ✓
- fennel ✓ ✓ . . ✓
- graphql ✓ . . ✓ ✓
- nickel ✓ . . . .
- ql ✓ ✓ . ✓ ✓
- ruby ✓ ✓ ✓ ✓ ✓
- perl ✓ . ✓ . .
- pascal ✓ ✓ ✓ ✓ ✓
- zig ✓ . ✓ ✓ ✓
- twig ✓ . . . ✓
- phpdoc ✓ . . . .
- fish ✓ ✓ ✓ ✓ ✓
- php ✓ ✓ ✓ ✓ ✓
- jsdoc ✓ . . . .
- java ✓ ✓ . ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- c ✓ ✓ ✓ ✓ ✓
- kotlin ✓ ✓ ✓ . ✓
- sparql ✓ ✓ ✓ ✓ ✓
- julia ✓ ✓ ✓ ✓ ✓
- jsonnet ✓ . . . .
- css ✓ . ✓ ✓ ✓
- scss ✓ . . ✓ .
- erlang ✓ . ✓ . .
- elixir ✓ ✓ ✓ ✓ ✓
- proto ✓ . ✓ . .
- blueprint ✓ . . . .
- gitattributes ✓ . . . ✓
- cpp ✓ ✓ ✓ ✓ ✓
- surface ✓ . ✓ ✓ ✓
- cmake ✓ . ✓ . .
- json ✓ ✓ ✓ ✓ .
- racket ✓ . ✓ . ✓
- dot ✓ . . . ✓
- vue ✓ . ✓ ✓ ✓
- gowork ✓ . . . ✓
- gomod ✓ . . . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- nix ✓ ✓ ✓ . ✓
- ninja ✓ . ✓ ✓ .
- rst ✓ ✓ . . ✓
- commonlisp ✓ ✓ ✓ . .
- scheme ✓ . ✓ . ✓
- fusion ✓ ✓ ✓ ✓ .
- verilog ✓ ✓ ✓ . ✓
- rust ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- jsonc ✓ ✓ ✓ ✓ ✓
- elvish ✓ . . . ✓
- hlsl ✓ ✓ ✓ ✓ ✓
- comment ✓ . . . .
- glsl ✓ ✓ ✓ ✓ ✓
- ocaml ✓ ✓ ✓ . ✓
- hcl ✓ . ✓ ✓ ✓
- go ✓ ✓ ✓ ✓ ✓
- toml ✓ ✓ ✓ ✓ ✓
- r ✓ ✓ . ✓ ✓
- rego ✓ . . . ✓
- sql ✓ . . . ✓
- make ✓ . ✓ . ✓
- scala ✓ . ✓ . ✓
- gdscript ✓ ✓ . ✓ ✓
- m68k ✓ ✓ ✓ . ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
nvim --version
NVIM v0.8.0-1210-gd367ed9b2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az505-656
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info
When integrating twig functions the highlighting breaks.
local ok, configs = pcall(require, "nvim-treesitter.configs")
if ok then
configs.setup({
additional_vim_regex_highlighting = false,
auto_install = true,
enable = true,
ensure_installed = {
"hcl",
"astro",
"bash",
"css",
"dockerfile",
"graphql",
"go",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"markdown",
"php",
"python",
"rust",
"scss",
"sql",
"svelte",
"toml",
"tsx",
"yaml",
"typescript",
"twig"
},
ignore_install = { "phpdoc" },
highlight = { enable = true },
indent = { enable = true },
autotag = { enable = true },
})
end
Installation is flawless and I can get autocompletion for twig macros and stuff. Im using the this boilerplate to test: https://github.com/craftcms/craft (templates/index.twig)
I dont fully understand how queries and stuff works so i'm not able to debug and open a MR. Do you have any idea?
The presence of symlinks prevents this parser from being installed on Windows (were symlinks are not supported outside admin/dev mode).
I don't think the node-module directory is even required; you can just use
- uses: tree-sitter/setup-action/cli@v1
in CI? See https://github.com/tree-sitter-grammars/template for using upstream workflows for parser CI.
You might also wish to regenerate the bindings with the latest tree-sitter CLI (0.22.6); upstream has switched from nan
to napi
.
Hi, thanks for your work in this repo.
Twig supports several variables in one assignment statement
But the parser catches errors.
Missing :
String Interpolation
> Ping @gbprod, maybe you could bring some context to this issue. Did you look into indenting already? Did you have some issues? Thanks!
Hi!
I've never tried to make indentation works for twig (mostly because I don't know how to make it works with combined injection).
But it would be awesome to improve this :)
I will make some tests ;)
Originally posted by @gbprod in nvim-treesitter/nvim-treesitter#6124 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.