aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2024-02-09 16:51:43 +0100
committerChristian Clason <c.clason@uni-graz.at>2024-02-09 18:29:39 +0100
commitb8840a426e38c486ddb365c8d9e663d1be659c15 (patch)
treee617d8c4cf5374621cda529ec3d668a116bf7b09
parentUpdate README (diff)
downloadnvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar.gz
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar.bz2
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar.lz
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar.xz
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.tar.zst
nvim-treesitter-b8840a426e38c486ddb365c8d9e663d1be659c15.zip
feat(tcl): add parser and queries
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/tcl/folds.scm1
-rw-r--r--queries/tcl/highlights.scm105
-rw-r--r--queries/tcl/indents.scm25
6 files changed, 143 insertions, 0 deletions
diff --git a/README.md b/README.md
index 74539aaf9..b2a9cb26f 100644
--- a/README.md
+++ b/README.md
@@ -394,6 +394,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [t32](https://gitlab.com/xasc/tree-sitter-t32.git) (maintained by @xasc)
- [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq)
- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce)
+- [x] [tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) (maintained by @lewis6991)
- [x] [templ](https://github.com/vrischmann/tree-sitter-templ) (maintained by @vrischmann)
- [x] [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann)
- [x] [textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) (maintained by @Porter)
diff --git a/lockfile.json b/lockfile.json
index 21b20893b..fa9d896d5 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -662,6 +662,9 @@
"teal": {
"revision": "33482c92a0dfa694491d34e167a1d2f52b0dccb1"
},
+ "tcl": {
+ "revision": "ca2643e3cd818771635a152899fb70b6b37d648a"
+ },
"templ": {
"revision": "592faa3186ef857c92e4bd1c31d73c07a4a334db"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index d2985abb8..68d346b83 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1934,6 +1934,14 @@ list.teal = {
maintainers = { "@euclidianAce" },
}
+list.tcl = {
+ install_info = {
+ url = "https://github.com/tree-sitter-grammars/tree-sitter-tcl",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@lewis6991" },
+}
+
list.terraform = {
install_info = {
url = "https://github.com/MichaHoffmann/tree-sitter-hcl",
diff --git a/queries/tcl/folds.scm b/queries/tcl/folds.scm
new file mode 100644
index 000000000..9084c662c
--- /dev/null
+++ b/queries/tcl/folds.scm
@@ -0,0 +1 @@
+(braced_word) @fold
diff --git a/queries/tcl/highlights.scm b/queries/tcl/highlights.scm
new file mode 100644
index 000000000..5cb281dbd
--- /dev/null
+++ b/queries/tcl/highlights.scm
@@ -0,0 +1,105 @@
+(comment) @comment @spell
+
+(command
+ name: (simple_word) @function)
+
+"proc" @keyword.function
+
+(procedure
+ name: (_) @variable)
+
+(set
+ (simple_word) @variable)
+
+(argument
+ name: (_) @variable.parameter)
+
+((simple_word) @variable.builtin
+ (#any-of? @variable.builtin "argc" "argv" "argv0" "auto_path" "env" "errorCode" "errorInfo" "tcl_interactive" "tcl_library" "tcl_nonwordchars" "tcl_patchLevel" "tcl_pkgPath" "tcl_platform" "tcl_precision" "tcl_rcFileName" "tcl_traceCompile" "tcl_traceExec" "tcl_wordchars" "tcl_version"))
+
+"expr" @function.builtin
+
+(command
+ name: (simple_word) @function.builtin
+ (#any-of? @function.builtin "cd" "exec" "exit" "incr" "info" "join" "puts" "regexp" "regsub" "split" "subst" "trace" "source"))
+
+(command
+ name: (simple_word) @keyword
+ (#any-of? @keyword "append" "break" "catch" "continue" "default" "dict" "error" "eval" "global" "lappend" "lassign" "lindex" "linsert" "list" "llength" "lmap" "lrange" "lrepeat" "lreplace" "lreverse" "lsearch" "lset" "lsort" "package" "return" "switch" "throw" "unset" "variable"))
+
+[
+ "error"
+ "namespace"
+ "on"
+ "set"
+ "try"
+] @keyword
+
+(unpack) @operator
+
+[
+ "while"
+ "foreach"
+] @keyword.repeat
+
+[
+ "if"
+ "else"
+ "elseif"
+] @keyword.conditional
+
+[
+ "**"
+ "/"
+ "*"
+ "%"
+ "+"
+ "-"
+ "<<"
+ ">>"
+ ">"
+ "<"
+ ">="
+ "<="
+ "=="
+ "!="
+ "eq"
+ "ne"
+ "in"
+ "ni"
+ "&"
+ "^"
+ "|"
+ "&&"
+ "||"
+] @operator
+
+(variable_substitution) @variable
+
+(quoted_word) @string
+
+(escaped_character) @string.escape
+
+[
+ "{"
+ "}"
+ "["
+ "]"
+ ";"
+] @punctuation.delimiter
+
+((simple_word) @number
+ (#lua-match? @number "^[0-9]+$"))
+
+((simple_word) @boolean
+ (#any-of? @boolean "true" "false"))
+
+; after apply array auto_execok auto_import auto_load auto_mkindex auto_qualify
+; auto_reset bgerror binary chan clock close coroutine dde encoding eof fblocked
+; fconfigure fcopy file fileevent filename flush format gets glob history http
+; interp load mathfunc mathop memory msgcat my next nextto open parray pid
+; pkg::create pkg_mkIndex platform platform::shell pwd re_syntax read refchan
+; registry rename safe scan seek self socket source string tailcall tcl::prefix
+; tcl_endOfWord tcl_findLibrary tcl_startOfNextWord tcl_startOfPreviousWord
+; tcl_wordBreakAfter tcl_wordBreakBefore tcltest tell time timerate tm
+; transchan unknown unload update uplevel upvar vwait yield yieldto zlib
diff --git a/queries/tcl/indents.scm b/queries/tcl/indents.scm
new file mode 100644
index 000000000..c4968d17d
--- /dev/null
+++ b/queries/tcl/indents.scm
@@ -0,0 +1,25 @@
+[
+ (braced_word_simple)
+ (namespace)
+ (command)
+ (conditional)
+ (foreach)
+ (while)
+ (try)
+ (procedure)
+ (command_substitution)
+] @indent.begin
+
+(quoted_word) @indent.align
+
+([
+ (expr)
+ (arguments)
+] @indent.align
+ (#set! "indent.open_delimiter" "{")
+ (#set! "indent.close_delimiter" "}"))
+
+[
+ "}"
+ "]"
+] @indent.branch @indent.end