" 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(':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()" augroup taskwiki autocmd! * " Update to TW upon saving autocmd BufWrite TaskWikiBufferSave " Save and load the view to preserve folding, if desired if !exists('g:taskwiki_dont_preserve_folds') autocmd BufWinLeave call taskwiki#MkView() autocmd BufWinEnter call taskwiki#LoadView() endif " Reset cache when switching buffers execute "autocmd BufEnter :" . g:taskwiki_py . "cache.load_current().reset()" " Update window-local fold options if !exists('g:taskwiki_dont_fold') autocmd BufWinEnter call taskwiki#FoldInit() endif " Refresh on load (if possible, after loadview to preserve folds) if has('patch-8.1.1113') || has('nvim-0.4.0') autocmd BufWinEnter ++once TaskWikiBufferLoad else TaskWikiBufferLoad endif augroup END " Split reports commands execute "command! -buffer -nargs=* TaskWikiProjects :" . g:taskwiki_py . "SplitProjects().execute()" execute "command! -buffer -nargs=* TaskWikiProjectsSummary :" . g:taskwiki_py . "SplitSummary().execute()" execute "command! -buffer -nargs=* TaskWikiBurndownDaily :" . g:taskwiki_py . "SplitBurndownDaily().execute()" execute "command! -buffer -nargs=* TaskWikiBurndownMonthly :" . g:taskwiki_py . "SplitBurndownMonthly().execute()" execute "command! -buffer -nargs=* TaskWikiBurndownWeekly :" . g:taskwiki_py . "SplitBurndownWeekly().execute()" execute "command! -buffer -nargs=* TaskWikiCalendar :" . g:taskwiki_py . "SplitCalendar().execute()" execute "command! -buffer -nargs=* TaskWikiGhistoryAnnual :" . g:taskwiki_py . "SplitGhistoryAnnual().execute()" execute "command! -buffer -nargs=* TaskWikiGhistoryMonthly :" . g:taskwiki_py . "SplitGhistoryMonthly().execute()" execute "command! -buffer -nargs=* TaskWikiHistoryAnnual :" . g:taskwiki_py . "SplitHistoryAnnual().execute()" execute "command! -buffer -nargs=* TaskWikiHistoryMonthly :" . g:taskwiki_py . "SplitHistoryMonthly().execute()" execute "command! -buffer -nargs=* TaskWikiStats :" . g:taskwiki_py . "SplitStats().execute()" execute "command! -buffer -nargs=* TaskWikiTags :" . g:taskwiki_py . "SplitTags().execute()" " Commands that operate on tasks in the buffer execute "command! -buffer -range TaskWikiInfo :," . g:taskwiki_py . "SelectedTasks().info()" execute "command! -buffer -range TaskWikiEdit :," . g:taskwiki_py . "SelectedTasks().edit()" execute "command! -buffer -range TaskWikiLink :," . g:taskwiki_py . "SelectedTasks().link()" execute "command! -buffer -range TaskWikiGrid :," . g:taskwiki_py . "SelectedTasks().grid()" execute "command! -buffer -range TaskWikiDelete :," . g:taskwiki_py . "SelectedTasks().delete()" execute "command! -buffer -range TaskWikiStart :," . g:taskwiki_py . "SelectedTasks().start()" execute "command! -buffer -range TaskWikiStop :," . g:taskwiki_py . "SelectedTasks().stop()" execute "command! -buffer -range TaskWikiToggle :," . g:taskwiki_py . "SelectedTasks().toggle()" execute "command! -buffer -range TaskWikiDone :," . g:taskwiki_py . "SelectedTasks().done()" execute "command! -buffer -range TaskWikiRedo :," . g:taskwiki_py . "SelectedTasks().redo()" execute "command! -buffer -range -nargs=* TaskWikiSort :," . g:taskwiki_py . "SelectedTasks().sort()" execute "command! -buffer -range -nargs=* TaskWikiAnnotate :," . g:taskwiki_py . "SelectedTasks().annotate()" execute "command! -buffer -range -nargs=* -complete=customlist,taskwiki#CompleteMod TaskWikiMod :," . g:taskwiki_py . "SelectedTasks().modify()" " Interactive commands execute "command! -buffer -range TaskWikiChooseProject :," . g:taskwiki_py . "ChooseSplitProjects('global').execute()" execute "command! -buffer -range TaskWikiChooseTag :," . g:taskwiki_py . "ChooseSplitTags('global').execute()" " Meta commands execute "command! -buffer TaskWikiInspect :" . g:taskwiki_py . "Meta().inspect_viewport()" if !exists('g:taskwiki_suppress_mappings') " Disable as VimwikiFollowLink if !hasmapto('VimwikiFollowLink') nmap NoVimwikiFollowLink VimwikiFollowLink endif if !exists("g:taskwiki_disable_cr_mapping") execute "nnoremap :" . g:taskwiki_py . "Mappings.task_info_or_vimwiki_follow_link()" endif " Leader-related mappings. Mostly t + 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 a :TaskWikiAnnotate nnoremap bd :TaskWikiBurndownDaily nnoremap bw :TaskWikiBurndownWeekly nnoremap bm :TaskWikiBurndownMonthly nnoremap cp :TaskWikiChooseProject nnoremap ct :TaskWikiChooseTag nnoremap C :TaskWikiCalendar nnoremap d :TaskWikiDone nnoremap D :TaskWikiDelete nnoremap e :TaskWikiEdit nnoremap g :TaskWikiGrid nnoremap Gm :TaskWikiGhistoryMonthly nnoremap Ga :TaskWikiGhistoryAnnual nnoremap hm :TaskWikiHistoryMonthly nnoremap ha :TaskWikiHistoryAnnual nnoremap i :TaskWikiInfo nnoremap l :TaskWikiLink nnoremap m :TaskWikiMod nnoremap p :TaskWikiProjects nnoremap s :TaskWikiProjectsSummary nnoremap S :TaskWikiStats nnoremap t :TaskWikiTags nnoremap . :TaskWikiRedo nnoremap + :TaskWikiStart nnoremap - :TaskWikiStop " Mappings for visual mode. vnoremap a :TaskWikiAnnotate vnoremap cp :TaskWikiChooseProject vnoremap ct :TaskWikiChooseTag vnoremap d :TaskWikiDone vnoremap D :TaskWikiDelete vnoremap e :TaskWikiEdit vnoremap g :TaskWikiGrid vnoremap i :TaskWikiInfo vnoremap l :TaskWikiLink vnoremap m :TaskWikiMod vnoremap . :TaskWikiRedo vnoremap + :TaskWikiStart vnoremap - :TaskWikiStop endif