55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
|
# Detection
|
||
|
# ‾‾‾‾‾‾‾‾‾
|
||
|
|
||
|
hook global BufCreate .*[.](jq) %{
|
||
|
set-option buffer filetype jq
|
||
|
set-option buffer comment_line '#'
|
||
|
set-option buffer extra_word_chars '$' '_'
|
||
|
}
|
||
|
|
||
|
# Initialization
|
||
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||
|
|
||
|
hook global WinSetOption filetype=jq %{
|
||
|
require-module jq
|
||
|
|
||
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window jq-.+ }
|
||
|
}
|
||
|
|
||
|
hook -group jq-highlight global WinSetOption filetype=jq %{
|
||
|
add-highlighter window/jq ref jq
|
||
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/jq }
|
||
|
}
|
||
|
|
||
|
|
||
|
provide-module jq %(
|
||
|
|
||
|
# Highlighters
|
||
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||
|
|
||
|
add-highlighter shared/jq regions
|
||
|
add-highlighter shared/jq/code default-region group
|
||
|
add-highlighter shared/jq/string region '"' (?<!\\)(\\\\)*" fill string
|
||
|
|
||
|
add-highlighter shared/jq/comment_line region '#' $ fill comment
|
||
|
|
||
|
add-highlighter shared/jq/code/ regex \b([a-zA-Z_]\w*): 1:string
|
||
|
add-highlighter shared/jq/code/ regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?)\b 0:value
|
||
|
add-highlighter shared/jq/code/ regex \b(dev)\s+([a-zA-Z_]+)\b.*?:\s*(\w*) 1:keyword 2:attribute 3:attribute
|
||
|
|
||
|
add-highlighter shared/jq/code/ regex (?:\|\s*(?:if|try|else|catch|elif)|then|\[|\||[\x28])\s*([a-zA-Z_]\w*) 1:attribute
|
||
|
add-highlighter shared/jq/code/ regex \b([a-zA-Z_]\w*)\s*[\x28] 1:attribute
|
||
|
add-highlighter shared/jq/code/ regex \$\w* 0:variable
|
||
|
add-highlighter shared/jq/code/ regex \.(\w+) 1:value
|
||
|
add-highlighter shared/jq/code/ regex \b(if|elif|else|then|end|as|try|catch|and|or)\b 1:keyword
|
||
|
|
||
|
# Commands
|
||
|
# ‾‾‾‾‾‾‾‾
|
||
|
|
||
|
define-command -hidden jq-trim-indent %{
|
||
|
# remove trailing white spaces
|
||
|
try %{ execute-keys -draft -itersel x s \h+$ <ret> d }
|
||
|
}
|
||
|
|
||
|
)
|