diff --git a/queries/highlights.scm b/queries/highlights.scm index 38b556f..37602c6 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -1,6 +1,24 @@ -(identifier) @variable +;; Function related +(function_declaration name: (_) @function (#set! "priority" 101)) +(call_expression function: (identifier) @function (#set! "priority" 101)) +(parameters (identifier) @parameter (#set! "priority" 101)) +(default_parameter (identifier) @parameter (#set! "priority" 101)) + +;; Command command + +(command) @string + +(command_attribute + name: _ @property + val: (behavior + name: _ @constant (#set! "priority" 101) + val: (identifier)? @function (#set! "priority" 101))?) + + ((identifier) @constant - (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + (#match? @constant "^[A-Z][A-Z_0-9]*$") + (#set! "priority" 101)) +(identifier) @variable ;; Keywords @@ -34,12 +52,6 @@ "endfunction" ] @keyword.function -;; Function related -(function_declaration name: (_) @function) -(call_expression function: (identifier) @function) -(parameters (identifier) @parameter) -(default_parameter (identifier) @parameter) - [ (bang) (spread) ] @punctuation.special [ (no_option) (inv_option) (default_option) (option_name) ] @variable.builtin @@ -163,16 +175,6 @@ "clear" ] @keyword) -;; Command command - -(command) @string - -(command_attribute - name: _ @property - val: (behavior - name: _ @constant - val: (identifier)? @function)?) - ;; Edit command (plus_plus_opt val: _? @constant) @property diff --git a/test/highlight/commands.vim b/test/highlight/commands.vim index 4b6974b..77565f6 100644 --- a/test/highlight/commands.vim +++ b/test/highlight/commands.vim @@ -104,10 +104,41 @@ command -buffer -bar -bang -keepscript -register UserCommand echo " ^ function.macro " ^ string -" command UserCommand call Test() +command UserCommand call Test() +" <- keyword +" ^^^^^^^^^^^ function.macro +" ^^^^^^^^^^^ string -" command -complete=syntax ToggleSyntax if exists("g:syntax_on") | syntax off | else | syntax enable | endif +command -complete=syntax ToggleSyntax if exists("g:syntax_on") | syntax off | else | syntax enable | endif +" <- keyword +" ^^^^^^^^^ property +" ^ operator +" ^^^^^^ constant +" ^^^^^^^^^^^^ function.macro +" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string -" command -nargs=1 -complete=mapping Show echo "this is an error message" +command -nargs=1 -complete=mapping Show echo "this is an error message" +" <- keyword +" ^^^^^^ property +" ^ operator +" ^ number +" ^^^^^^^^^ property +" ^ operator +" ^^^^^^^ constant +" ^^^^ function.macro +" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string -" com -complete=custom,funcName -buffer -addr=tabs -bang ShowFunc execute "echo 'this is another error message'" +com -complete=custom,funcName -buffer -addr=tabs -bang ShowFunc execute "echo 'this is another error message'" +" <- keyword +" ^^^^^^^^^ property +" ^ operator +" ^^^^^^ constant +" ^ punctuation.delimiter +" ^^^^^^^^ function +" ^^^^^^^ property +" ^^^^^ property +" ^ operator +" ^^^^ constant +" ^^^^^ property +" ^^^^^^^^ function.macro +" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string diff --git a/test/highlight/eval.vim b/test/highlight/eval.vim index 12c6e31..fe98cb0 100644 --- a/test/highlight/eval.vim +++ b/test/highlight/eval.vim @@ -2,7 +2,15 @@ eval append(foo, 0) " <- keyword +" ^^^^^^ function " ^ punctuation.bracket " ^^^ variable " ^ number " ^ punctuation.bracket + +call Of(DUTY) +" <- keyword +" ^^ function +" ^ punctuation.bracket +" ^^^^ constant +" ^ punctuation.bracket