aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgbprod <contact@gb-prod.fr>2022-09-19 17:18:19 +0200
committerChristian Clason <christian.clason@uni-due.de>2022-10-03 10:06:41 +0200
commitd8a695a1ac493096e6f7a0916a962b979d290039 (patch)
tree43210c6ac939a38f6e5399cdaf14e285cca099df
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar.gz
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar.bz2
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar.lz
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar.xz
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.tar.zst
nvim-treesitter-d8a695a1ac493096e6f7a0916a962b979d290039.zip
Introduce twig parser
This commit introduce parser, highlights and injections for the [twig syntax](https://twig.symfony.com)
-rw-r--r--README.md1
-rw-r--r--lua/nvim-treesitter/parsers.lua12
-rw-r--r--queries/twig/highlights.scm60
-rw-r--r--queries/twig/injections.scm2
4 files changed, 74 insertions, 1 deletions
diff --git a/README.md b/README.md
index 9a1ca98a4..b63e38c6b 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index db8ea2c98..a19fcee87 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -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)
diff --git a/queries/twig/highlights.scm b/queries/twig/highlights.scm
new file mode 100644
index 000000000..32ddc24a9
--- /dev/null
+++ b/queries/twig/highlights.scm
@@ -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)
+
diff --git a/queries/twig/injections.scm b/queries/twig/injections.scm
new file mode 100644
index 000000000..97f84c16c
--- /dev/null
+++ b/queries/twig/injections.scm
@@ -0,0 +1,2 @@
+(content) @html
+