mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
feat(fennel)!: switch to maintained parser (#6132)
Change the Fennel parser to a simpler and more consistent one, along with updating all the queries.
This commit is contained in:
parent
71ae32c187
commit
7d1bab6546
6 changed files with 398 additions and 107 deletions
|
|
@ -162,7 +162,7 @@
|
||||||
"revision": "9e514af33bfe061d0ccf1999dbcc93fca91f133c"
|
"revision": "9e514af33bfe061d0ccf1999dbcc93fca91f133c"
|
||||||
},
|
},
|
||||||
"fennel": {
|
"fennel": {
|
||||||
"revision": "15e4f8c417281768db17080c4447297f8ff5343a"
|
"revision": "389e9ec34d9a56ecf3dd74232de8675b3c4b5487"
|
||||||
},
|
},
|
||||||
"firrtl": {
|
"firrtl": {
|
||||||
"revision": "2b5adae629c8cba528c7b1e4aa67a8ae28934ea5"
|
"revision": "2b5adae629c8cba528c7b1e4aa67a8ae28934ea5"
|
||||||
|
|
|
||||||
|
|
@ -529,10 +529,10 @@ list.faust = {
|
||||||
|
|
||||||
list.fennel = {
|
list.fennel = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/travonted/tree-sitter-fennel",
|
url = "https://github.com/alexmozaidze/tree-sitter-fennel",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
},
|
},
|
||||||
maintainers = { "@TravonteD" },
|
maintainers = { "@alexmozaidze" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.firrtl = {
|
list.firrtl = {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,35 @@
|
||||||
[
|
[
|
||||||
(list)
|
(list)
|
||||||
(table)
|
(table)
|
||||||
(sequential_table)
|
(sequence)
|
||||||
(let)
|
|
||||||
(fn)
|
|
||||||
(let_clause)
|
|
||||||
(quoted_list)
|
|
||||||
(local)
|
|
||||||
(global)
|
|
||||||
] @fold
|
] @fold
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @_let
|
||||||
|
(#eq? @_let "let")
|
||||||
|
.
|
||||||
|
(sequence) @fold) @fold
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @_local
|
||||||
|
(#eq? @_local "local")) @fold
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @_global
|
||||||
|
(#eq? @_global "global")) @fold
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @_fn
|
||||||
|
(#any-of? @_fn "fn" "lambda" "λ" "hashfn")) @fold
|
||||||
|
|
||||||
|
(reader_macro
|
||||||
|
macro:
|
||||||
|
[
|
||||||
|
"'"
|
||||||
|
"`"
|
||||||
|
]
|
||||||
|
expression: (_) @fold)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
; Most primitive nodes
|
||||||
|
(shebang) @keyword.directive
|
||||||
|
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -9,18 +12,8 @@
|
||||||
"]"
|
"]"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
[
|
|
||||||
":"
|
|
||||||
":until"
|
|
||||||
"&"
|
|
||||||
"&as"
|
|
||||||
"?"
|
|
||||||
] @punctuation.special
|
|
||||||
|
|
||||||
(nil) @constant.builtin
|
(nil) @constant.builtin
|
||||||
|
|
||||||
(vararg) @punctuation.special
|
|
||||||
|
|
||||||
(boolean) @boolean
|
(boolean) @boolean
|
||||||
|
|
||||||
(number) @number
|
(number) @number
|
||||||
|
|
@ -33,11 +26,7 @@
|
||||||
|
|
||||||
(multi_symbol
|
(multi_symbol
|
||||||
"." @punctuation.delimiter
|
"." @punctuation.delimiter
|
||||||
(symbol) @variable.member)
|
member: (symbol_fragment) @variable.member)
|
||||||
|
|
||||||
(multi_symbol_method
|
|
||||||
":" @punctuation.delimiter
|
|
||||||
(symbol) @function.method.call .)
|
|
||||||
|
|
||||||
(list
|
(list
|
||||||
.
|
.
|
||||||
|
|
@ -46,80 +35,218 @@
|
||||||
(list
|
(list
|
||||||
.
|
.
|
||||||
(multi_symbol
|
(multi_symbol
|
||||||
(symbol) @function.call .))
|
member: (symbol_fragment) @function.call .))
|
||||||
|
|
||||||
((symbol) @variable.builtin
|
(multi_symbol_method
|
||||||
(#lua-match? @variable.builtin "^[$]"))
|
":" @punctuation.delimiter
|
||||||
|
method: (symbol_fragment) @function.method.call .)
|
||||||
|
|
||||||
(binding) @string.special.symbol
|
; Just `&` is only used in destructuring
|
||||||
|
((symbol) @punctuation.special
|
||||||
|
(#eq? @punctuation.special "&"))
|
||||||
|
|
||||||
[
|
; BUG: $ arguments should only be valid inside hashfn of any depth, but
|
||||||
"fn"
|
; it's impossible to express such query at the moment of writing.
|
||||||
"lambda"
|
; See tree-sitter/tree-sitter#880
|
||||||
"hashfn"
|
((symbol) @variable.parameter
|
||||||
"#"
|
(#eq? @variable.parameter "$..."))
|
||||||
] @keyword.function
|
|
||||||
|
|
||||||
(fn
|
((symbol) @variable.parameter
|
||||||
name:
|
(#lua-match? @variable.parameter "^%$[1-9]$"))
|
||||||
[
|
|
||||||
(symbol) @function
|
|
||||||
(multi_symbol
|
|
||||||
(symbol) @function .)
|
|
||||||
])
|
|
||||||
|
|
||||||
(lambda
|
((symbol) @operator
|
||||||
name:
|
; format-ignore
|
||||||
[
|
(#any-of? @operator
|
||||||
(symbol) @function
|
; arithmetic
|
||||||
(multi_symbol
|
"+" "-" "*" "/" "//" "%" "^"
|
||||||
(symbol) @function .)
|
; comparison
|
||||||
])
|
">" "<" ">=" "<=" "=" "~="
|
||||||
|
; other
|
||||||
|
"#" "." "?." ".."))
|
||||||
|
|
||||||
[
|
((symbol) @keyword.operator
|
||||||
"for"
|
; format-ignore
|
||||||
"each"
|
(#any-of? @keyword.operator
|
||||||
] @keyword.repeat
|
; comparison
|
||||||
|
"not="
|
||||||
|
; boolean
|
||||||
|
"and" "or" "not"
|
||||||
|
; bitwise
|
||||||
|
"lshift" "rshift" "band" "bor" "bxor" "bnot"
|
||||||
|
; other
|
||||||
|
"length"))
|
||||||
|
|
||||||
|
(reader_macro
|
||||||
|
macro: "#" @keyword.function)
|
||||||
|
|
||||||
|
((symbol) @keyword.function
|
||||||
|
(#any-of? @keyword.function "fn" "lambda" "λ" "hashfn"))
|
||||||
|
|
||||||
((symbol) @keyword.repeat
|
((symbol) @keyword.repeat
|
||||||
(#any-of? @keyword.repeat "while"))
|
(#any-of? @keyword.repeat "for" "each" "while"))
|
||||||
|
|
||||||
"match" @keyword.conditional
|
|
||||||
|
|
||||||
((symbol) @keyword.conditional
|
((symbol) @keyword.conditional
|
||||||
(#any-of? @keyword.conditional "if" "when"))
|
(#any-of? @keyword.conditional "if" "when" "match" "case"))
|
||||||
|
|
||||||
[
|
|
||||||
"global"
|
|
||||||
"local"
|
|
||||||
"let"
|
|
||||||
"set"
|
|
||||||
"var"
|
|
||||||
"where"
|
|
||||||
"or"
|
|
||||||
] @keyword
|
|
||||||
|
|
||||||
((symbol) @keyword
|
((symbol) @keyword
|
||||||
(#any-of? @keyword "comment" "do" "doc" "eval-compiler" "lua" "macros" "quote" "tset" "values"))
|
; format-ignore
|
||||||
|
(#any-of? @keyword
|
||||||
|
"global"
|
||||||
|
"local"
|
||||||
|
"let"
|
||||||
|
"set"
|
||||||
|
"var"
|
||||||
|
"comment"
|
||||||
|
"do"
|
||||||
|
"doc"
|
||||||
|
"eval-compiler"
|
||||||
|
"lua"
|
||||||
|
"macros"
|
||||||
|
"unquote"
|
||||||
|
"quote"
|
||||||
|
"tset"
|
||||||
|
"values"
|
||||||
|
"tail!"))
|
||||||
|
|
||||||
((symbol) @keyword.import
|
((symbol) @keyword.import
|
||||||
(#any-of? @keyword.import "require" "require-macros" "import-macros" "include"))
|
(#any-of? @keyword.import "require" "require-macros" "import-macros" "include"))
|
||||||
|
|
||||||
[
|
|
||||||
"collect"
|
|
||||||
"icollect"
|
|
||||||
"accumulate"
|
|
||||||
] @function.macro
|
|
||||||
|
|
||||||
((symbol) @function.macro
|
((symbol) @function.macro
|
||||||
(#any-of? @function.macro "->" "->>" "-?>" "-?>>" "?." "doto" "macro" "macrodebug" "partial" "pick-args" "pick-values" "with-open"))
|
; format-ignore
|
||||||
|
(#any-of? @function.macro
|
||||||
|
"collect"
|
||||||
|
"icollect"
|
||||||
|
"fcollect"
|
||||||
|
"accumulate"
|
||||||
|
"faccumulate"
|
||||||
|
"->"
|
||||||
|
"->>"
|
||||||
|
"-?>"
|
||||||
|
"-?>>"
|
||||||
|
"?."
|
||||||
|
"doto"
|
||||||
|
"macro"
|
||||||
|
"macrodebug"
|
||||||
|
"partial"
|
||||||
|
"pick-args"
|
||||||
|
"pick-values"
|
||||||
|
"with-open"))
|
||||||
|
|
||||||
|
; TODO: Highlight builtin methods (`table.unpack`, etc) as @function.builtin
|
||||||
|
([
|
||||||
|
(symbol) @module.builtin
|
||||||
|
(multi_symbol
|
||||||
|
base: (symbol_fragment) @module.builtin)
|
||||||
|
]
|
||||||
|
(#any-of? @module.builtin "vim" "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
|
||||||
|
|
||||||
|
([
|
||||||
|
(symbol) @variable.builtin
|
||||||
|
(multi_symbol
|
||||||
|
.
|
||||||
|
(symbol_fragment) @variable.builtin)
|
||||||
|
]
|
||||||
|
(#eq? @variable.builtin "arg"))
|
||||||
|
|
||||||
|
((symbol) @variable.builtin
|
||||||
|
(#eq? @variable.builtin "..."))
|
||||||
|
|
||||||
; Lua builtins
|
|
||||||
((symbol) @constant.builtin
|
((symbol) @constant.builtin
|
||||||
(#any-of? @constant.builtin "arg" "_ENV" "_G" "_VERSION"))
|
(#eq? @constant.builtin "_VERSION"))
|
||||||
|
|
||||||
((symbol) @function.builtin
|
((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"))
|
; format-ignore
|
||||||
|
(#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"
|
||||||
|
"module"
|
||||||
|
"setfenv"
|
||||||
|
"loadstring"
|
||||||
|
"unpack"))
|
||||||
|
|
||||||
((symbol) @function.builtin
|
(table
|
||||||
(#any-of? @function.builtin "loadstring" "module" "setfenv" "unpack"))
|
(table_pair
|
||||||
|
key: (symbol) @keyword.directive
|
||||||
|
(#eq? @keyword.directive "&as")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @keyword.function
|
||||||
|
(#any-of? @keyword.function "fn" "lambda" "λ")
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(symbol) @function
|
||||||
|
(multi_symbol
|
||||||
|
(symbol_fragment) @function .)
|
||||||
|
]
|
||||||
|
.
|
||||||
|
(sequence
|
||||||
|
((symbol) @variable.parameter
|
||||||
|
(#not-any-of? @variable.parameter "&" "..."))))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @function.macro
|
||||||
|
(#any-of? @function.macro "collect" "icollect" "fcollect")
|
||||||
|
.
|
||||||
|
(sequence
|
||||||
|
[
|
||||||
|
(symbol)
|
||||||
|
(string)
|
||||||
|
] @keyword.directive
|
||||||
|
(#any-of? @keyword.directive "&into" ":into")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @function.macro
|
||||||
|
(#any-of? @function.macro "for" "each" "collect" "icollect" "fcollect" "accumulate" "faccumulate")
|
||||||
|
.
|
||||||
|
(sequence
|
||||||
|
[
|
||||||
|
(symbol)
|
||||||
|
(string)
|
||||||
|
] @keyword.directive
|
||||||
|
(#any-of? @keyword.directive "&until" ":until")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @keyword.conditional
|
||||||
|
(#any-of? @keyword.conditional "match" "case")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
((list
|
||||||
|
.
|
||||||
|
(symbol) @keyword
|
||||||
|
(#eq? @keyword "where"))
|
||||||
|
.
|
||||||
|
(_))*
|
||||||
|
.
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @keyword
|
||||||
|
(#eq? @keyword "where"))
|
||||||
|
.
|
||||||
|
(_)? .)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,148 @@
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_vimcmd_identifier
|
||||||
|
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2")
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))
|
||||||
|
|
||||||
|
; NOTE: Matches *exactly* `ffi.cdef`
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_cdef_identifier
|
||||||
|
(#eq? @_cdef_identifier "ffi.cdef")
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "c")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_ts_query_identifier
|
||||||
|
(#any-of? @_ts_query_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "query")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_vimcmd_identifier
|
||||||
|
(#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(table
|
||||||
|
(table_pair
|
||||||
|
key:
|
||||||
|
(string
|
||||||
|
(string_content) @_command
|
||||||
|
(#eq? @_command "command"))
|
||||||
|
value:
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_user_cmd
|
||||||
|
(#eq? @_user_cmd "vim.api.nvim_create_user_command")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_user_cmd
|
||||||
|
(#eq? @_user_cmd "vim.api.nvim_buf_create_user_command")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_map
|
||||||
|
(#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_map
|
||||||
|
(#eq? @_map "vim.api.nvim_buf_set_keymap")
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "vim")))
|
||||||
|
|
||||||
|
; highlight string as query if starts with `; query`
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#lua-match? @injection.content "^%s*;+%s?query")
|
||||||
|
(#set! injection.language "query"))
|
||||||
|
|
||||||
|
; ──────────────────────────────────────────────────────────────────────
|
||||||
|
; (string.match "123" "%d+")
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol
|
||||||
|
member: (symbol_fragment) @_func
|
||||||
|
.
|
||||||
|
(#any-of? @_func "find" "match" "gmatch" "gsub"))
|
||||||
|
.
|
||||||
|
(_)
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "luap")
|
||||||
|
(#set! injection.include-children)))
|
||||||
|
|
||||||
|
; (my-string:match "%d+")
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol_method
|
||||||
|
method: (symbol_fragment) @_method
|
||||||
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "luap")
|
||||||
|
(#set! injection.include-children)))
|
||||||
|
|
||||||
|
; (string.format "pi = %.2f" 3.14159)
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(multi_symbol) @_func
|
||||||
|
(#eq? @_func "string.format")
|
||||||
|
.
|
||||||
|
(string
|
||||||
|
(string_content) @injection.content
|
||||||
|
(#set! injection.language "printf")))
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,26 @@
|
||||||
[
|
; TODO: Add tests
|
||||||
(program)
|
; TODO: Improve queries
|
||||||
(fn)
|
(program) @local.scope
|
||||||
(lambda)
|
|
||||||
(let)
|
|
||||||
(each)
|
|
||||||
(for)
|
|
||||||
(match)
|
|
||||||
] @local.scope
|
|
||||||
|
|
||||||
((list
|
((list
|
||||||
.
|
.
|
||||||
(symbol) @_special) @local.scope
|
(symbol) @_call) @local.scope
|
||||||
(#any-of? @_special "while" "if" "when" "do" "collect" "icollect" "accumulate"))
|
(#any-of? @_call "let" "fn" "lambda" "λ" "while" "each" "for" "if" "when" "do" "collect" "icollect" "accumulate" "case" "match"))
|
||||||
|
|
||||||
(fn
|
|
||||||
name: (symbol) @local.definition.function
|
|
||||||
(#set! definition.function.scope "parent"))
|
|
||||||
|
|
||||||
(lambda
|
|
||||||
name: (symbol) @local.definition.function
|
|
||||||
(#set! definition.function.scope "parent"))
|
|
||||||
|
|
||||||
; TODO: use @local.definition.parameter for parameters
|
|
||||||
(binding
|
|
||||||
(symbol) @local.definition.var)
|
|
||||||
|
|
||||||
(for_clause
|
|
||||||
.
|
|
||||||
(symbol) @local.definition.var)
|
|
||||||
|
|
||||||
(symbol) @local.reference
|
(symbol) @local.reference
|
||||||
|
|
||||||
|
(list
|
||||||
|
.
|
||||||
|
(symbol) @_fn
|
||||||
|
(#any-of? @_fn "fn" "lambda" "λ")
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(symbol) @local.definition.function
|
||||||
|
(multi_symbol
|
||||||
|
member: (symbol_fragment) @local.definition.function .)
|
||||||
|
]
|
||||||
|
(#set! definition.function.scope "parent")
|
||||||
|
.
|
||||||
|
(sequence
|
||||||
|
(symbol)* @local.definition.parameter
|
||||||
|
(#not-contains? @local.definition.parameter "&")))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue