2014-07-21 00:53:21 +02:00
|
|
|
# http://common-lisp.net
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](lisp) %{
|
|
|
|
set buffer filetype lisp
|
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
add-highlighter -group / regions -default code lisp \
|
2014-07-21 00:53:21 +02:00
|
|
|
string '"' (?<!\\)(\\\\)*" '' \
|
|
|
|
comment ';' '$' ''
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
add-highlighter -group /lisp/string fill string
|
|
|
|
add-highlighter -group /lisp/comment fill comment
|
2014-07-21 00:53:21 +02:00
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
add-highlighter -group /lisp/code regex \b(nil|true|false)\b 0:value
|
2017-10-02 14:59:22 +02:00
|
|
|
add-highlighter -group /lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=) 0:operator
|
2017-02-10 03:43:29 +01:00
|
|
|
add-highlighter -group /lisp/code regex \b(([':]\w+)|([*]\H+[*]))\b 0:variable
|
2017-01-04 01:07:45 +01:00
|
|
|
add-highlighter -group /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
|
2014-07-21 00:53:21 +02:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-01-13 01:56:30 +01:00
|
|
|
def -hidden lisp-filter-around-selections %{
|
2015-11-04 10:48:47 +01:00
|
|
|
# remove trailing white spaces
|
|
|
|
try %{ exec -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
|
2017-01-13 01:56:30 +01:00
|
|
|
def -hidden lisp-indent-on-new-line %{
|
2014-07-21 00:53:21 +02:00
|
|
|
eval -draft -itersel %{
|
|
|
|
# preserve previous line indent
|
2017-01-13 01:50:03 +01:00
|
|
|
try %{ exec -draft \; K <a-&> }
|
2014-07-21 00:53:21 +02:00
|
|
|
# indent when matches opening paren
|
2017-09-29 04:39:59 +02:00
|
|
|
try %{ exec -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> }
|
2014-07-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter ref lisp }
|
2014-07-21 00:53:21 +02:00
|
|
|
|
2016-09-25 15:15:07 +02:00
|
|
|
hook global WinSetOption filetype=lisp %{
|
2017-01-13 01:56:30 +01:00
|
|
|
hook window InsertEnd .* -group lisp-hooks lisp-filter-around-selections
|
|
|
|
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
|
2014-07-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 01:07:45 +01:00
|
|
|
hook -group lisp-highlight global WinSetOption filetype=(?!lisp).* %{ remove-highlighter lisp }
|
2016-09-28 08:45:01 +02:00
|
|
|
|
2014-07-21 00:53:21 +02:00
|
|
|
hook global WinSetOption filetype=(?!lisp).* %{
|
2017-01-04 01:07:45 +01:00
|
|
|
remove-hooks window lisp-indent
|
|
|
|
remove-hooks window lisp-hooks
|
2014-07-21 00:53:21 +02:00
|
|
|
}
|