2016-10-21 13:32:17 +02:00
|
|
|
# https://www.taskpaper.com
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*\.taskpaper %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype taskpaper
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=taskpaper %{
|
2019-03-13 22:00:59 +01:00
|
|
|
require-module taskpaper
|
2019-04-12 00:54:58 +02:00
|
|
|
|
2022-05-08 15:01:25 +02:00
|
|
|
hook window ModeChange pop:insert:.* -group taskpaper-trim-indent taskpaper-trim-indent
|
2019-04-12 00:54:58 +02:00
|
|
|
hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ }
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{
|
|
|
|
add-highlighter window/taskpaper ref taskpaper
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/taskpaper }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
provide-module taskpaper %{
|
2016-10-21 13:32:17 +02:00
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/taskpaper group
|
2016-10-21 13:32:17 +02:00
|
|
|
|
2018-07-01 11:53:35 +02: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 13:32:17 +02:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2022-05-08 15:01:25 +02:00
|
|
|
define-command -hidden taskpaper-trim-indent %{
|
|
|
|
evaluate-commands -no-hooks -draft -itersel %{
|
2022-03-16 23:20:07 +01:00
|
|
|
execute-keys x
|
2022-05-08 15:01:25 +02:00
|
|
|
# remove trailing white spaces
|
|
|
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command -hidden taskpaper-indent-on-new-line %{
|
2017-11-03 09:09:45 +01:00
|
|
|
evaluate-commands -draft -itersel %{
|
2016-10-21 13:32:17 +02:00
|
|
|
# preserve previous line indent
|
2019-10-22 11:02:06 +02:00
|
|
|
try %{ execute-keys -draft <semicolon>K<a-&> }
|
2016-10-21 13:32:17 +02:00
|
|
|
## If the line above is a project indent with a tab
|
2022-03-16 23:20:07 +01:00
|
|
|
try %{ execute-keys -draft Z kx <a-k>^\h*([^:\n]+):<ret> z i<tab> }
|
2016-10-21 13:32:17 +02:00
|
|
|
# cleanup trailing white spaces on previous line
|
2022-03-16 23:20:07 +01:00
|
|
|
try %{ execute-keys -draft kx s \h+$ <ret>d }
|
2016-10-21 13:32:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|