feat: add @comment.documentation where applicable

This commit is contained in:
Amaan Qureshi 2023-03-02 08:06:35 -05:00
parent 3a82b58745
commit 5a87bc98da
32 changed files with 256 additions and 58 deletions

View file

@ -94,11 +94,9 @@
[
"exception"
"raise"
] @exception
(comment) @comment
(comment) @spell ;; spell-check comments
(string_literal) @string
(string_literal) @spell ;; spell-check strings
] @exception
(comment) @comment @spell
(string_literal) @string @spell
(character_literal) @string
(numeric_literal) @number
@ -173,6 +171,24 @@
; ] @function.spec
;)
((comment) @comment.documentation
. [
(entry_declaration)
(subprogram_declaration)
(parameter_specification)
])
(compilation_unit
. (comment) @comment.documentation)
(component_list
(component_declaration)
. (comment) @comment.documentation)
(enumeration_type_definition
(identifier)
. (comment) @comment.documentation)
;; Highlight errors in red. This is not very useful in practice, as text will
;; be highlighted as user types, and the error could be elsewhere in the code.
;; This also requires defining :hi @error guifg=Red for instance.

View file

@ -176,6 +176,9 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
;; Parameters
(parameter_declaration
declarator: (identifier) @parameter)

View file

@ -75,6 +75,14 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
(using_directive
(identifier) @type)

View file

@ -4,7 +4,18 @@
(line_comment)
(block_comment)
(nesting_block_comment)
] @comment
] @comment @spell
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((nesting_block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$"))
[
"(" ")"

View file

@ -155,8 +155,8 @@
(false) @boolean
(null_literal) @constant.builtin
(documentation_comment) @comment
(comment) @comment
(comment) @comment @spell
(documentation_comment) @comment.documentation @spell
; Keywords
; --------------------

View file

@ -123,12 +123,13 @@
(undefined)
] @constant.builtin
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(hash_bang_line) @preproc
(comment) @spell
(string) @string @spell
(template_string) @string
(escape_sequence) @string.escape

View file

@ -29,12 +29,10 @@
((identifier) @comment (#match? @comment "^_"))
; Comments
(comment) @comment
(comment) @spell
(comment) @comment @spell
; Strings
(string) @string
(string) @spell
(string) @string @spell
; Modules
(alias) @type
@ -214,15 +212,15 @@
(unary_operator
operator: "@"
operand: (call
target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment
target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation
(arguments [
(string)
(boolean)
(charlist)
(sigil
"~" @comment
((sigil_name) @comment)
quoted_start: _ @comment
(quoted_content) @comment
quoted_end: _ @comment)
] @comment))) @comment
"~" @comment.documentation
((sigil_name) @comment.documentation)
quoted_start: _ @comment.documentation
(quoted_content) @comment.documentation
quoted_end: _ @comment.documentation)
] @comment.documentation))) @comment.documentation

View file

@ -1,7 +1,10 @@
[
(line_comment)
(block_comment)
] @comment
] @comment @spell
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^{[-]|[^|]"))
; Keywords

View file

@ -5,7 +5,10 @@
(integer) @number
(float) @float
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[%%][%%]"))
;; keyword
[
@ -104,7 +107,6 @@
(type_alias name: _ @type) @type.definition
(spec) @type.definition
(comment) @comment
[(string) (binary)] @string
;;; expr_function_call

View file

@ -324,6 +324,9 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^!>"))
; Errors
(ERROR) @error

View file

@ -82,11 +82,14 @@
(identifier) @variable
; Comments
[
(comment)
] @comment @spell
[
(module_comment)
(statement_comment)
(comment)
] @comment
] @comment.documentation @spell
; Unused Identifiers
[

View file

@ -196,20 +196,46 @@
(float_literal) @float
(imaginary_literal) @number
(true) @boolean
(false) @boolean
[
(true)
(false)
] @boolean
(nil) @constant.builtin
(keyed_element
. (literal_element (identifier) @field))
(field_declaration name: (field_identifier) @field)
; Comments
(comment) @comment @spell
;; Doc Comments
(source_file . (comment)+ @comment.documentation)
(source_file
(comment)+ @comment.documentation
. (const_declaration))
(source_file
(comment)+ @comment.documentation
. (function_declaration))
(source_file
(comment)+ @comment.documentation
. (type_declaration))
(source_file
(comment)+ @comment.documentation
. (var_declaration))
; Errors
(ERROR) @error
; Spell
((interpreted_string_literal) @spell
(#not-has-parent? @spell
import_spec
)
)
(#not-has-parent? @spell import_spec))

View file

@ -12,7 +12,10 @@
[
(comment)
(heredoc)
] @comment
] @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
"function" @keyword.function

View file

@ -279,3 +279,12 @@
(line_comment)
(block_comment)
] @comment @spell
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))

