2014-07-21 02:53:21 +04:00
|
|
|
# http://common-lisp.net
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](lisp) %{
|
2017-11-03 10:34:41 +03:00
|
|
|
set-option buffer filetype lisp
|
2014-07-21 02:53:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/ regions -default code lisp \
|
2014-07-21 02:53:21 +04:00
|
|
|
string '"' (?<!\\)(\\\\)*" '' \
|
|
|
|
comment ';' '$' ''
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/lisp/string fill string
|
|
|
|
add-highlighter shared/lisp/comment fill comment
|
2014-07-21 02:53:21 +04:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
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
|
2014-07-21 02:53:21 +04:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden lisp-filter-around-selections %{
|
2015-11-04 12:48:47 +03:00
|
|
|
# remove trailing white spaces
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-21 02:53:21 +04:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden lisp-indent-on-new-line %{
|
2017-11-03 11:09:45 +03:00
|
|
|
evaluate-commands -draft -itersel %{
|
2014-07-21 02:53:21 +04:00
|
|
|
# preserve previous line indent
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft \; K <a-&> }
|
2014-07-21 02:53:21 +04:00
|
|
|
# indent when matches opening paren
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft [( <a-k> \A\([^\n]+\n[^\n]*\n?\z <ret> <a-\;> \; <a-gt> }
|
2014-07-21 02:53:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter window ref lisp }
|
2014-07-21 02:53:21 +04:00
|
|
|
|
2016-09-25 16:15:07 +03:00
|
|
|
hook global WinSetOption filetype=lisp %{
|
2018-01-21 02:35:05 +03:00
|
|
|
hook window ModeChange insert:.* -group lisp-hooks lisp-filter-around-selections
|
2017-01-13 03:56:30 +03:00
|
|
|
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
|
2014-07-21 02:53:21 +04:00
|
|
|
}
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group lisp-highlight global WinSetOption filetype=(?!lisp).* %{ remove-highlighter window/lisp }
|
2016-09-28 09:45:01 +03:00
|
|
|
|
2014-07-21 02:53:21 +04:00
|
|
|
hook global WinSetOption filetype=(?!lisp).* %{
|
2017-01-04 03:07:45 +03:00
|
|
|
remove-hooks window lisp-indent
|
|
|
|
remove-hooks window lisp-hooks
|
2014-07-21 02:53:21 +04:00
|
|
|
}
|