From d7d79af8b4430b68ce1344257f054f3da6248c13 Mon Sep 17 00:00:00 2001 From: Martin Chaine Date: Fri, 21 Oct 2016 13:32:17 +0200 Subject: [PATCH] Add taskpaper basic support --- rc/extra/taskpaper.kak | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 rc/extra/taskpaper.kak diff --git a/rc/extra/taskpaper.kak b/rc/extra/taskpaper.kak new file mode 100644 index 00000000..5a366d3d --- /dev/null +++ b/rc/extra/taskpaper.kak @@ -0,0 +1,47 @@ +# https://www.taskpaper.com +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*\.taskpaper %{ + set buffer mimetype "" + set buffer filetype taskpaper +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / group taskpaper + +addhl -group /taskpaper regex ^\h*([^:\n]+):\h*\n 1:header +addhl -group /taskpaper regex \h@\w+(?:\(([^)]*)\))? 0:identifier 1:value +addhl -group /taskpaper regex ^\h*([^-:\n]+)\n 1:+i +addhl -group /taskpaper regex ^\h*-\h+[^\n]*@done[^\n]* 0:+d +addhl -group /taskpaper regex (([a-z]+://\S+)|((mailto:)[\w+-]+@\S+)) 0:link + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _taskpaper-indent-on-new-line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft \;K } + ## If the line above is a project indent with a tab + try %{ exec -draft Z k ^\h*([^:\n]+): z i } + # cleanup trailing white spaces on previous line + try %{ exec -draft k s \h+$ d } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{ + addhl ref taskpaper + hook window InsertChar \n -group taskpaper-indent _taskpaper-indent-on-new-line +} +hook -group taskpaper-highlight global WinSetOption filetype=(?!taskpaper).* %{ + rmhl taskpaper + rmhooks window taskpaper-indent +}