forked from helix-editor/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding initial support for ada language, based off helix-editor#7790 …
…PR from tomekw
- Loading branch information
Showing
5 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; Support for folding in Ada | ||
;; za toggles folding a package, subprogram, if statement or loop | ||
|
||
[ | ||
(package_declaration) | ||
(generic_package_declaration) | ||
(package_body) | ||
(subprogram_declaration) | ||
(subprogram_body) | ||
(block_statement) | ||
(if_statement) | ||
(loop_statement) | ||
(gnatprep_declarative_if_statement) | ||
(gnatprep_if_statement) | ||
] @fold |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
;; highlight queries. | ||
;; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries | ||
;; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations | ||
;; for a list of recommended @ tags, though not all of them have matching | ||
;; highlights in neovim. | ||
|
||
[ | ||
"abort" | ||
"abs" | ||
"abstract" | ||
"accept" | ||
"access" | ||
"all" | ||
"array" | ||
"at" | ||
"begin" | ||
"declare" | ||
"delay" | ||
"delta" | ||
"digits" | ||
"do" | ||
"end" | ||
"entry" | ||
"exit" | ||
"generic" | ||
"interface" | ||
"is" | ||
"limited" | ||
"of" | ||
"others" | ||
"out" | ||
"pragma" | ||
"private" | ||
"range" | ||
"synchronized" | ||
"tagged" | ||
"task" | ||
"terminate" | ||
"until" | ||
"when" | ||
] @keyword | ||
[ | ||
"null" | ||
] @constant.builtin | ||
[ | ||
"aliased" | ||
"constant" | ||
"renames" | ||
] @storageclass | ||
[ | ||
"mod" | ||
"new" | ||
"protected" | ||
"record" | ||
"subtype" | ||
"type" | ||
] @type | ||
[ | ||
"with" | ||
"use" | ||
] @keyword.control.import | ||
[ | ||
"body" | ||
"function" | ||
"overriding" | ||
"procedure" | ||
"package" | ||
"separate" | ||
] @keyword.function | ||
[ | ||
"and" | ||
"in" | ||
"not" | ||
"or" | ||
"xor" | ||
] @operator | ||
[ | ||
"while" | ||
"loop" | ||
"for" | ||
"parallel" | ||
"reverse" | ||
"some" | ||
] @kewyord.control.repeat | ||
[ | ||
"return" | ||
] @keyword.control.return | ||
[ | ||
"case" | ||
"if" | ||
"else" | ||
"then" | ||
"elsif" | ||
"select" | ||
] @keyword.control.conditional | ||
[ | ||
"exception" | ||
"raise" | ||
] @keyword.control.exception | ||
(comment) @comment | ||
(comment) @spell ;; spell-check comments | ||
(string_literal) @string | ||
(string_literal) @spell ;; spell-check strings | ||
(character_literal) @string | ||
(numeric_literal) @constant.numeric | ||
|
||
;; Highlight the name of subprograms | ||
(procedure_specification name: (_) @function.builtin) | ||
(function_specification name: (_) @function.builtin) | ||
(package_declaration name: (_) @function.builtin) | ||
(package_body name: (_) @function.builtin) | ||
(generic_instantiation name: (_) @function.builtin) | ||
(entry_declaration . (identifier) @function.builtin) | ||
|
||
;; Some keywords should take different categories depending on the context | ||
(use_clause "use" @keyword.control.import "type" @keyword.control.import) | ||
(with_clause "private" @keyword.control.import) | ||
(with_clause "limited" @keyword.control.import) | ||
(use_clause (_) @namespace) | ||
(with_clause (_) @namespace) | ||
|
||
(loop_statement "end" @keyword.control.repeat) | ||
(if_statement "end" @keyword.control.conditional) | ||
(loop_parameter_specification "in" @keyword.control.repeat) | ||
(loop_parameter_specification "in" @keyword.control.repeat) | ||
(iterator_specification ["in" "of"] @keyword.control.repeat) | ||
(range_attribute_designator "range" @keyword.control.repeat) | ||
|
||
(raise_statement "with" @keyword.control.exception) | ||
|
||
(gnatprep_declarative_if_statement) @preproc | ||
(gnatprep_if_statement) @preproc | ||
(gnatprep_identifier) @preproc | ||
|
||
(subprogram_declaration "is" @keyword.function "abstract" @keyword.function) | ||
(aspect_specification "with" @keyword.function) | ||
|
||
(full_type_declaration "is" @type) | ||
(subtype_declaration "is" @type) | ||
(record_definition "end" @type) | ||
(full_type_declaration (_ "access" @type)) | ||
(array_type_definition "array" @type "of" @type) | ||
(access_to_object_definition "access" @type) | ||
(access_to_object_definition "access" @type | ||
[ | ||
(general_access_modifier "constant" @type) | ||
(general_access_modifier "all" @type) | ||
] | ||
) | ||
(range_constraint "range" @type) | ||
(signed_integer_type_definition "range" @type) | ||
(index_subtype_definition "range" @type) | ||
(record_type_definition "abstract" @type) | ||
(record_type_definition "tagged" @type) | ||
(record_type_definition "limited" @type) | ||
(record_type_definition (record_definition "null" @type)) | ||
(private_type_declaration "is" @type "private" @type) | ||
(private_type_declaration "tagged" @type) | ||
(private_type_declaration "limited" @type) | ||
(task_type_declaration "task" @type "is" @type) | ||
|
||
;; Gray the body of expression functions | ||
(expression_function_declaration | ||
(function_specification) | ||
"is" | ||
(_) @attribute | ||
) | ||
(subprogram_declaration (aspect_specification) @attribute) | ||
|
||
;; Highlight full subprogram specifications | ||
;(subprogram_body | ||
; [ | ||
; (procedure_specification) | ||
; (function_specification) | ||
; ] @function.builtin.spec | ||
;) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
;; Better highlighting by referencing to the definition, for variable | ||
;; references. However, this is not yet supported by neovim | ||
;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables | ||
|
||
(compilation) @scope | ||
(package_declaration) @scope | ||
(package_body) @scope | ||
(subprogram_declaration) @scope | ||
(subprogram_body) @scope | ||
(block_statement) @scope | ||
|
||
(with_clause (_) @definition.import) | ||
(procedure_specification name: (_) @definition.function) | ||
(function_specification name: (_) @definition.function) | ||
(package_declaration name: (_) @definition.var) | ||
(package_body name: (_) @definition.var) | ||
(generic_instantiation . name: (_) @definition.var) | ||
(component_declaration . (identifier) @definition.var) | ||
(exception_declaration . (identifier) @definition.var) | ||
(formal_object_declaration . (identifier) @definition.var) | ||
(object_declaration . (identifier) @definition.var) | ||
(parameter_specification . (identifier) @definition.var) | ||
(full_type_declaration . (identifier) @definition.type) | ||
(private_type_declaration . (identifier) @definition.type) | ||
(private_extension_declaration . (identifier) @definition.type) | ||
(incomplete_type_declaration . (identifier) @definition.type) | ||
(protected_type_declaration . (identifier) @definition.type) | ||
(formal_complete_type_declaration . (identifier) @definition.type) | ||
(formal_incomplete_type_declaration . (identifier) @definition.type) | ||
(task_type_declaration . (identifier) @definition.type) | ||
(subtype_declaration . (identifier) @definition.type) | ||
|
||
(identifier) @reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
;; Support for high-level text objects selections. | ||
;; For instance: | ||
;; vaf (v)isually select (a) (f)unction or subprogram | ||
;; vif (v)isually select (i)nside a (f)unction or subprogram | ||
;; vai (v)isually select (a) (i)f statement (or loop) | ||
;; vii (v)isually select (i)nside an (i)f statement (or loop) | ||
;; | ||
;; https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/master/README.md | ||
|
||
(subprogram_body) @function.outer | ||
(subprogram_body (non_empty_declarative_part) @function.inner) | ||
(subprogram_body (handled_sequence_of_statements) @function.inner) | ||
(function_specification) @function.outer | ||
(procedure_specification) @function.outer | ||
(package_declaration) @function.outer | ||
(generic_package_declaration) @function.outer | ||
(package_body) @function.outer | ||
(if_statement) @block.outer | ||
(if_statement statements: (_) @block.inner) | ||
(if_statement else_statements: (_) @block.inner) | ||
(elsif_statement_item statements: (_) @block.inner) | ||
(loop_statement) @block.outer | ||
(loop_statement statements: (_) @block.inner) |