mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-23 03:21:55 +03:00
d49555fc75
That means we can now have highlighters active at global, buffer, and window scope. The add-highlighter and remove-highlighter syntax changed to take the parent path (scope/group/...) as a mandatory argument, superseeding the previous -group switch.
47 lines
1.5 KiB
Plaintext
47 lines
1.5 KiB
Plaintext
# https://www.taskpaper.com
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
# Detection
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
hook global BufCreate .*\.taskpaper %{
|
|
set buffer filetype taskpaper
|
|
}
|
|
|
|
# Highlighters
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
add-highlighter shared/ group taskpaper
|
|
|
|
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
|
|
|
|
# Commands
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
def -hidden taskpaper-indent-on-new-line %{
|
|
eval -draft -itersel %{
|
|
# preserve previous line indent
|
|
try %{ exec -draft \;K<a-&> }
|
|
## If the line above is a project indent with a tab
|
|
try %{ exec -draft Z k<a-x> <a-k>^\h*([^:\n]+):<ret> z i<tab> }
|
|
# cleanup trailing white spaces on previous line
|
|
try %{ exec -draft k<a-x> s \h+$ <ret>d }
|
|
}
|
|
}
|
|
|
|
# Initialization
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{
|
|
add-highlighter window ref taskpaper
|
|
hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line
|
|
}
|
|
hook -group taskpaper-highlight global WinSetOption filetype=(?!taskpaper).* %{
|
|
remove-highlighter window/taskpaper
|
|
remove-hooks window taskpaper-indent
|
|
}
|