mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat: add jq
This commit is contained in:
parent
f5c088771b
commit
8a261e32ec
5 changed files with 371 additions and 0 deletions
|
|
@ -231,6 +231,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [http](https://github.com/rest-nvim/tree-sitter-http) (maintained by @NTBBloodbath)
|
||||
- [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f)
|
||||
- [x] [javascript](https://github.com/tree-sitter/tree-sitter-javascript) (maintained by @steelsojka)
|
||||
- [ ] [jq](https://github.com/flurie/tree-sitter-jq)
|
||||
- [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka)
|
||||
- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka)
|
||||
- [x] [json5](https://github.com/Joakker/tree-sitter-json5) (maintained by @Joakker)
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@
|
|||
"javascript": {
|
||||
"revision": "936d976a782e75395d9b1c8c7c7bf4ba6fe0d86b"
|
||||
},
|
||||
"jq": {
|
||||
"revision": "13990f530e8e6709b7978503da9bc8701d366791"
|
||||
},
|
||||
"jsdoc": {
|
||||
"revision": "189a6a4829beb9cdbe837260653b4a3dfb0cc3db"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1307,6 +1307,13 @@ list.arduino = {
|
|||
maintainers = { "@ObserverOfTime" },
|
||||
}
|
||||
|
||||
list.jq = {
|
||||
install_info = {
|
||||
url = "https://github.com/flurie/tree-sitter-jq",
|
||||
files = { "src/parser.c" },
|
||||
},
|
||||
}
|
||||
|
||||
local M = {
|
||||
list = list,
|
||||
filetype_to_parsername = filetype_to_parsername,
|
||||
|
|
|
|||
329
queries/jq/highlights.scm
Normal file
329
queries/jq/highlights.scm
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
; Variables
|
||||
|
||||
(variable) @variable
|
||||
|
||||
((variable) @constant.builtin
|
||||
(#eq? @constant.builtin "$ENV"))
|
||||
|
||||
((variable) @constant.macro
|
||||
(#eq? @constant.macro "$__loc__"))
|
||||
|
||||
; Properties
|
||||
|
||||
(index
|
||||
(identifier) @property)
|
||||
|
||||
; Labels
|
||||
|
||||
(query
|
||||
label: (variable) @label)
|
||||
|
||||
(query
|
||||
break_statement: (variable) @label)
|
||||
|
||||
; Literals
|
||||
|
||||
(number) @number
|
||||
|
||||
(string) @string
|
||||
|
||||
[
|
||||
"true"
|
||||
"false"
|
||||
] @boolean
|
||||
|
||||
("null") @type.builtin
|
||||
|
||||
; Interpolation
|
||||
|
||||
["\\(" ")"] @character.special
|
||||
|
||||
; Format
|
||||
|
||||
(format) @attribute
|
||||
|
||||
; Functions
|
||||
|
||||
(funcdef
|
||||
(identifier) @function)
|
||||
|
||||
(funcdefargs
|
||||
(identifier) @parameter)
|
||||
|
||||
[
|
||||
"reduce"
|
||||
"foreach"
|
||||
] @function.builtin
|
||||
|
||||
; jq -n 'builtins | map(split("/")[0]) | unique | .[]'
|
||||
((funcname) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"IN"
|
||||
"INDEX"
|
||||
"JOIN"
|
||||
"acos"
|
||||
"acosh"
|
||||
"add"
|
||||
"all"
|
||||
"any"
|
||||
"arrays"
|
||||
"ascii_downcase"
|
||||
"ascii_upcase"
|
||||
"asin"
|
||||
"asinh"
|
||||
"atan"
|
||||
"atan2"
|
||||
"atanh"
|
||||
"booleans"
|
||||
"bsearch"
|
||||
"builtins"
|
||||
"capture"
|
||||
"cbrt"
|
||||
"ceil"
|
||||
"combinations"
|
||||
"contains"
|
||||
"copysign"
|
||||
"cos"
|
||||
"cosh"
|
||||
"debug"
|
||||
"del"
|
||||
"delpaths"
|
||||
"drem"
|
||||
"empty"
|
||||
"endswith"
|
||||
"env"
|
||||
"erf"
|
||||
"erfc"
|
||||
"error"
|
||||
"exp"
|
||||
"exp10"
|
||||
"exp2"
|
||||
"explode"
|
||||
"expm1"
|
||||
"fabs"
|
||||
"fdim"
|
||||
"finites"
|
||||
"first"
|
||||
"flatten"
|
||||
"floor"
|
||||
"fma"
|
||||
"fmax"
|
||||
"fmin"
|
||||
"fmod"
|
||||
"format"
|
||||
"frexp"
|
||||
"from_entries"
|
||||
"fromdate"
|
||||
"fromdateiso8601"
|
||||
"fromjson"
|
||||
"fromstream"
|
||||
"gamma"
|
||||
"get_jq_origin"
|
||||
"get_prog_origin"
|
||||
"get_search_list"
|
||||
"getpath"
|
||||
"gmtime"
|
||||
"group_by"
|
||||
"gsub"
|
||||
"halt"
|
||||
"halt_error"
|
||||
"has"
|
||||
"hypot"
|
||||
"implode"
|
||||
"in"
|
||||
"index"
|
||||
"indices"
|
||||
"infinite"
|
||||
"input"
|
||||
"input_filename"
|
||||
"input_line_number"
|
||||
"inputs"
|
||||
"inside"
|
||||
"isempty"
|
||||
"isfinite"
|
||||
"isinfinite"
|
||||
"isnan"
|
||||
"isnormal"
|
||||
"iterables"
|
||||
"j0"
|
||||
"j1"
|
||||
"jn"
|
||||
"join"
|
||||
"keys"
|
||||
"keys_unsorted"
|
||||
"last"
|
||||
"ldexp"
|
||||
"leaf_paths"
|
||||
"length"
|
||||
"lgamma"
|
||||
"lgamma_r"
|
||||
"limit"
|
||||
"localtime"
|
||||
"log"
|
||||
"log10"
|
||||
"log1p"
|
||||
"log2"
|
||||
"logb"
|
||||
"ltrimstr"
|
||||
"map"
|
||||
"map_values"
|
||||
"match"
|
||||
"max"
|
||||
"max_by"
|
||||
"min"
|
||||
"min_by"
|
||||
"mktime"
|
||||
"modf"
|
||||
"modulemeta"
|
||||
"nan"
|
||||
"nearbyint"
|
||||
"nextafter"
|
||||
"nexttoward"
|
||||
"normals"
|
||||
"not"
|
||||
"now"
|
||||
"nth"
|
||||
"nulls"
|
||||
"numbers"
|
||||
"objects"
|
||||
"path"
|
||||
"paths"
|
||||
"pow"
|
||||
"pow10"
|
||||
"range"
|
||||
"recurse"
|
||||
"recurse_down"
|
||||
"remainder"
|
||||
"repeat"
|
||||
"reverse"
|
||||
"rindex"
|
||||
"rint"
|
||||
"round"
|
||||
"rtrimstr"
|
||||
"scalars"
|
||||
"scalars_or_empty"
|
||||
"scalb"
|
||||
"scalbln"
|
||||
"scan"
|
||||
"select"
|
||||
"setpath"
|
||||
"significand"
|
||||
"sin"
|
||||
"sinh"
|
||||
"sort"
|
||||
"sort_by"
|
||||
"split"
|
||||
"splits"
|
||||
"sqrt"
|
||||
"startswith"
|
||||
"stderr"
|
||||
"strflocaltime"
|
||||
"strftime"
|
||||
"strings"
|
||||
"strptime"
|
||||
"sub"
|
||||
"tan"
|
||||
"tanh"
|
||||
"test"
|
||||
"tgamma"
|
||||
"to_entries"
|
||||
"todate"
|
||||
"todateiso8601"
|
||||
"tojson"
|
||||
"tonumber"
|
||||
"tostream"
|
||||
"tostring"
|
||||
"transpose"
|
||||
"trunc"
|
||||
"truncate_stream"
|
||||
"type"
|
||||
"unique"
|
||||
"unique_by"
|
||||
"until"
|
||||
"utf8bytelength"
|
||||
"values"
|
||||
"walk"
|
||||
"while"
|
||||
"with_entries"
|
||||
"y0"
|
||||
"y1"
|
||||
"yn"))
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"def"
|
||||
"as"
|
||||
"label"
|
||||
"module"
|
||||
"break"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"import"
|
||||
"include"
|
||||
] @include
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"end"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
] @exception
|
||||
|
||||
[
|
||||
"or"
|
||||
"and"
|
||||
] @keyword.operator
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"."
|
||||
"=="
|
||||
"!="
|
||||
">"
|
||||
">="
|
||||
"<="
|
||||
"<"
|
||||
"="
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"//="
|
||||
"|"
|
||||
"?"
|
||||
"//"
|
||||
"?//"
|
||||
(recurse) ; ".."
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
|
||||
[
|
||||
";"
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"[" "]"
|
||||
"{" "}"
|
||||
"(" ")"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment @spell
|
||||
31
queries/jq/injections.scm
Normal file
31
queries/jq/injections.scm
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(comment) @comment
|
||||
|
||||
; test(val)
|
||||
(query
|
||||
((funcname) @_function
|
||||
(#any-of? @_function
|
||||
"test"
|
||||
"match"
|
||||
"capture"
|
||||
"scan"
|
||||
"split"
|
||||
"splits"
|
||||
"sub"
|
||||
"gsub"))
|
||||
(args . (query (string) @regex)))
|
||||
|
||||
|
||||
; test(regex; flags)
|
||||
(query
|
||||
((funcname) @_function
|
||||
(#any-of? @_function
|
||||
"test"
|
||||
"match"
|
||||
"capture"
|
||||
"scan"
|
||||
"split"
|
||||
"splits"
|
||||
"sub"
|
||||
"gsub"))
|
||||
(args . (args
|
||||
(query (string) @regex))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue