aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOtto Modinos <ottomodinos@gmail.com>2021-09-10 03:49:35 +0300
committerStephan Seitz <stephan.seitz@fau.de>2021-09-17 21:06:36 +0200
commit4f96b955d650e332540beb2f5eab5b0896d42ed6 (patch)
treeb1629d6cd9d7845ab4fd02424c77e34b01136e4b
parent[cmake] add highlights for `add_custom_target` and `add_custom_command` (diff)
downloadnvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar.gz
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar.bz2
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar.lz
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar.xz
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.tar.zst
nvim-treesitter-4f96b955d650e332540beb2f5eab5b0896d42ed6.zip
fix(fennel): update parser and all the queries
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua2
-rw-r--r--queries/fennel/highlights.scm196
-rw-r--r--queries/fennel/locals.scm67
4 files changed, 121 insertions, 146 deletions
diff --git a/lockfile.json b/lockfile.json
index f21f5db79..f064c02b5 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -57,7 +57,7 @@
"revision": "9d5fd0c329280a156bf7614a49dc5e8c58cc037c"
},
"fennel": {
- "revision": "e10b04389094d9b96aa8489121c1f285562d701d"
+ "revision": "42823442a18dd2aa7b0b22dc719abb54abb3fe2e"
},
"fish": {
"revision": "04e54ab6585dfd4fee6ddfe5849af56f101b6d4f"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 9c59cbd9d..3a758450e 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -498,7 +498,7 @@ list.rst = {
list.fennel = {
install_info = {
url = "https://github.com/travonted/tree-sitter-fennel",
- files = { "src/parser.c", "src/scanner.c" },
+ files = { "src/parser.c" },
},
maintainers = { "@TravonteD" },
}
diff --git a/queries/fennel/highlights.scm b/queries/fennel/highlights.scm
index 13f955feb..2ebfcdc09 100644
--- a/queries/fennel/highlights.scm
+++ b/queries/fennel/highlights.scm
@@ -1,94 +1,4 @@
-(boolean) @boolean
-(nil) @constant.builtin
-(string) @string
-(number) @number
-(field) @constant
(comment) @comment
-(identifier) @variable
-
-[
- "fn"
- "lambda"
- "hashfn"
- "set"
- "tset"
- "λ"
- "global"
- "var"
- "local"
- "let"
- "do"
- "not"
- "not="
- "_ENV"
- "_G"
- "_VERSION"
- "arg"
- "assert"
- "collectgarbage"
- "coroutine"
- "debug"
- "dofile"
- "doto"
- "error"
- "eval-compiler"
- "gensym"
- "getmetatable"
- "in-scope?"
- "ipairs"
- "list"
- "list?"
- "load"
- "loadfile"
- "loadstring"
- "match"
- "macro"
- "macrodebug"
- "macroexpand"
- "macros"
- "multi-sym?"
- "next"
- "pairs"
- "package"
- "pcall"
- "print"
- "rawequal"
- "rawget"
- "rawlen"
- "rawset"
- "select"
- "sequence?"
- "setmetatable"
- "string"
- "sym"
- "sym?"
- "table"
- "table?"
- "tonumber"
- "tostring"
- "type"
- "unpack"
- "varg?"
- "xpcall"
-] @keyword
-
-[
- "require"
- "require-macros"
- "import-macros"
- "include"
- ] @include
-
-[
- "each"
- "for"
- "while"
-] @repeat
-
-[
- "if"
- "when"
-] @conditional
[
"("
@@ -99,26 +9,100 @@
"]"
] @punctuation.bracket
-; hash function
-"#" @function
+(nil) @constant.builtin
+(vararg) @punctuation.special
-(function_definition
- name: (identifier) @function)
+(boolean) @boolean
+(number) @number
-(lambda_definition
- name: (identifier) @function)
+(string) @string
+(escape_sequence) @string.escape
-(function_call
- name: (identifier) @function)
+(symbol) @variable
-(field_expression
- (identifier)
+(multi_symbol
"." @punctuation.delimiter
- (identifier) @function)
+ (symbol) @field)
+
+(multi_symbol_method
+ ":" @punctuation.delimiter
+ (symbol) @method .)
+
+(list . (symbol) @function)
+(list . (multi_symbol (symbol) @function .))
+
+((symbol) @variable.builtin
+ (#match? @variable.builtin "^[$]"))
+
+(sequential_table_binding (symbol) @symbol)
+(table_binding ([(_) ":" @punctuation.special] (symbol) @symbol)*)
+
+[
+ "fn"
+ "lambda"
+ "hashfn"
+ "#"
+] @keyword.function
+
+(fn name: [
+ (symbol) @function
+ (multi_symbol (symbol) @function .)
+])
+
+(lambda name: [
+ (symbol) @function
+ (multi_symbol (symbol) @function .)
+])
+
+(parameters (symbol) @parameter)
+
+[
+ "for"
+ "each"
+] @repeat
+((symbol) @repeat
+ (#any-of? @repeat
+ "while"))
+
+[
+ "match"
+] @conditional
+((symbol) @conditional
+ (#any-of? @conditional
+ "if" "when"))
+
+((symbol) @include
+ (#any-of? @include
+ "require" "require-macros" "import-macros" "include"))
+
+[
+ "global"
+ "local"
+ "let"
+ "set"
+ "var"
+] @keyword
+((symbol) @keyword
+ (#any-of? @keyword
+ "comment" "do" "doc" "eval-compiler" "lua" "macros" "quote" "tset" "values"))
+
+((symbol) @function.macro
+ (#any-of? @function.macro
+ "->" "->>" "-?>" "-?>>" "?." "accumulate" "collect" "doto" "icollect"
+ "macro" "macrodebug" "partial" "pick-args" "pick-values" "with-open"))
+
+; Lua builtins
+((symbol) @constant.builtin
+ (#any-of? @constant.builtin
+ "arg" "_ENV" "_G" "_VERSION"))
-;; TODO: fix me
-;(field_expression
- ;(identifier)
- ;(field) @function)
+((symbol) @function.builtin
+ (#any-of? @function.builtin
+ "assert" "collectgarbage" "dofile" "error" "getmetatable" "ipairs"
+ "load" "loadfile" "next" "pairs" "pcall" "print" "rawequal" "rawget"
+ "rawlen" "rawset" "require" "select" "setmetatable" "tonumber" "tostring"
+ "type" "warn" "xpcall"))
-(parameters (identifier) @parameter)
+((symbol) @function.builtin
+ (#any-of? @function.builtin
+ "loadstring" "module" "setfenv" "unpack"))
diff --git a/queries/fennel/locals.scm b/queries/fennel/locals.scm
index fb260596b..6a0f6c9fe 100644
--- a/queries/fennel/locals.scm
+++ b/queries/fennel/locals.scm
@@ -1,45 +1,36 @@
-; Scope
[
(program)
- (function_definition)
- (lambda_definition)
- (let_definition)
+ (fn)
+ (lambda)
+ (let)
+ (each)
+ (for)
+ (match)
] @scope
-; Functions
-(function_definition
- name: (identifier) @definition.function)
-(lambda_definition
- name: (identifier) @definition.function)
+((symbol) @scope
+ (#any-of? @scope
+ "while" "if" "when" "do"))
+
+(fn name: (symbol) @definition.function)
+(lambda name: (symbol) @definition.function)
-; Variable Definitions
-(local_definition
- (assignment
- (identifier) @definition.var))
-(var_definition
- (assignment
- (identifier) @definition.var))
-(global_definition
- (assignment
- (identifier) @definition.var))
-(assignment
- (identifier) @definition.var)
-(multi_value_assignment
- (value_list
- (identifier) @definition.var))
(parameters
- ((identifier) @definition.var))
-; iterators/loops
-((each
- (each_clause
- (identifier) @definition.var)) @scope)
-((for
- (for_clause
- (identifier) @definition.var)) @scope)
+ (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)*)
-; references
-(set
- (assignment (identifier) @reference))
-(function_call
- name: (identifier) @reference)
-(identifier) @reference
+(symbol) @reference