View file

@ -217,12 +217,13 @@
;;; Literals
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(shebang_line) @preproc
(comment) @spell
(real_literal) @float
[
(integer_literal)

View file

@ -187,6 +187,12 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-][-]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
(hash_bang_line) @preproc
(number) @number

View file

@ -248,7 +248,36 @@
; -- Comments
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((comment) @comment.documentation
. [(unit) (declProc)])
(declTypes
(comment) @comment.documentation
. (declType))
(declSection
(comment) @comment.documentation
. [(declField) (declProc)])
(declEnum
(comment) @comment.documentation
. (declEnumValue))
(declConsts
(comment) @comment.documentation
. (declConst))
(declVars
(comment) @comment.documentation
. (declVar))
(pp) @preproc
; -- Type declaration

View file

@ -8,10 +8,9 @@
"type"
] @keyword
[
(comment)
(developer_comment)
] @comment
(comment) @comment @spell
(developer_comment) @comment.documentation @spell
[
(attribute)

View file

@ -42,7 +42,10 @@
(false)
] @boolean
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
[
"("
@ -53,7 +56,7 @@
"}"
"<"
">"
] @punctuation.bracket
] @punctuation.bracket
[
";"

View file

@ -130,5 +130,6 @@
[
(line_comment)
(block_comment)
(qldoc)
] @comment
] @comment @spell
(qldoc) @comment.documentation

View file

@ -173,13 +173,30 @@
(float) @float
[
(nil)
(true)
(false)
] @boolean
(comment) @comment
(comment) @spell
(nil) @constant.builtin
(comment) @comment @spell
(program
(comment)+ @comment.documentation
(class))
(module
(comment)+ @comment.documentation
(body_statement (class)))
(class
(comment)+ @comment.documentation
(body_statement (method)))
(body_statement
(comment)+ @comment.documentation
(method))
(string_content) @spell
; Operators

View file

@ -148,6 +148,18 @@
(block_comment)
] @comment @spell
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^//!"))
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][!]"))
(boolean_literal) @boolean
(integer_literal) @number
(float_literal) @float

View file

@ -234,6 +234,9 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
;; `case` is a conditional keyword in case_block
(case_block

View file

@ -182,3 +182,10 @@
; Comments
(comment) @comment @spell
(class_definition
(comment) @comment.documentation)
; Errors
(ERROR) @error

View file

@ -108,7 +108,6 @@
; Comments
[
(comment)
(documentation_comment)
] @comment @spell
(comment) @comment @spell
(documentation_comment) @comment.documentation @spell

View file

@ -252,6 +252,14 @@
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
; Errors
(ERROR) @error

View file

@ -107,6 +107,15 @@
(multiline_comment)
] @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((multiline_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
; String literals
(line_str_text) @string
(str_escaped_char) @string

View file

@ -2,7 +2,11 @@
;; Primitives
(boolean) @boolean
(comment) @comment @spell
(shebang_comment) @comment
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-][-]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
(shebang_comment) @preproc
(identifier) @variable
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))

View file

@ -198,3 +198,11 @@
; Comments
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))

View file

@ -406,5 +406,8 @@
(ERROR) @error
(comment) @comment
(comment) @comment @spell
(_
(comment)+ @comment.documentation
[(function_declaration) (type_declaration) (const_spec) (enum_declaration)])

View file

@ -1,7 +1,9 @@
; highlights.scm
; highlight comments and symbols
(comment) @comment
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(symbol) @symbol
(member_access_expression (_) (identifier) @symbol)

View file

@ -1,8 +1,9 @@
(line_comment) @comment @spell
[
(container_doc_comment)
(doc_comment)
(line_comment)
] @comment @spell
] @comment.documentation @spell
[
variable: (IDENTIFIER)