From 99d4f72a5cd4a1c8e9c050eb347a5f724561fe1f Mon Sep 17 00:00:00 2001 From: Otto Modinos Date: Thu, 30 Sep 2021 18:17:31 +0300 Subject: feat(fennel): update parser and queries --- lockfile.json | 2 +- queries/fennel/highlights.scm | 23 +++++++++++++++-------- queries/fennel/locals.scm | 26 +++++++------------------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lockfile.json b/lockfile.json index d7ea8d385..a980739de 100644 --- a/lockfile.json +++ b/lockfile.json @@ -57,7 +57,7 @@ "revision": "9d5fd0c329280a156bf7614a49dc5e8c58cc037c" }, "fennel": { - "revision": "42823442a18dd2aa7b0b22dc719abb54abb3fe2e" + "revision": "fce4331731a960077ff5f98939bc675179f1908a" }, "fish": { "revision": "04e54ab6585dfd4fee6ddfe5849af56f101b6d4f" diff --git a/queries/fennel/highlights.scm b/queries/fennel/highlights.scm index 2ebfcdc09..48a33990e 100644 --- a/queries/fennel/highlights.scm +++ b/queries/fennel/highlights.scm @@ -9,6 +9,14 @@ "]" ] @punctuation.bracket +[ + ":" + ":until" + "&" + "&as" + "?" +] @punctuation.special + (nil) @constant.builtin (vararg) @punctuation.special @@ -34,8 +42,7 @@ ((symbol) @variable.builtin (#match? @variable.builtin "^[$]")) -(sequential_table_binding (symbol) @symbol) -(table_binding ([(_) ":" @punctuation.special] (symbol) @symbol)*) +(binding) @symbol [ "fn" @@ -54,8 +61,6 @@ (multi_symbol (symbol) @function .) ]) -(parameters (symbol) @parameter) - [ "for" "each" @@ -71,21 +76,23 @@ (#any-of? @conditional "if" "when")) -((symbol) @include - (#any-of? @include - "require" "require-macros" "import-macros" "include")) - [ "global" "local" "let" "set" "var" + "where" + "or" ] @keyword ((symbol) @keyword (#any-of? @keyword "comment" "do" "doc" "eval-compiler" "lua" "macros" "quote" "tset" "values")) +((symbol) @include + (#any-of? @include + "require" "require-macros" "import-macros" "include")) + ((symbol) @function.macro (#any-of? @function.macro "->" "->>" "-?>" "-?>>" "?." "accumulate" "collect" "doto" "icollect" diff --git a/queries/fennel/locals.scm b/queries/fennel/locals.scm index 6a0f6c9fe..31e52038b 100644 --- a/queries/fennel/locals.scm +++ b/queries/fennel/locals.scm @@ -8,29 +8,17 @@ (match) ] @scope -((symbol) @scope - (#any-of? @scope - "while" "if" "when" "do")) +( + (list . (symbol) @_special) @scope + (#any-of? @_special + "while" "if" "when" "do" "collect" "icollect" "accumulate") +) (fn name: (symbol) @definition.function) (lambda name: (symbol) @definition.function) -(parameters - (symbol) @definition.var) - +; TODO: use @definition.parameter for parameters +(binding (symbol) @definition.var) (for_clause . (symbol) @definition.var) -; FIXME: how to distinguish between symbols-as-bindings and -; symbols-as-expressions -; (each_clause (symbol) @definition.var) -; (let_clause ((symbol) @definition.var (_))*) - -(global . (symbol) @definition.var) -(local . (symbol) @definition.var) -(var . (symbol) @definition.var) - -(multi_value_binding (symbol) @definition.var) -(sequential_table_binding (symbol) @definition.var) -(table_binding ([(_) ":"] (symbol) @definition.var)*) - (symbol) @reference -- cgit v1.2.3-70-g09d2