From 92d2501d698e0fe855bd222540f9648890fab6c7 Mon Sep 17 00:00:00 2001 From: Elliot Fontaine <92150839+elliotfontaine@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:56:58 +0100 Subject: feat(cylc): add parser and queries (#7225) --- README.md | 1 + lockfile.json | 3 ++ lua/nvim-treesitter/parsers.lua | 8 +++++ queries/cylc/folds.scm | 10 ++++++ queries/cylc/highlights.scm | 72 +++++++++++++++++++++++++++++++++++++++++ queries/cylc/indents.scm | 16 +++++++++ queries/cylc/injections.scm | 11 +++++++ 7 files changed, 121 insertions(+) create mode 100644 queries/cylc/folds.scm create mode 100644 queries/cylc/highlights.scm create mode 100644 queries/cylc/indents.scm create mode 100644 queries/cylc/injections.scm diff --git a/README.md b/README.md index e1a7b6325..167753300 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [csv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq) - [x] [cuda](https://github.com/theHamsta/tree-sitter-cuda) (maintained by @theHamsta) - [x] [cue](https://github.com/eonpatapon/tree-sitter-cue) (maintained by @amaanq) +- [x] [cylc](https://github.com/elliotfontaine/tree-sitter-cylc) (maintained by @elliotfontaine) - [x] [d](https://github.com/gdamore/tree-sitter-d) (maintained by @amaanq) - [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @akinsho) - [x] [desktop](https://github.com/ValdezFOmar/tree-sitter-desktop) (maintained by @ValdezFOmar) diff --git a/lockfile.json b/lockfile.json index ef2fb39e8..29e80ffdf 100644 --- a/lockfile.json +++ b/lockfile.json @@ -101,6 +101,9 @@ "cue": { "revision": "8a5f273bfa281c66354da562f2307c2d394b6c81" }, + "cylc": { + "revision": "30dd40d9bf23912e4aefa93eeb4c7090bda3d0f6" + }, "d": { "revision": "45e5f1e9d6de2c68591bc8e5ec662cf18e950b4a" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index fd79f8af7..8e3ce2cf4 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -349,6 +349,14 @@ list.cue = { maintainers = { "@amaanq" }, } +list.cylc = { + install_info = { + url = "https://github.com/elliotfontaine/tree-sitter-cylc", + files = { "src/parser.c" }, + }, + maintainers = { "@elliotfontaine" }, +} + list.d = { install_info = { url = "https://github.com/gdamore/tree-sitter-d", diff --git a/queries/cylc/folds.scm b/queries/cylc/folds.scm new file mode 100644 index 000000000..c8bd40703 --- /dev/null +++ b/queries/cylc/folds.scm @@ -0,0 +1,10 @@ +[ + (multiline_string) + (multiline_graph_string) + (top_section) + (sub_section_1) + (sub_section_2) + (runtime_section) + (task_section) + (graph_section) +] @fold diff --git a/queries/cylc/highlights.scm b/queries/cylc/highlights.scm new file mode 100644 index 000000000..a744caa52 --- /dev/null +++ b/queries/cylc/highlights.scm @@ -0,0 +1,72 @@ +(comment) @comment @spell + +(key) @property + +(boolean) @boolean + +(datetime) @string.special + +(task_name) @function + +(include_directive) @keyword.import + +[ + (section_name) + (namespace) +] @markup.heading + +[ + (integer) + (recurrence) +] @number + +[ + "[" + "]" + "[[" + "]]" + "[[[" + "]]]" + "<" + ">" + (graph_parenthesis) +] @punctuation.bracket + +[ + "\"" + "\"\"\"" + (unquoted_string) + (quoted_string) + (multiline_string) +] @string + +[ + (xtrigger_annotation) + (suicide_annotation) +] @attribute + +[ + "=" + (assignment_operator) + (graph_logical) + (graph_arrow) +] @operator + +(include_statement + path: (_)? @string.special.path) + +(task_parameter + name: (_)? @variable.parameter + selection: (_)? @variable.parameter) + +(task_output + ":" @tag + (nametag) @variable.builtin + "?"? @tag) + +[ + (jinja2_expression) + (jinja2_statement) + (jinja2_comment) + (jinja2_shebang) +] @keyword.directive diff --git a/queries/cylc/indents.scm b/queries/cylc/indents.scm new file mode 100644 index 000000000..0457e4580 --- /dev/null +++ b/queries/cylc/indents.scm @@ -0,0 +1,16 @@ +[ + (top_section) + (sub_section_1) + (sub_section_2) + (graph_section) + (runtime_section) + (task_section) +] @indent.begin + +(multiline_string + quotes_close: _ @indent.end) @indent.begin + +(multiline_graph_string + quotes_close: _ @indent.end) @indent.begin + +(line_continuation) @indent.zero diff --git a/queries/cylc/injections.scm b/queries/cylc/injections.scm new file mode 100644 index 000000000..41becd699 --- /dev/null +++ b/queries/cylc/injections.scm @@ -0,0 +1,11 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; https://cylc.github.io/cylc-doc/latest/html/user-guide/task-implementation/job-scripts.html#jobscripts +((setting + key: (key) @_key + (#any-of? @_key + "script" "init-script" "env-script" "pre-script" "post-script" "err-script" "exit-script") + value: (_ + (string_content) @injection.content)) + (#set! injection.language "bash")) -- cgit v1.2.3-70-g09d2