/unite-taskwarrior

A unite.vim interface to taskwarrior

Primary LanguageVimL

Unite-taskwarrior

A unite.vim interface to task warrior.

This is meant to be a simple interface to taskwarrior, that works faster than vim-taskwarrior. Plus I like Unite's interface also I may suffer from a severe case of NIH syndrome.

This code was based off of unite-todo. That tool provides a pretty good simple task system for inside vim. I used it for a bit but also needed something for use outside vim. taskwarrior does that, but I prefer a simpler interface much of the time.

Requirements

  • unite

  • vimproc

  • taskwarrior Taskwarrior should be configured to not prompt for stuff. I use:

    echo.command=yes
    verbose=no
    confirmation=no
    

    I've only tested this with version 2.4.0.

Installing

Use a plugin manager. I like NeoBundle, Other options are: Vim-Plug, Vim-Pathogen, Vundle.

For NeoBundle add:

NeoBundle 'blakesweeney/unite-taskwarrior'

to your vimrc.

Screenshots

Add some.

Usage

This is a general overview of the functionality here, for details about this see the docs in doc/unite-taskwarrior.txt.

This doesn't come with any key bindings added by default, you should add your own as needed. Some useful configuration is:

" vimrc
NeoBundle 'blakesweeney/unite-taskwarrior'
call unite#custom#source('taskwarrior', 'matchers', 'matcher_fuzzy')
call unite#custom#source('taskwarrior', 'sorters', 'sorter_rank')

nnoremap <silent>  <Leader>T  :Unite taskwarrior -winheight=50<CR>
nnoremap           <Leader>Ta :UniteTaskWarriorAdd<CR>
vnoremap <silent>  <Leader>Ta :B UniteTaskWarriorAdd<CR>
nnoremap <silent>  <Leader>Tp :Unite taskwarrior/tags -vertical -winwidth=40

" ftplugin/unite.vim
inoremap <silent><buffer><expr> <C-t> unite#do_action('edit_tag')
nnoremap <silent><buffer><expr> <C-t> unite#do_action('edit_tag')
inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
nnoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')

The :B is from vis.vim which makes visual commands apply only the selected text, not the whole line. I highly recommend it as well. In ftplugin/unite.vim I use:

nnoremap <C-t> :call unite#do_action('edit_tag')

Commands:

:Unite taskwarrior                 " Show all tasks not marked as deleted
:Unite taskwarrior:$proj           " Show all tasks for the given project
:Unite taskwarrior:@tag            " Show all tasks with the given tag
:Unite taskwarrior:@tag:@other-tag " Show all tasks with tag and other-tag
:Unite taskwarrior/tags            " Show a tag listing
:Unite taskwarrior/projects        " Show a project listing
:UniteTaskwarriorAdd               " Add a task

The taskwarrior/tags and taskwarrior/projects sources generally produce long and narrow output. For these it's useful to open them with -vertical and -winwidth= to create nice vertical mapping. In the mappings above there is an example of doing this for projects.

Project list actions

  • open Show all tasks for the given project

    This can be run on several projects.

  • rename Rename the project.

Tag list actions

  • open Show all tasks with the given tag.

    This can be run on several tags.

  • rename Rename the tag.

Task list actions

  • do Complete this task.

    Can be used on several selected tasks.

  • delete Delete the the task

    Can be used on several selected tasks.

    By default is called by d.

  • edit Will edit the description of task.

    By default is called by e.

  • edit_tags Will edit the tags.

    Can be used on several tasks.

  • edit_proj Edit the project of the current task

    Can be used on several tasks.

  • open Will open a notes file for the task.

    By default is called by o.

  • preview Will preview the notes file.

    By default is called by p.

  • similar Show all similar tasks.

    TODO: Implement me

  • toggle Will toggle the task status. This is the default action. By default is called by <CR>. This will toggle between pending and completed.

    Can be used on several selected tasks.

  • view Provide a detailed view of the task.

Keybindings

There are some very experimental keybindings which are only available when using the taskwarrior source. These can be activated by adding:

let g:unite_taskwarrior_define_mappings = 1

to your vimrc. This provides the following normal mode mappings:

nnoremap <silent><buffer><expr> <TAB>       unite#do_action('toggle')
nnoremap <silent><buffer><expr> <CR>        unite#do_action('view')
nnoremap <silent><buffer><expr> d           unite#do_action('do')
nnoremap <silent><buffer><expr> D           unite#do_action('delete')
nnoremap <silent><buffer><expr> P           unite#do_action('edit_proj')
nnoremap <silent><buffer><expr> A           unite#do_action('annotate')
nnoremap <silent><buffer><expr> m           unite#do_action('modify')
nnoremap <silent><buffer><expr> e           unite#do_action('edit')
nnoremap <silent><buffer><expr> +           unite#do_action('start')
nnoremap <silent><buffer><expr> -           unite#do_action('stop')

There are examples in unite.vim's help of how to add other keybindings. If you want to add other bindings specific to a source you'll need to modify it with the example at Shougo/unite.vim#924.

Notes files

This provides some simple tasknote functionality. In the list of tasks you can open a file for a task using 'o' by default. This will be created with the description of the task. You can modify and save this file and re open it later. In some cases it's better to open the notes in a vsplit. Above in the mappings section there is a nnoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit'), which opens a note in a vertical split.

Running tests

First install the required packages with vim-flavor. You should only need to do run install to install everything needed. Then compile vimproc with:

$ cd .vim-flavor/deps/Shougo_vimproc.vim/
$ make -f make_mac.mak # If you have a mac
# If you don't have mac you'll have to choose the correct make file.

If run install doesn't install everything then install vim-flavor with bundler and use vim-flavor to install vim-vspec.

You can then run tests by doing ./run test. The script makes sure we use the correct task configuration and data directory.