mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 23:34:12 +03:00
d49555fc75
That means we can now have highlighters active at global, buffer, and window scope. The add-highlighter and remove-highlighter syntax changed to take the parent path (scope/group/...) as a mandatory argument, superseeding the previous -group switch.
59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
# http://common-lisp.net
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
# Detection
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
hook global BufCreate .*[.](lisp) %{
|
|
set buffer filetype lisp
|
|
}
|
|
|
|
# Highlighters
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
add-highlighter shared/ regions -default code lisp \
|
|
string '"' (?<!\\)(\\\\)*" '' \
|
|
comment ';' '$' ''
|
|
|
|
add-highlighter shared/lisp/string fill string
|
|
add-highlighter shared/lisp/comment fill comment
|
|
|
|
add-highlighter shared/lisp/code regex \b(nil|true|false)\b 0:value
|
|
add-highlighter shared/lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=) 0:operator
|
|
add-highlighter shared/lisp/code regex \b(([':]\w+)|([*]\H+[*]))\b 0:variable
|
|
add-highlighter shared/lisp/code regex \b(def[a-z]+|if|do|let|lambda|catch|and|assert|while|def|do|fn|finally|let|loop|new|quote|recur|set!|throw|try|var|case|if-let|if-not|when|when-first|when-let|when-not|(cond(->|->>)?))\b 0:keyword
|
|
|
|
# Commands
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
def -hidden lisp-filter-around-selections %{
|
|
# remove trailing white spaces
|
|
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d }
|
|
}
|
|
|
|
def -hidden lisp-indent-on-new-line %{
|
|
eval -draft -itersel %{
|
|
# preserve previous line indent
|
|
try %{ exec -draft \; K <a-&> }
|
|
# indent when matches opening paren
|
|
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> }
|
|
}
|
|
}
|
|
|
|
# Initialization
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter window ref lisp }
|
|
|
|
hook global WinSetOption filetype=lisp %{
|
|
hook window InsertEnd .* -group lisp-hooks lisp-filter-around-selections
|
|
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
|
|
}
|
|
|
|
hook -group lisp-highlight global WinSetOption filetype=(?!lisp).* %{ remove-highlighter window/lisp }
|
|
|
|
hook global WinSetOption filetype=(?!lisp).* %{
|
|
remove-hooks window lisp-indent
|
|
remove-hooks window lisp-hooks
|
|
}
|