mirror of
https://github.com/helix-editor/helix.git
synced 2024-09-11 18:58:00 +03:00
Add jq language support (#11393)
jq is a language for manipulating JSON data: https://jqlang.github.io/jq/
This commit is contained in:
parent
931ddbb077
commit
2f60c21727
@ -97,6 +97,7 @@
|
||||
| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| jinja | ✓ | | | |
|
||||
| jjdescription | ✓ | | | |
|
||||
| jq | ✓ | ✓ | | `jq-lsp` |
|
||||
| jsdoc | ✓ | | | |
|
||||
| json | ✓ | ✓ | ✓ | `vscode-json-language-server` |
|
||||
| json5 | ✓ | | | |
|
||||
|
@ -44,6 +44,7 @@ haskell-language-server = { command = "haskell-language-server-wrapper", args =
|
||||
idris2-lsp = { command = "idris2-lsp" }
|
||||
intelephense = { command = "intelephense", args = ["--stdio"] }
|
||||
jdtls = { command = "jdtls" }
|
||||
jq-lsp = { command = "jq-lsp" }
|
||||
jsonnet-language-server = { command = "jsonnet-language-server", args= ["-t", "--lint"] }
|
||||
julia = { command = "julia", timeout = 60, args = [ "--startup-file=no", "--history-file=no", "--quiet", "-e", "using LanguageServer; runserver()", ] }
|
||||
koka = { command = "koka", args = ["--language-server", "--lsstdio"] }
|
||||
@ -3238,6 +3239,19 @@ text-width = 72
|
||||
name = "jjdescription"
|
||||
source = { git = "https://github.com/kareigu/tree-sitter-jjdescription", rev = "2ddec6cad07b366aee276a608e1daa2c29d3caf2" }
|
||||
|
||||
[[language]]
|
||||
name = "jq"
|
||||
scope = "source.jq"
|
||||
injection-regex = "jq"
|
||||
file-types = ["jq"]
|
||||
comment-token = "#"
|
||||
language-servers = ["jq-lsp"]
|
||||
indent = { tab-width = 2, unit = " " }
|
||||
|
||||
[[grammar]]
|
||||
name = "jq"
|
||||
source = { git = "https://github.com/flurie/tree-sitter-jq", rev = "13990f530e8e6709b7978503da9bc8701d366791" }
|
||||
|
||||
[[grammar]]
|
||||
name = "wren"
|
||||
source = { git = "https://git.sr.ht/~jummit/tree-sitter-wren", rev = "6748694be32f11e7ec6b5faeb1b48ca6156d4e06" }
|
||||
|
160
runtime/queries/jq/highlights.scm
Normal file
160
runtime/queries/jq/highlights.scm
Normal file
@ -0,0 +1,160 @@
|
||||
;; From nvim-treesitter, contributed by @ObserverOfTime et al.
|
||||
|
||||
; Variables
|
||||
(variable) @variable
|
||||
|
||||
((variable) @constant.builtin
|
||||
(#eq? @constant.builtin "$ENV"))
|
||||
|
||||
((variable) @constant.builtin
|
||||
(#eq? @constant.builtin "$__loc__"))
|
||||
|
||||
; Properties
|
||||
(index
|
||||
(identifier) @variable.other.member)
|
||||
|
||||
; Labels
|
||||
(query
|
||||
label: (variable) @label)
|
||||
|
||||
(query
|
||||
break_statement: (variable) @label)
|
||||
|
||||
; Literals
|
||||
(number) @constant.numeric
|
||||
|
||||
(string) @string
|
||||
|
||||
[
|
||||
"true"
|
||||
"false"
|
||||
] @constant.builtin.boolean
|
||||
|
||||
"null" @type.builtin
|
||||
|
||||
; Interpolation
|
||||
[
|
||||
"\\("
|
||||
")"
|
||||
] @special
|
||||
|
||||
; Format
|
||||
(format) @attribute
|
||||
|
||||
; Functions
|
||||
(funcdef
|
||||
(identifier) @function)
|
||||
|
||||
(funcdefargs
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
[
|
||||
"reduce"
|
||||
"foreach"
|
||||
] @function.builtin
|
||||
|
||||
((funcname) @function
|
||||
.
|
||||
"(")
|
||||
|
||||
; jq -n 'builtins | map(split("/")[0]) | unique | .[]'
|
||||
((funcname) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"IN" "INDEX" "JOIN" "abs" "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" "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" "pick" "pow"
|
||||
"pow10" "range" "recurse" "remainder" "repeat" "reverse" "rindex" "rint" "round" "rtrimstr"
|
||||
"scalars" "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"
|
||||
] @keyword.control.import
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"elif"
|
||||
"else"
|
||||
"end"
|
||||
] @keyword.control.conditional
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
] @keyword.control.exception
|
||||
|
||||
[
|
||||
"or"
|
||||
"and"
|
||||
] @keyword.operator
|
||||
|
||||
; Operators
|
||||
[
|
||||
"."
|
||||
"=="
|
||||
"!="
|
||||
">"
|
||||
">="
|
||||
"<="
|
||||
"<"
|
||||
"="
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"//="
|
||||
"|"
|
||||
"?"
|
||||
"//"
|
||||
"?//"
|
||||
(recurse) ; ".."
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
";"
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Comments
|
||||
(comment) @comment.line
|
25
runtime/queries/jq/injections.scm
Normal file
25
runtime/queries/jq/injections.scm
Normal file
@ -0,0 +1,25 @@
|
||||
;; From nvim-treesitter, contributed by @ObserverOfTime et al.
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; test(val)
|
||||
(query
|
||||
((funcname) @_function
|
||||
(#any-of? @_function "test" "match" "capture" "scan" "split" "splits" "sub" "gsub"))
|
||||
(args
|
||||
.
|
||||
(query
|
||||
(string) @injection.content
|
||||
(#set! injection.language "regex"))))
|
||||
|
||||
; test(regex; flags)
|
||||
(query
|
||||
((funcname) @_function
|
||||
(#any-of? @_function "test" "match" "capture" "scan" "split" "splits" "sub" "gsub"))
|
||||
(args
|
||||
.
|
||||
(args
|
||||
(query
|
||||
(string) @injection.content
|
||||
(#set! injection.language "regex")))))
|
12
runtime/queries/jq/locals.scm
Normal file
12
runtime/queries/jq/locals.scm
Normal file
@ -0,0 +1,12 @@
|
||||
;; From nvim-treesitter, contributed by @ObserverOfTime et al.
|
||||
|
||||
(funcdef
|
||||
(identifier) @local.definition)
|
||||
|
||||
(funcdefargs
|
||||
(identifier) @local.definition)
|
||||
|
||||
(funcname) @local.reference
|
||||
|
||||
(index
|
||||
(identifier) @local.reference)
|
8
runtime/queries/jq/textobjects.scm
Normal file
8
runtime/queries/jq/textobjects.scm
Normal file
@ -0,0 +1,8 @@
|
||||
(comment) @comment.inside
|
||||
(comment)+ @comment.around
|
||||
|
||||
(funcdef
|
||||
(query) @function.inside) @function.around
|
||||
|
||||
(objectkeyval
|
||||
(_) @entry.inside) @entry.around
|
Loading…
Reference in New Issue
Block a user