-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathtaskwiki.vim
More file actions
157 lines (139 loc) · 8.63 KB
/
taskwiki.vim
File metadata and controls
157 lines (139 loc) · 8.63 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
" Check VIM version
if version < 704
echoerr "Taskwiki requires at least Vim 7.4. Please upgrade your environment."
finish
endif
" Python version detection.
if has("python3") && ! exists("g:taskwiki_use_python2")
let g:taskwiki_py='py3 '
let g:taskwiki_pyfile='py3file '
elseif has("python")
let g:taskwiki_py='py '
let g:taskwiki_pyfile='pyfile '
else
echoerr "Taskwiki requires Vim compiled with the Python support."
finish
endif
" Disable taskwiki if taskwiki_disable variable set
if exists("g:taskwiki_disable")
finish
endif
if !exists("g:did_python_taskwiki")
" Determine the plugin path
let s:plugin_path = escape(expand('<sfile>:p:h:h:h'), '\')
" Execute the main body of taskwiki source
execute g:taskwiki_pyfile . s:plugin_path . '/taskwiki/main.py'
let g:did_python_taskwiki = 1
endif
" Global update commands
execute "command! -buffer -nargs=* TaskWikiBufferSave :" . g:taskwiki_py . "WholeBuffer.update_to_tw()"
execute "command! -buffer -nargs=* TaskWikiBufferLoad :" . g:taskwiki_py . "WholeBuffer.update_from_tw()"
execute "command! -buffer -nargs=* TaskWikiReview :" . g:taskwiki_py . "TaskWikiReview.run(<args>)"
augroup taskwiki
autocmd! * <buffer>
" Update to TW upon saving
autocmd BufWrite <buffer> TaskWikiBufferSave
" Save and load the view to preserve folding, if desired
if !exists('g:taskwiki_dont_preserve_folds')
autocmd BufWinLeave <buffer> mkview
autocmd BufWinEnter <buffer> silent! loadview
autocmd BufWinEnter <buffer> silent! doautocmd SessionLoadPost
endif
execute "autocmd BufEnter <buffer> :" . g:taskwiki_py . "cache.load_current().reset()"
" Refresh on load (if possible, after loadview to preserve folds)
if has('patch-8.1.1113') || has('nvim-0.4.0')
autocmd BufWinEnter <buffer> ++once TaskWikiBufferLoad
else
TaskWikiBufferLoad
endif
" Update reviewed date when exiting a review
execute "autocmd BufUnload <buffer> :" . g:taskwiki_py . "TaskWikiReview().update()"
augroup END
" Split reports commands
execute "command! -buffer -nargs=* TaskWikiProjects :" . g:taskwiki_py . "SplitProjects(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiProjectsSummary :" . g:taskwiki_py . "SplitSummary(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiBurndownDaily :" . g:taskwiki_py . "SplitBurndownDaily(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiBurndownMonthly :" . g:taskwiki_py . "SplitBurndownMonthly(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiBurndownWeekly :" . g:taskwiki_py . "SplitBurndownWeekly(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiCalendar :" . g:taskwiki_py . "SplitCalendar(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiGhistoryAnnual :" . g:taskwiki_py . "SplitGhistoryAnnual(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiGhistoryMonthly :" . g:taskwiki_py . "SplitGhistoryMonthly(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiHistoryAnnual :" . g:taskwiki_py . "SplitHistoryAnnual(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiHistoryMonthly :" . g:taskwiki_py . "SplitHistoryMonthly(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiStats :" . g:taskwiki_py . "SplitStats(<q-args>).execute()"
execute "command! -buffer -nargs=* TaskWikiTags :" . g:taskwiki_py . "SplitTags(<q-args>).execute()"
" Commands that operate on tasks in the buffer
execute "command! -buffer -range TaskWikiInfo :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().info()"
execute "command! -buffer -range TaskWikiEdit :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().edit()"
execute "command! -buffer -range TaskWikiLink :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().link()"
execute "command! -buffer -range TaskWikiGrid :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().grid()"
execute "command! -buffer -range TaskWikiDelete :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().delete()"
execute "command! -buffer -range TaskWikiStart :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().start()"
execute "command! -buffer -range TaskWikiStop :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().stop()"
execute "command! -buffer -range TaskWikiDone :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().done()"
execute "command! -buffer -range TaskWikiRedo :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().redo()"
execute "command! -buffer -range -nargs=* TaskWikiSort :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().sort(<q-args>)"
execute "command! -buffer -range -nargs=* TaskWikiMod :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().modify(<q-args>)"
execute "command! -buffer -range -nargs=* TaskWikiAnnotate :<line1>,<line2>" . g:taskwiki_py . "SelectedTasks().annotate(<q-args>)"
" Interactive commands
execute "command! -buffer -range TaskWikiChooseProject :<line1>,<line2>" . g:taskwiki_py . "ChooseSplitProjects('global').execute()"
execute "command! -buffer -range TaskWikiChooseTag :<line1>,<line2>" . g:taskwiki_py . "ChooseSplitTags('global').execute()"
" Meta commands
execute "command! -buffer TaskWikiInspect :" . g:taskwiki_py . "Meta().inspect_viewport()"
" Disable <CR> as VimwikiFollowLink
if !hasmapto('<Plug>VimwikiFollowLink')
nmap <Plug>NoVimwikiFollowLink <Plug>VimwikiFollowLink
endif
execute "nnoremap <silent><buffer> <CR> :" . g:taskwiki_py . "Mappings.task_info_or_vimwiki_follow_link()<CR>"
" Leader-related mappings. Mostly <Leader>t + <first letter of the action>
if !exists('g:taskwiki_suppress_mappings')
if exists('g:taskwiki_maplocalleader')
let maplocalleader = g:taskwiki_maplocalleader
else
if exists('g:mapleader')
let maplocalleader = g:mapleader.'t'
else
let maplocalleader = '\t'
endif
endif
nnoremap <silent><buffer> <LocalLeader>a :TaskWikiAnnotate<CR>
nnoremap <silent><buffer> <LocalLeader>bd :TaskWikiBurndownDaily<CR>
nnoremap <silent><buffer> <LocalLeader>bw :TaskWikiBurndownWeekly<CR>
nnoremap <silent><buffer> <LocalLeader>bm :TaskWikiBurndownMonthly<CR>
nnoremap <silent><buffer> <LocalLeader>cp :TaskWikiChooseProject<CR>
nnoremap <silent><buffer> <LocalLeader>ct :TaskWikiChooseTag<CR>
nnoremap <silent><buffer> <LocalLeader>C :TaskWikiCalendar<CR>
nnoremap <silent><buffer> <LocalLeader>d :TaskWikiDone<CR>
nnoremap <silent><buffer> <LocalLeader>D :TaskWikiDelete<CR>
nnoremap <silent><buffer> <LocalLeader>e :TaskWikiEdit<CR>
nnoremap <silent><buffer> <LocalLeader>g :TaskWikiGrid<CR>
nnoremap <silent><buffer> <LocalLeader>Gm :TaskWikiGhistoryMonthly<CR>
nnoremap <silent><buffer> <LocalLeader>Ga :TaskWikiGhistoryAnnual<CR>
nnoremap <silent><buffer> <LocalLeader>hm :TaskWikiHistoryMonthly<CR>
nnoremap <silent><buffer> <LocalLeader>ha :TaskWikiHistoryAnnual<CR>
nnoremap <silent><buffer> <LocalLeader>i :TaskWikiInfo<CR>
nnoremap <silent><buffer> <LocalLeader>l :TaskWikiLink<CR>
nnoremap <silent><buffer> <LocalLeader>m :TaskWikiMod<CR>
nnoremap <silent><buffer> <LocalLeader>p :TaskWikiProjects<CR>
nnoremap <silent><buffer> <LocalLeader>s :TaskWikiProjectsSummary<CR>
nnoremap <silent><buffer> <LocalLeader>S :TaskWikiStats<CR>
nnoremap <silent><buffer> <LocalLeader>t :TaskWikiTags<CR>
nnoremap <silent><buffer> <LocalLeader>. :TaskWikiRedo<CR>
nnoremap <silent><buffer> <LocalLeader>+ :TaskWikiStart<CR>
nnoremap <silent><buffer> <LocalLeader>- :TaskWikiStop<CR>
nnoremap <silent><buffer> <LocalLeader>r :TaskWikiReview<CR>
" Mappings for visual mode.
vnoremap <silent><buffer> <LocalLeader>a :TaskWikiAnnotate<CR>
vnoremap <silent><buffer> <LocalLeader>cp :TaskWikiChooseProject<CR>
vnoremap <silent><buffer> <LocalLeader>ct :TaskWikiChooseTag<CR>
vnoremap <silent><buffer> <LocalLeader>d :TaskWikiDone<CR>
vnoremap <silent><buffer> <LocalLeader>D :TaskWikiDelete<CR>
vnoremap <silent><buffer> <LocalLeader>e :TaskWikiEdit<CR>
vnoremap <silent><buffer> <LocalLeader>g :TaskWikiGrid<CR>
vnoremap <silent><buffer> <LocalLeader>i :TaskWikiInfo<CR>
vnoremap <silent><buffer> <LocalLeader>l :TaskWikiLink<CR>
vnoremap <silent><buffer> <LocalLeader>m :TaskWikiMod<CR>
vnoremap <silent><buffer> <LocalLeader>. :TaskWikiRedo<CR>
vnoremap <silent><buffer> <LocalLeader>+ :TaskWikiStart<CR>
vnoremap <silent><buffer> <LocalLeader>- :TaskWikiStop<CR>
endif