aboutsummaryrefslogtreecommitdiffstats
path: root/queries/nim_format_string
diff options
context:
space:
mode:
authoraMOPel <36712072+aMOPel@users.noreply.github.com>2023-10-30 12:35:51 +0100
committerGitHub <noreply@github.com>2023-10-30 20:35:51 +0900
commitaeb5ad8ae1c7f0165128b0be889fae967d46844d (patch)
tree027617ea4d01a19e76a5def4bfe3b5d45708410f /queries/nim_format_string
parentfix(rust): add foreign_mod_item to folds (diff)
downloadnvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar.gz
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar.bz2
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar.lz
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar.xz
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.tar.zst
nvim-treesitter-aeb5ad8ae1c7f0165128b0be889fae967d46844d.zip
feat(nim): added nim parser and queries (#5556)
* feat(nim): added nim parser and queries * correct scanner.cc to scanner.c Co-authored-by: Christian Clason <c.clason@uni-graz.at> * fix(nim): corrected capture for @function.macro * feat(nim highlights): added @field capture for discriminator field in object variant * bumped parser version, adapted highlights.scm and condensed injections.scm * improved nim_format_string highlights.scm * bump nim parser version again * removed overlap between queries for generalized strings in injections.scm * improved formattin] in nim_format_string/injections.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * corrected asm parser name in injections.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * improved formatting in highlights.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * removed @error capture from highlights.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * improved wording in comment in highlights.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * removed priority from (dot_expression left: @none) capture, since it's at the end of the file anyways * removed comments listing unused captures * reverted @error capture in nim_format_string/highlights.scm back to @none * condensed string alternatives in injections.scm Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * condensed string alternatives in injections.scm (second part) Co-authored-by: ObserverOfTime <chronobserver@disroot.org> * added comment to explain reasoning behind priority use * swapped order of @punctuation.delimiter and @operator to get rid of superfluous comment * moved macro and template keywords to @preproc capture * removed priorities in highlights.scm and shifted @parameter capture behind @type capture * improved formatting in locals.scm * added queries for missing cases of @definition.namespace capture in locals.scm * removed some trailing whitespace * added @namespace queries for highlights.scm * bumped parser version again * removed superfluous @type capture * removed `@type`s `has-ancestor` and removed `(_ (_ ...` structures, but added priorities * added missing @constant capture to some queries in highlights.scm * fixed priority numbers so they work when injecting nim (in markdown) * added @none captures back to injection targets * added (assembly_statement) injection query * added indent queries * removed indents.scm again * added some missing queries for dot_generic_call, concept_declaration and pragma_statement --------- Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
Diffstat (limited to 'queries/nim_format_string')
-rw-r--r--queries/nim_format_string/highlights.scm19
-rw-r--r--queries/nim_format_string/injections.scm2
2 files changed, 21 insertions, 0 deletions
diff --git a/queries/nim_format_string/highlights.scm b/queries/nim_format_string/highlights.scm
new file mode 100644
index 000000000..94a239dfb
--- /dev/null
+++ b/queries/nim_format_string/highlights.scm
@@ -0,0 +1,19 @@
+(string_literal)
+(matching_curlies
+ opening_curly: (opening_curly) @punctuation.special
+ equals: (equals)? @punctuation.special
+ closing_curly: (closing_curly) @punctuation.special)
+
+(format_specifiers
+ colon: (colon) @punctuation.delimiter
+ fill_align: (fill_align)? @conditional.ternary
+ sign: (sign)? @operator
+ hash: (hash)? @punctuation.special
+ zero: (zero)? @field
+ min_width: (min_width)? @number
+ precision: (precision)? @number
+ type: (type)? @type)
+
+(matching_curlies
+ nim_expression: (nim_expression
+ escaped_curly: (escaped_curly)+ @string.escape) @none)
diff --git a/queries/nim_format_string/injections.scm b/queries/nim_format_string/injections.scm
new file mode 100644
index 000000000..0775fba0c
--- /dev/null
+++ b/queries/nim_format_string/injections.scm
@@ -0,0 +1,2 @@
+((matching_curlies (nim_expression !escaped_curly) @injection.content)
+ (#set! injection.language "nim"))