]> git.sev.monster Git - dotfiles.git/blame_incremental - .vim/ftplugin/todo.vim
initial commit
[dotfiles.git] / .vim / ftplugin / todo.vim
... / ...
CommitLineData
1" File: todo.txt.vim
2" Description: Todo.txt filetype detection
3" Author: Leandro Freitas <freitass@gmail.com>
4" License: Vim license
5" Website: http://github.com/freitass/todo.txt-vim
6" Version: 0.4
7
8" Save context {{{1
9let s:save_cpo = &cpo
10set cpo&vim
11
12" General options {{{1
13" Some options lose their values when window changes. They will be set every
14" time this script is invocated, which is whenever a file of this type is
15" created or edited.
16setlocal textwidth=0
17setlocal wrapmargin=0
18
19" Mappings {{{1
20" Sort tasks {{{2
21nnoremap <script> <silent> <buffer> <localleader>s :%sort<CR>
22vnoremap <script> <silent> <buffer> <localleader>s :sort<CR>
23nnoremap <script> <silent> <buffer> <localleader>s@ :%call todo#txt#sort_by_context()<CR>
24vnoremap <script> <silent> <buffer> <localleader>s@ :call todo#txt#sort_by_context()<CR>
25nnoremap <script> <silent> <buffer> <localleader>s+ :%call todo#txt#sort_by_project()<CR>
26vnoremap <script> <silent> <buffer> <localleader>s+ :call todo#txt#sort_by_project()<CR>
27nnoremap <script> <silent> <buffer> <localleader>sd :%call todo#txt#sort_by_date()<CR>
28vnoremap <script> <silent> <buffer> <localleader>sd :call todo#txt#sort_by_date()<CR>
29nnoremap <script> <silent> <buffer> <localleader>sdd :%call todo#txt#sort_by_due_date()<CR>
30vnoremap <script> <silent> <buffer> <localleader>sdd :call todo#txt#sort_by_due_date()<CR>
31
32" Change priority {{{2
33nnoremap <script> <silent> <buffer> <localleader>j :call todo#txt#prioritize_increase()<CR>
34vnoremap <script> <silent> <buffer> <localleader>j :call todo#txt#prioritize_increase()<CR>
35nnoremap <script> <silent> <buffer> <localleader>k :call todo#txt#prioritize_decrease()<CR>
36vnoremap <script> <silent> <buffer> <localleader>k :call todo#txt#prioritize_decrease()<CR>
37nnoremap <script> <silent> <buffer> <localleader>a :call todo#txt#prioritize_add('A')<CR>
38vnoremap <script> <silent> <buffer> <localleader>a :call todo#txt#prioritize_add('A')<CR>
39nnoremap <script> <silent> <buffer> <localleader>b :call todo#txt#prioritize_add('B')<CR>
40vnoremap <script> <silent> <buffer> <localleader>b :call todo#txt#prioritize_add('B')<CR>
41nnoremap <script> <silent> <buffer> <localleader>c :call todo#txt#prioritize_add('C')<CR>
42vnoremap <script> <silent> <buffer> <localleader>c :call todo#txt#prioritize_add('C')<CR>
43
44" Insert date {{{2
45inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
46nnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
47vnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
48
49" Mark done {{{2
50nnoremap <script> <silent> <buffer> <localleader>x :call todo#txt#mark_as_done()<CR>
51vnoremap <script> <silent> <buffer> <localleader>x :call todo#txt#mark_as_done()<CR>
52
53" Mark all done {{{2
54nnoremap <script> <silent> <buffer> <localleader>X :call todo#txt#mark_all_as_done()<CR>
55
56" Remove completed {{{2
57nnoremap <script> <silent> <buffer> <localleader>D :call todo#txt#remove_completed()<CR>
58
59" Folding {{{1
60" Options {{{2
61setlocal foldmethod=expr
62setlocal foldexpr=s:todo_fold_level(v:lnum)
63setlocal foldtext=s:todo_fold_text()
64
65" s:todo_fold_level(lnum) {{{2
66function! s:todo_fold_level(lnum)
67 " The match function returns the index of the matching pattern or -1 if
68 " the pattern doesn't match. In this case, we always try to match a
69 " completed task from the beginning of the line so that the matching
70 " function will always return -1 if the pattern doesn't match or 0 if the
71 " pattern matches. Incrementing by one the value returned by the matching
72 " function we will return 1 for the completed tasks (they will be at the
73 " first folding level) while for the other lines 0 will be returned,
74 " indicating that they do not fold.
75 return match(getline(a:lnum),'^[xX]\s.\+$') + 1
76endfunction
77
78" s:todo_fold_text() {{{2
79function! s:todo_fold_text()
80 " The text displayed at the fold is formatted as '+- N Completed tasks'
81 " where N is the number of lines folded.
82 return '+' . v:folddashes . ' '
83 \ . (v:foldend - v:foldstart + 1)
84 \ . ' Completed tasks '
85endfunction
86
87" Restore context {{{1
88let &cpo = s:save_cpo
89" Modeline {{{1
90" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1
This page took 0.031699 seconds and 4 git commands to generate.