git.s-ol.nu alive.kak / master alive.kak
master

Tree @master (Download .tar.gz)

alive.kak @masterraw · history · blame

# Detection
hook global BufCreate .*[.](alv) %{
    set-option buffer filetype alive
}

# Highlighters

add-highlighter shared/alive regions
add-highlighter shared/alive/code default-region group
add-highlighter shared/alive/dstring  region '"'       (?<!\\)(?:\\\\)*" fill string
add-highlighter shared/alive/qstring  region "'"       (?<!\\)(?:\\\\)*' fill string
add-highlighter shared/alive/comment  region -recurse '\(' '#\(' '\)'    fill comment
add-highlighter shared/alive/code/tag regex  \[[0-9]+\] 0:rgb:696969

# Commands

# attempt to tame the autoreload, not 100% successful
define-command -hidden alive-reload-file %[
  nop %sh{ sleep 0.01 }
  edit!
]

# Initialization

hook -group alive-highlight global WinSetOption filetype=alive %{
    add-highlighter window/alive ref alive

    hook -once -always window WinSetOption filetype=.* %{
        remove-highlighter window/alive
    }
}

hook global WinSetOption filetype=alive %[
    set-option buffer comment_block_begin '#('
    set-option buffer comment_block_end ')'
    set-option buffer tabstop 2
    set-option buffer indentwidth 2

    hook -group alive-hooks window BufWritePost .* alive-reload-file

    hook -once -always window WinSetOption filetype=.* %{
        remove-hooks window alive-.+
    }
]