-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.vim
65 lines (53 loc) · 2.68 KB
/
tasks.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
" Tasks syntax
" Language: Tasks
" Maintainer: CrispyDrone
" Previous Maintainer: Chris Rolfs
" Last Change: Oct 17, 2019
" Version: 0.20.1
" URL: https://github.com/CrispyDrone/vim-tasks
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" note: For some reason syntax/tasks.vim is loaded before the plugin/tasks.vim file on my new ubuntu pc
if !exists("b:loaded_tasks")
let path = expand('<sfile>:p:h:h')
exec 'source' path . '/ftplugin/tasks.vim'
endif
silent! syntax include @markdown syntax/markdown.vim
unlet! b:current_syntax
syn case match
syn sync fromstart
let b:regesc = '[]()?.*@=\'
function! s:CreateMatch(name, regex)
exec 'syn match ' . a:name . ' "' . a:regex . '" contained'
endfunc
let s:regMarker = join([escape(g:TasksMarkerBase, b:regesc), escape(g:TasksMarkerInProgress, b:regesc), escape(g:TasksMarkerDone, b:regesc), escape(g:TasksMarkerCancelled, b:regesc)], '\|')
let s:regProject = '^\(\s*\)\(\(.*' . s:regMarker . '.*\)\@!.\)\+:\s*$'
call s:CreateMatch('tMarker', '^\s*' . escape(g:TasksMarkerBase, b:regesc))
call s:CreateMatch('tMarkerCancelled', '^\s*' . escape(g:TasksMarkerCancelled, b:regesc))
call s:CreateMatch('tMarkerComplete', '^\s*' . escape(g:TasksMarkerDone, b:regesc))
exec 'syn match tAttribute "' . g:TasksAttributeMarker . '\w\+\(([^)]*)\)\=" contained'
exec 'syn match tAttributeCompleted "' . g:TasksAttributeMarker . '\w\+\(([^)]*)\)\=" contained'
exec 'syn match tLowPriority "' . g:TasksAttributeMarker . 'priority(low)" contained'
exec 'syn match tMediumPriority "' . g:TasksAttributeMarker . 'priority(medium)" contained'
exec 'syn match tHighPriority "' . g:TasksAttributeMarker . 'priority(high)" contained'
exec 'syn match tCriticalPriority "' . g:TasksAttributeMarker . 'priority(critical)" contained'
syn region tTask start=/^\s*/ end=/$/ oneline keepend contains=tMarker,tAttribute, tLowPriority, tMediumPriority, tHighPriority, tCriticalPriority
exec 'syn region tTaskDone start="^[\s]*.*'.g:TasksAttributeMarker.'done" end=/$/ oneline contains=tMarkerComplete,tAttributeCompleted'
exec 'syn region tTaskCancelled start="^[\s]*.*'.g:TasksAttributeMarker.'cancelled" end=/$/ oneline contains=tMarkerCancelled,tAttributeCompleted'
"syn match tProject "^\s*.*:\s*$"
exec 'syn match tProject "' . s:regProject . '"'
hi def link tMarker Comment
hi def link tMarkerComplete String
hi def link tMarkerCancelled Statement
hi def link tAttribute Special
hi def link tAttributeCompleted Function
hi def link tTaskDone Comment
hi def link tTaskCancelled Comment
hi def link tProject Constant
hi def link tLowPriority Statement
hi def link tMediumPriority Type
hi def link tHighPriority PreProc
hi def link tCriticalPriority Todo