mirror of
https://github.com/nvim-treesitter/nvim-treesitter
synced 2024-09-16 14:34:05 +02:00
Fixup format (#5934)
* fix(format): newline between top-level field defs * fixup: newline between node and comment * fixup: optimize pattern
This commit is contained in:
parent
f5a839d1e8
commit
d198a75e2c
35 changed files with 47 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
(initializer_list)
|
||||
(init_declarator)
|
||||
] @indent.begin
|
||||
|
||||
; With current indent logic, if we capture expression_statement with @indent.begin
|
||||
; It will be affected by _parent_ node with error subnodes deep down the tree
|
||||
; So narrow indent capture to check for error inside expression statement only,
|
||||
|
|
|
@ -4,7 +4,9 @@ body:
|
|||
(switch_body)
|
||||
(enum_member_declaration_list)
|
||||
] @fold
|
||||
|
||||
accessors: (accessor_list) @fold
|
||||
|
||||
initializer: (initializer_expression) @fold
|
||||
|
||||
(block) @fold
|
||||
|
|
|
@ -331,6 +331,7 @@
|
|||
"seq-to-map-for-destructuring" "update-keys" "update-vals"
|
||||
;; 1.12
|
||||
"partitionv" "partitionv-all" "splitv-at"))
|
||||
|
||||
; >> Context based highlighting
|
||||
; def-likes
|
||||
; Correctly highlight docstrings
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(sym_lit) @variable
|
||||
|
||||
; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp
|
||||
;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin))
|
||||
;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(dotted_identifier_list) @string
|
||||
|
||||
; Methods
|
||||
; --------------------
|
||||
(super) @function
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
"<%%="
|
||||
"<%="
|
||||
] @tag.delimiter
|
||||
|
||||
; EEx comments are highlighted as such
|
||||
(comment) @comment @spell
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
(_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))))
|
||||
]
|
||||
operator: "=")
|
||||
|
||||
; Stab Clause Definitions
|
||||
; format-ignore
|
||||
(stab_clause
|
||||
|
@ -98,6 +99,7 @@
|
|||
])
|
||||
operator: "when")
|
||||
])
|
||||
|
||||
; Aliases
|
||||
; format-ignore
|
||||
(call
|
||||
|
@ -155,6 +157,7 @@
|
|||
]))
|
||||
]?)
|
||||
(#set! definition.function.scope parent)(do_block)?) @local.scope
|
||||
|
||||
; ExUnit Test Definitions & Scopes
|
||||
; format-ignore
|
||||
(call
|
||||
|
@ -193,5 +196,6 @@
|
|||
])
|
||||
])
|
||||
(do_block)?) @local.scope
|
||||
|
||||
; Stab Clause Scopes
|
||||
(stab_clause) @local.scope
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
(lambda)
|
||||
(constructor_definition)
|
||||
] @fold
|
||||
|
||||
; It's nice to be able to fold the if/elif/else clauses and the entire
|
||||
; if_statement.
|
||||
(if_statement
|
||||
|
|
|
@ -304,6 +304,7 @@
|
|||
"Color8" "assert" "char" "convert" "dict_to_inst" "get_stack" "inst_to_dict"
|
||||
"is_instance_of" "len" "print_debug" "print_stack" "range"
|
||||
"type_exists"))
|
||||
|
||||
; Builtin Constants
|
||||
((identifier) @constant.builtin
|
||||
; format-ignore
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(tag_name) @tag
|
||||
|
||||
; (erroneous_end_tag_name) @error ; we do not lint syntax errors
|
||||
(comment) @comment @spell
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
(element
|
||||
(self_closing_tag))
|
||||
] @indent.begin
|
||||
|
||||
; These tags are usually written one-lined and doesn't use self-closing tags so special-cased them
|
||||
; but add indent to the tag to make sure attributes inside them are still indented if written multi-lined
|
||||
((start_tag
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; <style>...</style>
|
||||
; <style blocking> ...</style>
|
||||
; Add "lang" to predicate check so that vue/svelte can inherit this
|
||||
|
|
|
@ -249,6 +249,7 @@
|
|||
"y0"
|
||||
"y1"
|
||||
"yn"))
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"def"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; test(val)
|
||||
(query
|
||||
((funcname) @_function
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
(multiline_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; There are 3 ways to define a regex
|
||||
; - "[abc]?".toRegex()
|
||||
(call_expression
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
(items_block)
|
||||
(block)
|
||||
] @indent.begin
|
||||
|
||||
; if "if" statement and conditional statement are in separate lines
|
||||
; conditional should be indented and when the conditional block
|
||||
; starts dedented
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"default"
|
||||
(arith_cmp_predicate)
|
||||
] @keyword
|
||||
|
||||
; format-ignore
|
||||
[
|
||||
"module"
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
; primops, `__<tab>` in `nix repl`
|
||||
"__add" "__filter" "__isFunction" "__split" "__addErrorContext" "__filterSource" "__isInt" "__splitVersion" "__all" "__findFile" "__isList" "__storeDir" "__any" "__floor" "__isPath" "__storePath" "__appendContext" "__foldl'" "__isString" "__stringLength" "__attrNames" "__fromJSON" "__langVersion" "__sub" "__attrValues" "__functionArgs" "__length" "__substring" "__bitAnd" "__genList" "__lessThan" "__tail" "__bitOr" "__genericClosure" "__listToAttrs" "__toFile" "__bitXor" "__getAttr" "__mapAttrs" "__toJSON" "__catAttrs" "__getContext" "__match" "__toPath" "__ceil" "__getEnv" "__mul" "__toXML" "__compareVersions" "__getFlake" "__nixPath" "__trace" "__concatLists" "__groupBy" "__nixVersion" "__traceVerbose" "__concatMap" "__hasAttr" "__parseDrvName" "__tryEval" "__concatStringsSep" "__hasContext" "__partition" "__typeOf" "__currentSystem" "__hashFile" "__path" "__unsafeDiscardOutputDependency" "__currentTime" "__hashString" "__pathExists" "__unsafeDiscardStringContext" "__deepSeq" "__head" "__readDir" "__unsafeGetAttrPos" "__div" "__intersectAttrs" "__readFile" "__zipAttrsWith" "__elem" "__isAttrs" "__replaceStrings" "__elemAt" "__isBool" "__seq" "__fetchurl" "__isFloat" "__sort")
|
||||
)
|
||||
|
||||
; constants
|
||||
(variable_expression
|
||||
name: (identifier) @constant.builtin
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; There is no parser for assembly language yet. Add an injection here when we
|
||||
; have a parser.
|
||||
; ((asmBody) @injection.content
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
(assignment
|
||||
alias: (field) @variable.member)
|
||||
|
||||
alias: (identifier) @variable.member
|
||||
|
||||
(comment) @comment @spell
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
((doctest_block) @injection.content
|
||||
(#set! injection.language "python"))
|
||||
|
||||
; Directives with nested content without arguments nor options
|
||||
((directive
|
||||
name: (type) @_type
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(host_declaration)
|
||||
(match_declaration)
|
||||
] @indent.begin
|
||||
|
||||
; incomplete declarations
|
||||
(ERROR
|
||||
.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
":"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
; TODO: "\\(" ")" in interpolations should be @punctuation.special
|
||||
[
|
||||
"\\("
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(block) @local.scope
|
||||
|
||||
; Parameter definitions
|
||||
(parameter_declaration
|
||||
command: (identifier)
|
||||
|
|
|
@ -13,4 +13,5 @@
|
|||
(class_type)
|
||||
(method_declaration)
|
||||
] @fold
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
|
@ -165,6 +165,7 @@
|
|||
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin "eprint" "eprintln" "error" "exit" "panic" "print" "println" "after" "after_char" "all" "all_after" "all_after_last" "all_before" "all_before_last" "any" "ascii_str" "before" "bool" "byte" "byterune" "bytes" "bytestr" "c_error_number_str" "capitalize" "clear" "clone" "clone_to_depth" "close" "code" "compare" "compare_strings" "contains" "contains_any" "contains_any_substr" "copy" "count" "cstring_to_vstring" "delete" "delete_last" "delete_many" "ends_with" "eprint" "eprintln" "eq_epsilon" "error" "error_with_code" "exit" "f32" "f32_abs" "f32_max" "f32_min" "f64" "f64_max" "fields" "filter" "find_between" "first" "flush_stderr" "flush_stdout" "free" "gc_check_leaks" "get_str_intp_u32_format" "get_str_intp_u64_format" "grow_cap" "grow_len" "hash" "hex" "hex2" "hex_full" "i16" "i64" "i8" "index" "index_after" "index_any" "index_byte" "insert" "int" "is_alnum" "is_bin_digit" "is_capital" "is_digit" "is_hex_digit" "is_letter" "is_lower" "is_oct_digit" "is_space" "is_title" "is_upper" "isnil" "join" "join_lines" "keys" "last" "last_index" "last_index_byte" "length_in_bytes" "limit" "malloc" "malloc_noscan" "map" "match_glob" "memdup" "memdup_noscan" "move" "msg" "panic" "panic_error_number" "panic_lasterr" "panic_optional_not_set" "parse_int" "parse_uint" "pointers" "pop" "prepend" "print" "print_backtrace" "println" "proc_pidpath" "ptr_str" "push_many" "realloc_data" "reduce" "repeat" "repeat_to_depth" "replace" "replace_each" "replace_once" "reverse" "reverse_in_place" "runes" "sort" "sort_by_len" "sort_ignore_case" "sort_with_compare" "split" "split_any" "split_into_lines" "split_nth" "starts_with" "starts_with_capital" "str" "str_escaped" "str_intp" "str_intp_g32" "str_intp_g64" "str_intp_rune" "str_intp_sq" "str_intp_sub" "strg" "string_from_wide" "string_from_wide2" "strip_margin" "strip_margin_custom" "strlong" "strsci" "substr" "substr_ni" "substr_with_check" "title" "to_lower" "to_upper" "to_wide" "tos" "tos2" "tos3" "tos4" "tos5" "tos_clone" "trim" "trim_left" "trim_pr" "try_pop" "try_push" "utf32_decode_to_buffer" "utf32_to_str" "utf32_to_str_no_malloc" "utf8_char_len" "utf8_getchar" "utf8_str_len" "utf8_str_visible_length" "utf8_to_utf32" "v_realloc" "vbytes" "vcalloc" "vcalloc_noscan" "vmemcmp" "vmemcpy" "vmemmove" "vmemset" "vstring" "vstring_literal" "vstring_literal_with_len" "vstring_with_len" "vstrlen" "vstrlen_char" "winapi_lasterr_str"))
|
||||
|
||||
; Operators
|
||||
[
|
||||
"++"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; asm_statement if asm ever highlighted :)
|
||||
; #include <...>
|
||||
((hash_statement) @injection.content
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((Comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; SVG style
|
||||
((element
|
||||
(STag
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; Github actions ("run") / Gitlab CI ("scripts")
|
||||
(block_mapping_pair
|
||||
key: (flow_node) @_run
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(comment) @comment @spell
|
||||
|
||||
; Module / submodule
|
||||
[
|
||||
"module"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
(json_object)
|
||||
(parenthesized_expression)
|
||||
] @indent.begin
|
||||
|
||||
; TODO: can't get this to work, goal is to indent at the property ":" prefix
|
||||
; ((list (identifier) (property)) @indent.align
|
||||
; (#set! indent.open_delimiter "(")
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
variable: (IDENTIFIER)
|
||||
variable_type_function: (IDENTIFIER)
|
||||
] @variable
|
||||
|
||||
parameter: (IDENTIFIER) @variable.parameter
|
||||
|
||||
[
|
||||
|
@ -38,8 +39,11 @@ parameter: (IDENTIFIER) @variable.parameter
|
|||
field_access: (IDENTIFIER)
|
||||
] @constant
|
||||
(#lua-match? @constant "^%u[%u%d_]+$"))
|
||||
|
||||
function: (IDENTIFIER) @function
|
||||
|
||||
function_call: (IDENTIFIER) @function.call
|
||||
|
||||
exception: "!" @keyword.exception
|
||||
|
||||
((IDENTIFIER) @variable.builtin
|
||||
|
@ -55,6 +59,7 @@ exception: "!" @keyword.exception
|
|||
])
|
||||
(ContainerField
|
||||
(IDENTIFIER) @constant))
|
||||
|
||||
field_constant: (IDENTIFIER) @constant
|
||||
|
||||
(BUILTINIDENTIFIER) @function.builtin
|
||||
|
|
|
@ -52,10 +52,7 @@ local format_queries = [[
|
|||
;; Preserve inline comments
|
||||
(program
|
||||
. (_)
|
||||
(_) @_comment
|
||||
.
|
||||
(comment) @format.prepend-newline
|
||||
(#not-has-type? @_comment comment)
|
||||
(#is-start-of-line? @format.prepend-newline))
|
||||
(program
|
||||
. (_)
|
||||
|
@ -77,7 +74,9 @@ local format_queries = [[
|
|||
(grouping)
|
||||
(named_node)
|
||||
(anonymous_node)
|
||||
(field_definition)
|
||||
] @format.prepend-newline)
|
||||
|
||||
(program
|
||||
(comment) @_comment
|
||||
.
|
||||
|
@ -86,6 +85,8 @@ local format_queries = [[
|
|||
(grouping)
|
||||
(named_node)
|
||||
(anonymous_node)
|
||||
(field_definition)
|
||||
(comment)
|
||||
] @format.cancel-prepend
|
||||
(#is-start-of-line? @_comment))
|
||||
;; }}}
|
||||
|
|
Loading…
Reference in a new issue