From 88f293115398e5609ee845fd8698b5584ac62fa5 Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Thu, 4 Apr 2024 03:31:00 +0200 Subject: [PATCH] Add tcl highlighting (#9837) Co-authored-by: Michael Davis --- book/src/generated/lang-support.md | 1 + languages.toml | 12 +++ runtime/queries/tcl/folds.scm | 1 + runtime/queries/tcl/highlights.scm | 153 +++++++++++++++++++++++++++++ runtime/queries/tcl/indents.scm | 13 +++ 5 files changed, 180 insertions(+) create mode 100644 runtime/queries/tcl/folds.scm create mode 100644 runtime/queries/tcl/highlights.scm create mode 100644 runtime/queries/tcl/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a4e2a84a2..efdc8b634 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -186,6 +186,7 @@ | tablegen | ✓ | ✓ | ✓ | | | tact | ✓ | ✓ | ✓ | | | task | ✓ | | | | +| tcl | ✓ | | ✓ | | | templ | ✓ | | | `templ` | | tfvars | ✓ | | ✓ | `terraform-ls` | | todotxt | ✓ | | | | diff --git a/languages.toml b/languages.toml index b047b83eb..755b37deb 100644 --- a/languages.toml +++ b/languages.toml @@ -3367,6 +3367,18 @@ grammar = "hyprlang" name = "hyprlang" source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang", rev = "27af9b74acf89fa6bed4fb8cb8631994fcb2e6f3"} +[[language]] +name = "tcl" +scope = "source.tcl" +injection-regex = "tcl" +file-types = [ "tcl" ] +shebangs = [ "tclish", "jimsh", "wish" ] +comment-token = '#' + +[[grammar]] +name = "tcl" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-tcl", rev = "56ad1fa6a34ba800e5495d1025a9b0fda338d5b8" } + [[language]] name = "supercollider" scope = "source.supercollider" diff --git a/runtime/queries/tcl/folds.scm b/runtime/queries/tcl/folds.scm new file mode 100644 index 000000000..9084c662c --- /dev/null +++ b/runtime/queries/tcl/folds.scm @@ -0,0 +1 @@ +(braced_word) @fold diff --git a/runtime/queries/tcl/highlights.scm b/runtime/queries/tcl/highlights.scm new file mode 100644 index 000000000..27b2d81e6 --- /dev/null +++ b/runtime/queries/tcl/highlights.scm @@ -0,0 +1,153 @@ + +(comment) @comment + +(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" + ; "for" + ] @keyword.control.repeat + +[ + "if" + "else" + "elseif" + ] @keyword.control.conditional + +[ + "**" + "/" "*" "%" "+" "-" + "<<" ">>" + ">" "<" ">=" "<=" + "==" "!=" + "eq" "ne" + "in" "ni" + "&" + "^" + "|" + "&&" + "||" + ] @operator + +(variable_substitution) @variable +(quoted_word) @string +(escaped_character) @constant.character.escape + +[ + "{" "}" + "[" "]" + ";" + ] @punctuation.delimiter + +((simple_word) @constant.numeric + (#match? @constant.numeric "^[0-9]+$")) + +((simple_word) @constant.builtin.boolean + (#any-of? @constant.builtin.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/runtime/queries/tcl/indents.scm b/runtime/queries/tcl/indents.scm new file mode 100644 index 000000000..c0652fe78 --- /dev/null +++ b/runtime/queries/tcl/indents.scm @@ -0,0 +1,13 @@ +[ + (braced_word_simple) + (namespace) + (command) + (conditional) + (foreach) + (while) + (try) + (procedure) + (command_substitution) + ] @indent + +[ "}" "]" ] @outdent