Created
April 6, 2023 07:55
-
-
Save divarvel/11d934e90e642fc184bbfa1332173e61 to your computer and use it in GitHub Desktop.
Kakoune support for biscuit datalog
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
# http://https://datalog-biscuit-lang.org | |
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | |
# Detection | |
# ‾‾‾‾‾‾‾‾‾ | |
hook global BufCreate .*\.biscuit-datalog %{ | |
set-option buffer filetype biscuitdl | |
} | |
# Initialization | |
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | |
add-highlighter shared/biscuitdl regions | |
add-highlighter shared/biscuitdl/code default-region group | |
add-highlighter shared/biscuitdl/string region '"' '(?<!\\)"' fill string | |
add-highlighter shared/biscuitdl/line_comment region '//' '$' fill comment | |
add-highlighter shared/biscuitdl/block_comment region '/\*' '\*/' fill comment | |
#add-highlighter shared/dhall/code/op regex <- 0:operator | |
add-highlighter shared/biscuitdl/code/symbol regex '#[A-Za-z0-9]+' 0:type | |
add-highlighter shared/biscuitdl/code/variable regex \$[A-Za-z0-9]+ 0:variable | |
add-highlighter shared/biscuitdl/code/date regex (?<!')\b\d{1,4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})(.\d+)?(Z|[\+\-]\d{2}:\d{2}) 0:value | |
add-highlighter shared/biscuitdl/code/number regex (?<!')\b\d+([.]\d+)? 0:value | |
add-highlighter shared/biscuitdl/code/boolean regex (?<!')\b(true|false) 0:value | |
add-highlighter shared/biscuitdl/code/bytes regex (?<!')\bhex:[A-Fa-f0-9]+ 0:string | |
add-highlighter shared/biscuitdl/code/head regex (?<!')\b\w+(?=\() 0:function | |
add-highlighter shared/biscuitdl/code/kw regex (?<!')\b(check|allow|deny|if) 0:keyword | |
# Commands | |
# ‾‾‾‾‾‾‾‾ | |
define-command -hidden biscuitdl-filter-around-selections %{ | |
# remove trailing white spaces | |
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d } | |
} | |
# | |
# Initialization | |
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ | |
hook -group biscuitdl-highlight global WinSetOption filetype=biscuitdl %{ add-highlighter window/biscuitdl ref biscuitdl } | |
hook global WinSetOption filetype=biscuitdl %{ | |
set-option window extra_word_chars "'" | |
hook window ModeChange insert:.* -group biscuitdl-hooks biscuitdl-filter-around-selections | |
} | |
hook -group biscuitdl-highlight global WinSetOption filetype=(?!biscuitdl).* %{ remove-highlighter window/biscuitdl } | |
hook global WinSetOption filetype=(?!biscuitdl).* %{ | |
remove-hooks window biscuitdl-hooks | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment