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" "exception"
"raise" "raise"
] @exception ] @exception
(comment) @comment (comment) @comment @spell
(comment) @spell ;; spell-check comments (string_literal) @string @spell
(string_literal) @string
(string_literal) @spell ;; spell-check strings
(character_literal) @string (character_literal) @string
(numeric_literal) @number (numeric_literal) @number
@ -173,6 +171,24 @@
; ] @function.spec ; ] @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 ;; 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. ;; be highlighted as user types, and the error could be elsewhere in the code.
;; This also requires defining :hi @error guifg=Red for instance. ;; This also requires defining :hi @error guifg=Red for instance.

View file

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

View file

@ -75,6 +75,14 @@
(comment) @comment @spell (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 (using_directive
(identifier) @type) (identifier) @type)

View file

@ -4,7 +4,18 @@
(line_comment) (line_comment)
(block_comment) (block_comment)
(nesting_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 (false) @boolean
(null_literal) @constant.builtin (null_literal) @constant.builtin
(documentation_comment) @comment (comment) @comment @spell
(comment) @comment (documentation_comment) @comment.documentation @spell
; Keywords ; Keywords
; -------------------- ; --------------------

View file

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

View file

@ -29,12 +29,10 @@
((identifier) @comment (#match? @comment "^_")) ((identifier) @comment (#match? @comment "^_"))
; Comments ; Comments
(comment) @comment (comment) @comment @spell
(comment) @spell
; Strings ; Strings
(string) @string (string) @string @spell
(string) @spell
; Modules ; Modules
(alias) @type (alias) @type
@ -214,15 +212,15 @@
(unary_operator (unary_operator
operator: "@" operator: "@"
operand: (call 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 [ (arguments [
(string) (string)
(boolean) (boolean)
(charlist) (charlist)
(sigil (sigil
"~" @comment "~" @comment.documentation
((sigil_name) @comment) ((sigil_name) @comment.documentation)
quoted_start: _ @comment quoted_start: _ @comment.documentation
(quoted_content) @comment (quoted_content) @comment.documentation
quoted_end: _ @comment) quoted_end: _ @comment.documentation)
] @comment))) @comment ] @comment.documentation))) @comment.documentation

View file

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

View file

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

View file

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

View file

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

View file

@ -196,20 +196,46 @@
(float_literal) @float (float_literal) @float
(imaginary_literal) @number (imaginary_literal) @number
(true) @boolean [
(false) @boolean (true)
(false)
] @boolean
(nil) @constant.builtin (nil) @constant.builtin
(keyed_element (keyed_element
. (literal_element (identifier) @field)) . (literal_element (identifier) @field))
(field_declaration name: (field_identifier) @field) (field_declaration name: (field_identifier) @field)
; Comments
(comment) @comment @spell (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 (ERROR) @error
; Spell
((interpreted_string_literal) @spell ((interpreted_string_literal) @spell
(#not-has-parent? @spell (#not-has-parent? @spell import_spec))
import_spec
)
)

View file

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

View file

@ -279,3 +279,12 @@
(line_comment) (line_comment)
(block_comment) (block_comment)
] @comment @spell ] @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 ;;; Literals
(comment) @comment (comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(shebang_line) @preproc (shebang_line) @preproc
(comment) @spell
(real_literal) @float (real_literal) @float
[ [
(integer_literal) (integer_literal)

View file

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

View file

@ -248,7 +248,36 @@
; -- Comments ; -- 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 (pp) @preproc
; -- Type declaration ; -- Type declaration

View file

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

View file

@ -42,7 +42,10 @@
(false) (false)
] @boolean ] @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) (line_comment)
(block_comment) (block_comment)
(qldoc) ] @comment @spell
] @comment
(qldoc) @comment.documentation

View file

@ -173,13 +173,30 @@
(float) @float (float) @float
[ [
(nil)
(true) (true)
(false) (false)
] @boolean ] @boolean
(comment) @comment (nil) @constant.builtin
(comment) @spell
(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 (string_content) @spell
; Operators ; Operators

View file

@ -148,6 +148,18 @@
(block_comment) (block_comment)
] @comment @spell ] @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 (boolean_literal) @boolean
(integer_literal) @number (integer_literal) @number
(float_literal) @float (float_literal) @float

View file

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

View file

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

View file

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

View file

@ -252,6 +252,14 @@
(comment) @comment @spell (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 ; Errors
(ERROR) @error (ERROR) @error

View file

@ -107,6 +107,15 @@
(multiline_comment) (multiline_comment)
] @comment @spell ] @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 ; String literals
(line_str_text) @string (line_str_text) @string
(str_escaped_char) @string (str_escaped_char) @string

View file

@ -2,7 +2,11 @@
;; Primitives ;; Primitives
(boolean) @boolean (boolean) @boolean
(comment) @comment @spell (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
((identifier) @variable.builtin ((identifier) @variable.builtin
(#eq? @variable.builtin "self")) (#eq? @variable.builtin "self"))

View file

@ -198,3 +198,11 @@
; Comments ; Comments
(comment) @comment @spell (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 (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 ; highlights.scm
; highlight comments and symbols ; highlight comments and symbols
(comment) @comment (comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
(symbol) @symbol (symbol) @symbol
(member_access_expression (_) (identifier) @symbol) (member_access_expression (_) (identifier) @symbol)

View file

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