Last active
April 24, 2024 18:24
-
-
Save eduardvercaemer/bf1917b7031c13110ecf50ae5cc76208 to your computer and use it in GitHub Desktop.
Kakoune ADA language highlighter
This file contains hidden or 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
hook global BufCreate .*\.(ad[sb]) %{ | |
set-option buffer filetype ada | |
} | |
hook global WinSetOption filetype=ada %{ | |
require-module ada | |
set-option window static_words %opt{ada_static_words} | |
} | |
hook -group ada-highlight global WinSetOption filetype=ada %{ | |
add-highlighter window/ada ref ada | |
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ada } | |
} | |
provide-module ada %§ | |
add-highlighter shared/ada regions | |
add-highlighter shared/ada/code default-region group | |
add-highlighter shared/ada/string region '"' (?<!\\)(\\\\)*" fill string | |
add-highlighter shared/ada/comment region '--' '$' fill comment | |
add-highlighter shared/ada/attribute region \' [a-zA-Z_]* fill value | |
evaluate-commands %sh{ | |
# Keywords | |
keywords="abort|abs|abstract|accept|access|aliased|all|and|array|at|begin|body|case|constant" | |
keywords="${keywords}|declare|delay|delta|digits|do|else|elseif|end|entry|exception|exit|for" | |
keywords="${keywords}|function|generic|goto|if|in|interface|is|limited|loop|mod|new|not|null" | |
keywords="${keywords}|of|or|others|out|overriding|package|pragma|private|procedure|protected" | |
keywords="${keywords}|raise|range|record|rem|renames|requeue|return|reverse|select|separate" | |
keywords="${keywords}|some|subtype|synchronized|tagged|task|terminate|then|type|until|use|when" | |
keywords="${keywords}|while|with|xor" | |
# Types | |
types="Integer|Float|Boolean|Character" | |
# Add the language's grammar to the static completion list | |
printf %s\\n "declare-option str-list ada_static_words ${keywords} ${types}" | tr '|' ' ' | |
printf %s " | |
add-highlighter shared/ada/code/ regex '(?i)\b(${keywords})\b' 0:keyword | |
add-highlighter shared/ada/code/ regex '\b(${types})\b' 0:type | |
" | |
} | |
add-highlighter shared/ada/code/ regex '\+|-|\*|/|<>|<=|<|>=|>|=>|=|\.\.|\.|:=|:|;|&' 0:operator | |
add-highlighter shared/ada/code/ regex \b\d[\d_]*(?:\.\d[\d_]*)?\b 0:value | |
§ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basic support. Adds keywords, ops, attributes, comments, and primitive types, static word completion.