feat(format): extra newline after modeline

This commit is contained in:
Phạm Huy Hoàng 2024-02-19 00:00:07 +09:00 committed by 再生花
parent 84daea50b1
commit 62b0bb4f24
54 changed files with 69 additions and 1 deletions

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
(identifier) @variable (identifier) @variable
(pipe_operator) @operator (pipe_operator) @operator

View file

@ -1,4 +1,5 @@
; inherits: soql ; inherits: soql
; Apex + SOQL ; Apex + SOQL
[ [
"[" "["

View file

@ -1,4 +1,5 @@
; inherits: cpp ; inherits: cpp
((identifier) @function.builtin ((identifier) @function.builtin
(#any-of? @function.builtin (#any-of? @function.builtin
; Digital I/O ; Digital I/O

View file

@ -1,4 +1,5 @@
; inherits: html ; inherits: html
"---" @punctuation.delimiter "---" @punctuation.delimiter
[ [

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
(frontmatter (frontmatter
(raw_text) @injection.content (raw_text) @injection.content
(#set! injection.language "typescript")) (#set! injection.language "typescript"))

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
(for_range_loop) (for_range_loop)
(class_specifier) (class_specifier)

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
((identifier) @variable.member ((identifier) @variable.member
(#lua-match? @variable.member "^m_.*$")) (#lua-match? @variable.member "^m_.*$"))

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
(condition_clause) @indent.begin (condition_clause) @indent.begin
((field_initializer_list) @indent.begin ((field_initializer_list) @indent.begin

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
; Parameters ; Parameters
(variadic_parameter_declaration (variadic_parameter_declaration
declarator: declarator:

View file

@ -1,2 +1,3 @@
; inherits: tsv ; inherits: tsv
"," @punctuation.delimiter "," @punctuation.delimiter

View file

@ -1,4 +1,5 @@
; inherits: cpp ; inherits: cpp
[ [
"<<<" "<<<"
">>>" ">>>"

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
"in" "in"
"out" "out"

View file

@ -1,2 +1,3 @@
; inherits: json ; inherits: json
(comment) @indent.ignore (comment) @indent.ignore

View file

@ -1,4 +1,5 @@
; inherits: cpp ; inherits: cpp
[ [
"in" "in"
"out" "out"

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
(doctype) @constant (doctype) @constant
"<!" @tag.delimiter "<!" @tag.delimiter

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
(foreach_statement) (foreach_statement)
(foreach_instance_statement) (foreach_instance_statement)

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
"soa" "soa"
"task" "task"

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
((foreach_statement ((foreach_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-has-type? @_body compound_statement))

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
(reference_declarator (reference_declarator
(identifier) @local.definition.var) (identifier) @local.definition.var)

View file

@ -1,4 +1,5 @@
; inherits: ecma,jsx ; inherits: ecma,jsx
; Parameters ; Parameters
(formal_parameters (formal_parameters
(identifier) @variable.parameter) (identifier) @variable.parameter)

View file

@ -1,4 +1,5 @@
; inherits: ecma,jsx ; inherits: ecma,jsx
; Both properties are matched here. ; Both properties are matched here.
; ;
; class Foo { ; class Foo {

View file

@ -1,2 +1,3 @@
; inherits: json ; inherits: json
(comment) @comment @spell (comment) @comment @spell

View file

@ -1,2 +1,3 @@
; inherits: json ; inherits: json
(comment) @indent.ignore (comment) @indent.ignore

View file

@ -1,2 +1,3 @@
; inherits: lua ; inherits: lua
(object_type) @fold (object_type) @fold

View file

@ -1,2 +1,3 @@
; inherits: lua ; inherits: lua
(object_type) @indent.begin (object_type) @indent.begin

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
"task" "task"
"sub" "sub"

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
[ [
(class_declaration) (class_declaration)
(class_interface) (class_interface)

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
; Preprocs ; Preprocs
(preproc_undef (preproc_undef
name: (_) @constant) @keyword.directive name: (_) @constant) @keyword.directive

View file

@ -1,4 +1,5 @@
; inherits: c ; inherits: c
; TODO(amaanq): uncomment/add when I add asm support ; TODO(amaanq): uncomment/add when I add asm support
; (ms_asm_block "{" _ @asm "}") ; (ms_asm_block "{" _ @asm "}")
; ;

View file

@ -1,4 +1,5 @@
; inherits: php_only ; inherits: php_only
((text) @injection.content ((text) @injection.content
(#set! injection.language "html") (#set! injection.language "html")
(#set! injection.combined)) (#set! injection.combined))

View file

@ -1,2 +1,3 @@
; inherits: tsv ; inherits: tsv
"|" @punctuation.delimiter "|" @punctuation.delimiter

View file

@ -1,4 +1,5 @@
; inherits: css ; inherits: css
[ [
"@at-root" "@at-root"
"@debug" "@debug"

View file

@ -1,4 +1,5 @@
; inherits: css ; inherits: css
[ [
(mixin_statement) (mixin_statement)
(while_statement) (while_statement)

View file

@ -1,4 +1,5 @@
; inherits: hlsl ; inherits: hlsl
[ [
(interface_specifier) (interface_specifier)
(extension_specifier) (extension_specifier)

View file

@ -1,4 +1,5 @@
; inherits: hlsl ; inherits: hlsl
[ [
"var" "var"
"let" "let"

View file

@ -1,4 +1,5 @@
; inherits: hlsl ; inherits: hlsl
[ [
(interface_specifier) (interface_specifier)
(extension_specifier) (extension_specifier)

View file

@ -1,4 +1,5 @@
; inherits: python ; inherits: python
[ [
(rule_definition) (rule_definition)
(module_definition) (module_definition)

View file

@ -1,4 +1,5 @@
; inherits: python ; inherits: python
; Compound directives ; Compound directives
[ [
"rule" "rule"

View file

@ -1,4 +1,5 @@
; inherits: python ; inherits: python
(wildcard (wildcard
(constraint) @injection.content (constraint) @injection.content
(#set! injection.language "regex")) (#set! injection.language "regex"))

View file

@ -1,4 +1,5 @@
; inherits: html ; inherits: html
[ [
(if_statement) (if_statement)
(else_if_block) (else_if_block)

View file

@ -1,4 +1,5 @@
; inherits: html ; inherits: html
(raw_text) @none (raw_text) @none
[ [

View file

@ -1,4 +1,5 @@
; inherits: html ; inherits: html
[ [
(if_statement) (if_statement)
(each_statement) (each_statement)

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
((style_element ((style_element
(start_tag (start_tag
(attribute (attribute

View file

@ -1,4 +1,5 @@
; inherits: go ; inherits: go
(component_declaration (component_declaration
name: (component_identifier) @function) name: (component_identifier) @function)

View file

@ -1,4 +1,5 @@
; inherits: go ; inherits: go
((element_comment) @injection.content ((element_comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))

View file

@ -1,4 +1,5 @@
; inherits: hcl ; inherits: hcl
; Terraform specific references ; Terraform specific references
; ;
; ;

View file

@ -1,4 +1,5 @@
; inherits: ecma ; inherits: ecma
[ [
(interface_declaration) (interface_declaration)
(internal_module) (internal_module)

View file

@ -1,4 +1,5 @@
; inherits: ecma ; inherits: ecma
"require" @keyword.import "require" @keyword.import
(import_require_clause (import_require_clause

View file

@ -1,4 +1,5 @@
; inherits: ecma ; inherits: ecma
[ [
(enum_declaration) (enum_declaration)
(interface_declaration) (interface_declaration)

View file

@ -1,4 +1,5 @@
; inherits: ecma ; inherits: ecma
(required_parameter (required_parameter
(identifier) @local.definition) (identifier) @local.definition)

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
[ [
(directive_dynamic_argument) (directive_dynamic_argument)
(directive_dynamic_argument_value) (directive_dynamic_argument_value)

View file

@ -1,4 +1,5 @@
; inherits: html_tags ; inherits: html_tags
(template_element) @indent.begin (template_element) @indent.begin
(template_element (template_element

View file

@ -1,4 +1,5 @@
; inherits: dtd ; inherits: dtd
; XML declaration ; XML declaration
(XMLDecl (XMLDecl
"standalone" @tag.attribute) "standalone" @tag.attribute)

View file

@ -61,6 +61,19 @@ local format_queries = [[
(comment) @format.prepend-newline (comment) @format.prepend-newline
(#not-is-start-of-line? @_comment) (#not-is-start-of-line? @_comment)
(#is-start-of-line? @format.prepend-newline)) (#is-start-of-line? @format.prepend-newline))
; Extra newline for modelines
(program
(comment) @_modeline
.
(_) @format.prepend-newline
(#is-start-of-line? @_modeline)
(#contains? @_modeline "^;+%s*inherits:"))
(program
(comment) @_modeline
.
(_) @format.prepend-newline
(#is-start-of-line? @_modeline)
(#contains? @_modeline "^;+%s*extends%s*$"))
;; }}} ;; }}}
;; Making sure all top-level patterns are separated ;; Making sure all top-level patterns are separated
(program (program
@ -88,7 +101,9 @@ local format_queries = [[
(field_definition) (field_definition)
(comment) (comment)
] @format.cancel-prepend ] @format.cancel-prepend
(#is-start-of-line? @_comment)) (#is-start-of-line? @_comment)
(#not-lua-match? @_comment "^;+%s*inherits:")
(#not-lua-match? @_comment "^;+%s*extends%s*$"))
;; }}} ;; }}}
;; delims ;; delims