mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Introduce twig parser
This commit introduce parser, highlights and injections for the [twig syntax](https://twig.symfony.com)
This commit is contained in:
parent
7ce47ddf52
commit
d8a695a1ac
4 changed files with 74 additions and 1 deletions
|
|
@ -292,6 +292,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [tsx](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [turtle](https://github.com/BonaBeavis/tree-sitter-turtle) (maintained by @bonabeavis)
|
||||
- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka)
|
||||
- [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod)
|
||||
- [x] [v](https://github.com/vlang/vls) (maintained by @tami5)
|
||||
- [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781, @vala-lang)
|
||||
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv)
|
||||
|
|
|
|||
|
|
@ -1233,6 +1233,16 @@ list.blueprint = {
|
|||
experimental = true,
|
||||
}
|
||||
|
||||
list.twig = {
|
||||
install_info = {
|
||||
url = "https://github.com/gbprod/tree-sitter-twig",
|
||||
branch = "main",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
maintainers = { "@gbprod" },
|
||||
filetype = "twig",
|
||||
}
|
||||
|
||||
local M = {
|
||||
list = list,
|
||||
filetype_to_parsername = filetype_to_parsername,
|
||||
|
|
@ -1249,7 +1259,7 @@ function M.ft_to_lang(ft)
|
|||
end
|
||||
|
||||
function M.available_parsers()
|
||||
if vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1 then
|
||||
if vim.fn.executable("tree-sitter") == 1 and vim.fn.executable("node") == 1 then
|
||||
return vim.tbl_keys(M.list)
|
||||
else
|
||||
return vim.tbl_filter(function(p)
|
||||
|
|
|
|||
60
queries/twig/highlights.scm
Normal file
60
queries/twig/highlights.scm
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
(comment) @comment
|
||||
|
||||
(filter_identifier) @function.call
|
||||
(function_identifier) @function.call
|
||||
(test) @function.builtin
|
||||
(variable) @variable
|
||||
(string) @string
|
||||
(interpolated_string) @string
|
||||
(operator) @operator
|
||||
(number) @number
|
||||
(boolean) @boolean
|
||||
(null) @constant.builtin
|
||||
(keyword) @keyword
|
||||
(attribute) @attribute
|
||||
(tag) @tag
|
||||
(conditional) @conditional
|
||||
(repeat) @repeat
|
||||
(method) @method
|
||||
(parameter) @parameter
|
||||
|
||||
[
|
||||
"{{"
|
||||
"}}"
|
||||
"{{-"
|
||||
"-}}"
|
||||
"{{~"
|
||||
"~}}"
|
||||
"{%"
|
||||
"%}"
|
||||
"{%-"
|
||||
"-%}"
|
||||
"{%~"
|
||||
"~%}"
|
||||
] @tag.delimiter
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
"?"
|
||||
":"
|
||||
"="
|
||||
] @punctuation.delimiter
|
||||
|
||||
(interpolated_string [
|
||||
"#{"
|
||||
"}"
|
||||
] @punctuation.delimiter)
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
] @punctuation.bracket
|
||||
|
||||
(hash [
|
||||
"}"
|
||||
] @punctuation.bracket)
|
||||
|
||||
2
queries/twig/injections.scm
Normal file
2
queries/twig/injections.scm
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(content) @html
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue