1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-01 16:32:54 +03:00
kakoune/rc/extra/taskpaper.kak

47 lines
1.6 KiB
Plaintext
Raw Normal View History

2016-10-21 14:32:17 +03:00
# https://www.taskpaper.com
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.taskpaper %{
set-option buffer filetype taskpaper
2016-10-21 14:32:17 +03:00
}
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/taskpaper group
2016-10-21 14:32:17 +03:00
add-highlighter shared/taskpaper/ regex ^\h*([^:\n]+):\h*\n 1:header
add-highlighter shared/taskpaper/ regex \h@\w+(?:\(([^)]*)\))? 0:variable 1:value
add-highlighter shared/taskpaper/ regex ^\h*([^-:\n]+)\n 1:+i
add-highlighter shared/taskpaper/ regex ^\h*-\h+[^\n]*@done[^\n]* 0:+d
add-highlighter shared/taskpaper/ regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) 0:link
2016-10-21 14:32:17 +03:00
# Commands
# ‾‾‾‾‾‾‾‾
define-command -hidden taskpaper-indent-on-new-line %{
evaluate-commands -draft -itersel %{
2016-10-21 14:32:17 +03:00
# preserve previous line indent
try %{ execute-keys -draft \;K<a-&> }
2016-10-21 14:32:17 +03:00
## If the line above is a project indent with a tab
try %{ execute-keys -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> }
2016-10-21 14:32:17 +03:00
# cleanup trailing white spaces on previous line
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
2016-10-21 14:32:17 +03:00
}
}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{
add-highlighter window/taskpaper ref taskpaper
hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line
2016-10-21 14:32:17 +03:00
}
hook -group taskpaper-highlight global WinSetOption filetype=(?!taskpaper).* %{
remove-highlighter window/taskpaper
2017-01-04 03:07:45 +03:00
remove-hooks window taskpaper-indent
2016-10-21 14:32:17 +03:00
}