|
| 1 | +;; highlight queries. |
| 2 | +;; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries |
| 3 | +;; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations |
| 4 | +;; for a list of recommended @ tags, though not all of them have matching |
| 5 | +;; highlights in neovim. |
| 6 | + |
| 7 | +[ |
| 8 | + "abort" |
| 9 | + "abs" |
| 10 | + "abstract" |
| 11 | + "accept" |
| 12 | + "access" |
| 13 | + "all" |
| 14 | + "array" |
| 15 | + "at" |
| 16 | + "begin" |
| 17 | + "declare" |
| 18 | + "delay" |
| 19 | + "delta" |
| 20 | + "digits" |
| 21 | + "do" |
| 22 | + "end" |
| 23 | + "entry" |
| 24 | + "exit" |
| 25 | + "generic" |
| 26 | + "interface" |
| 27 | + "is" |
| 28 | + "limited" |
| 29 | + "null" |
| 30 | + "of" |
| 31 | + "others" |
| 32 | + "out" |
| 33 | + "pragma" |
| 34 | + "private" |
| 35 | + "range" |
| 36 | + "synchronized" |
| 37 | + "tagged" |
| 38 | + "task" |
| 39 | + "terminate" |
| 40 | + "until" |
| 41 | + "when" |
| 42 | +] @keyword |
| 43 | +[ |
| 44 | + "aliased" |
| 45 | + "constant" |
| 46 | + "renames" |
| 47 | +] @storageclass |
| 48 | +[ |
| 49 | + "mod" |
| 50 | + "new" |
| 51 | + "protected" |
| 52 | + "record" |
| 53 | + "subtype" |
| 54 | + "type" |
| 55 | +] @keyword.type |
| 56 | +[ |
| 57 | + "with" |
| 58 | + "use" |
| 59 | +] @include |
| 60 | +[ |
| 61 | + "body" |
| 62 | + "function" |
| 63 | + "overriding" |
| 64 | + "procedure" |
| 65 | + "package" |
| 66 | + "separate" |
| 67 | +] @keyword.function |
| 68 | +[ |
| 69 | + "and" |
| 70 | + "in" |
| 71 | + "not" |
| 72 | + "or" |
| 73 | + "xor" |
| 74 | +] @keyword.operator |
| 75 | +[ |
| 76 | + "while" |
| 77 | + "loop" |
| 78 | + "for" |
| 79 | + "parallel" |
| 80 | + "reverse" |
| 81 | + "some" |
| 82 | +] @repeat |
| 83 | +[ |
| 84 | + "return" |
| 85 | +] @keyword.return |
| 86 | +[ |
| 87 | + "case" |
| 88 | + "if" |
| 89 | + "else" |
| 90 | + "then" |
| 91 | + "elsif" |
| 92 | + "select" |
| 93 | +] @conditional |
| 94 | +[ |
| 95 | + "exception" |
| 96 | + "raise" |
| 97 | +] @exception |
| 98 | +(comment) @comment |
| 99 | +(comment) @spell ;; spell-check comments |
| 100 | +(string_literal) @string |
| 101 | +(string_literal) @spell ;; spell-check strings |
| 102 | +(character_literal) @string |
| 103 | +(numeric_literal) @number |
| 104 | + |
| 105 | +;; Highlight the name of subprograms |
| 106 | +(procedure_specification name: (_) @function) |
| 107 | +(function_specification name: (_) @function) |
| 108 | +(package_declaration name: (_) @function) |
| 109 | +(package_body name: (_) @function) |
| 110 | +(generic_instantiation name: (_) @function) |
| 111 | +(entry_declaration . (identifier) @function) |
| 112 | + |
| 113 | +;; Some keywords should take different categories depending on the context |
| 114 | +(use_clause "use" @include "type" @include) |
| 115 | +(with_clause "private" @include) |
| 116 | +(with_clause "limited" @include) |
| 117 | +(use_clause (_) @namespace) |
| 118 | +(with_clause (_) @namespace) |
| 119 | + |
| 120 | +(loop_statement "end" @keyword.repeat) |
| 121 | +(if_statement "end" @conditional) |
| 122 | +(loop_parameter_specification "in" @keyword.repeat) |
| 123 | +(loop_parameter_specification "in" @keyword.repeat) |
| 124 | +(iterator_specification ["in" "of"] @keyword.repeat) |
| 125 | +(range_attribute_designator "range" @keyword.repeat) |
| 126 | + |
| 127 | +(raise_statement "with" @exception) |
| 128 | + |
| 129 | +(gnatprep_declarative_if_statement) @preproc |
| 130 | +(gnatprep_if_statement) @preproc |
| 131 | +(gnatprep_identifier) @preproc |
| 132 | + |
| 133 | +(subprogram_declaration "is" @keyword.function "abstract" @keyword.function) |
| 134 | +(aspect_specification "with" @keyword.function) |
| 135 | + |
| 136 | +(full_type_declaration "is" @keyword.type) |
| 137 | +(subtype_declaration "is" @keyword.type) |
| 138 | +(record_definition "end" @keyword.type) |
| 139 | +(full_type_declaration (_ "access" @keyword.type)) |
| 140 | +(array_type_definition "array" @keyword.type "of" @keyword.type) |
| 141 | +(access_to_object_definition "access" @keyword.type) |
| 142 | +(access_to_object_definition "access" @keyword.type |
| 143 | + [ |
| 144 | + (general_access_modifier "constant" @keyword.type) |
| 145 | + (general_access_modifier "all" @keyword.type) |
| 146 | + ] |
| 147 | +) |
| 148 | +(range_constraint "range" @keyword.type) |
| 149 | +(signed_integer_type_definition "range" @keyword.type) |
| 150 | +(index_subtype_definition "range" @keyword.type) |
| 151 | +(record_type_definition "abstract" @keyword.type) |
| 152 | +(record_type_definition "tagged" @keyword.type) |
| 153 | +(record_type_definition "limited" @keyword.type) |
| 154 | +(record_type_definition (record_definition "null" @keyword.type)) |
| 155 | +(private_type_declaration "is" @keyword.type "private" @keyword.type) |
| 156 | +(private_type_declaration "tagged" @keyword.type) |
| 157 | +(private_type_declaration "limited" @keyword.type) |
| 158 | +(task_type_declaration "task" @keyword.type "is" @keyword.type) |
| 159 | + |
| 160 | +;; Gray the body of expression functions |
| 161 | +(expression_function_declaration |
| 162 | + (function_specification) |
| 163 | + "is" |
| 164 | + (_) @attribute |
| 165 | +) |
| 166 | +(subprogram_declaration (aspect_specification) @attribute) |
| 167 | + |
| 168 | +;; Highlight full subprogram specifications |
| 169 | +;(subprogram_body |
| 170 | +; [ |
| 171 | +; (procedure_specification) |
| 172 | +; (function_specification) |
| 173 | +; ] @function.spec |
| 174 | +;) |
| 175 | + |
| 176 | +;; Highlight errors in red. This is not very useful in practice, as text will |
| 177 | +;; be highlighted as user types, and the error could be elsewhere in the code. |
| 178 | +;; This also requires defining :hi @error guifg=Red for instance. |
| 179 | +(ERROR) @error |
| 180 | + |
0 commit comments