From 88642e902e380ecf506818e538ebead5ffcd3dfc Mon Sep 17 00:00:00 2001 From: gzagatti Date: Tue, 27 Feb 2024 12:50:47 +0100 Subject: [PATCH] add typst queries --- nvim/queries/typst/folds.scm | 11 +++++ nvim/queries/typst/highlights.scm | 81 +++++++++++++++++++++++++++++++ nvim/queries/typst/injections.scm | 7 +++ 3 files changed, 99 insertions(+) create mode 100644 nvim/queries/typst/folds.scm create mode 100644 nvim/queries/typst/highlights.scm create mode 100644 nvim/queries/typst/injections.scm diff --git a/nvim/queries/typst/folds.scm b/nvim/queries/typst/folds.scm new file mode 100644 index 0000000..e290d50 --- /dev/null +++ b/nvim/queries/typst/folds.scm @@ -0,0 +1,11 @@ +( + [ + (block) + (content) + (raw_blck) + (group) + (math) + (section) + ] @fold + (#trim! @fold) +) diff --git a/nvim/queries/typst/highlights.scm b/nvim/queries/typst/highlights.scm new file mode 100644 index 0000000..4286e7c --- /dev/null +++ b/nvim/queries/typst/highlights.scm @@ -0,0 +1,81 @@ +(call + item: (ident) @function) +(call + item: (field field: (ident) @function.method)) +(tagged field: (ident) @parameter) +(field field: (ident) @parameter) +(comment) @comment + +; CONTROL +(let "let" @keyword.storage.type) +(branch ["if" "else"] @keyword.control.conditional) +(while "while" @keyword.control.repeat) +(for ["for" "in"] @keyword.control.repeat) +(import "import" @keyword.control.import) +(as "as" @keyword.operator) +(include "include" @keyword.control.import) +(show "show" @keyword.control) +(set "set" @keyword.control) +(return "return" @keyword.control) +(flow ["break" "continue"] @keyword.control) + +; OPERATOR +(in ["in" "not"] @keyword.operator) +(and "and" @keyword.operator) +(or "or" @keyword.operator) +(not "not" @keyword.operator) +(sign ["+" "-"] @operator) +(add "+" @operator) +(sub "-" @operator) +(mul "*" @operator) +(div "/" @operator) +(cmp ["==" "<=" ">=" "!=" "<" ">"] @operator) +(fraction "/" @operator) +(fac "!" @operator) +(attach ["^" "_"] @operator) +(wildcard) @operator + +; VALUE +(raw_blck "```" @text.literal.block) @text.literal +(raw_span "`" @text.literal.block) @text.literal +(raw_blck lang: (ident) @label) +(label) @label +(ref) @text.reference +; (number) @constant.numeric +(string) @string +(content ["[" "]"] @operator) +(bool) @constant.builtin.boolean +(none) @constant.builtin +(auto) @constant.builtin +; (ident) @label +(call + item: (builtin) @function) +; (builtin) @constant.builtin + +; MARKUP +(item "-" @punctuation.list) +(term ["/" ":"] @punctuation.list) +(heading ["="] @text.title.1.marker) @text.title.1 +(heading ["=="] @text.title.2.marker) @text.title.2 +(heading ["==="] @text.title.3.marker) @text.title.3 +(heading ["===="] @text.title.4.marker) @text.title.4 +(heading ["====="] @text.title.5.marker) @text.title.5 +(url) @tag +(emph) @text.emphasis +(strong) @text.strong +; (symbol) @constant.character +(shorthand) @constant.builtin +(quote) @markup.quote +(align) @operator +(letter) @constant.character +(linebreak) @constant.builtin + +(math (formula)) @text.math +"#" @operator +"end" @operator + +(escape) @constant.character.escape +["(" ")" "{" "}"] @punctuation.bracket +["," ";" ".." ":" "sep"] @punctuation.delimiter +"assign" @punctuation +(field "." @punctuation) diff --git a/nvim/queries/typst/injections.scm b/nvim/queries/typst/injections.scm new file mode 100644 index 0000000..06a2509 --- /dev/null +++ b/nvim/queries/typst/injections.scm @@ -0,0 +1,7 @@ +(raw_blck + (blob) @injection.shebang @injection.content) + +(raw_blck + lang: (ident) @injection.language + (blob) @injection.content) +