]> git.sev.monster Git - dotfiles.git/blob - base/.vim/ftplugin/todo.vim
fixed .config not being added
[dotfiles.git] / base / .vim / ftplugin / todo.vim
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
9 let s:save_cpo = &cpo
10 set 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.
16 setlocal textwidth=0
17 setlocal wrapmargin=0
18
19 " Mappings {{{1
20 " Sort tasks {{{2
21 nnoremap <script> <silent> <buffer> <localleader>s :%sort<CR>
22 vnoremap <script> <silent> <buffer> <localleader>s :sort<CR>
23 nnoremap <script> <silent> <buffer> <localleader>s@ :%call todo#txt#sort_by_context()<CR>
24 vnoremap <script> <silent> <buffer> <localleader>s@ :call todo#txt#sort_by_context()<CR>
25 nnoremap <script> <silent> <buffer> <localleader>s+ :%call todo#txt#sort_by_project()<CR>
26 vnoremap <script> <silent> <buffer> <localleader>s+ :call todo#txt#sort_by_project()<CR>
27 nnoremap <script> <silent> <buffer> <localleader>sd :%call todo#txt#sort_by_date()<CR>
28 vnoremap <script> <silent> <buffer> <localleader>sd :call todo#txt#sort_by_date()<CR>
29 nnoremap <script> <silent> <buffer> <localleader>sdd :%call todo#txt#sort_by_due_date()<CR>
30 vnoremap <script> <silent> <buffer> <localleader>sdd :call todo#txt#sort_by_due_date()<CR>
31
32 " Change priority {{{2
33 nnoremap <script> <silent> <buffer> <localleader>j :call todo#txt#prioritize_increase()<CR>
34 vnoremap <script> <silent> <buffer> <localleader>j :call todo#txt#prioritize_increase()<CR>
35 nnoremap <script> <silent> <buffer> <localleader>k :call todo#txt#prioritize_decrease()<CR>
36 vnoremap <script> <silent> <buffer> <localleader>k :call todo#txt#prioritize_decrease()<CR>
37 nnoremap <script> <silent> <buffer> <localleader>a :call todo#txt#prioritize_add('A')<CR>
38 vnoremap <script> <silent> <buffer> <localleader>a :call todo#txt#prioritize_add('A')<CR>
39 nnoremap <script> <silent> <buffer> <localleader>b :call todo#txt#prioritize_add('B')<CR>
40 vnoremap <script> <silent> <buffer> <localleader>b :call todo#txt#prioritize_add('B')<CR>
41 nnoremap <script> <silent> <buffer> <localleader>c :call todo#txt#prioritize_add('C')<CR>
42 vnoremap <script> <silent> <buffer> <localleader>c :call todo#txt#prioritize_add('C')<CR>
43
44 " Insert date {{{2
45 inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
46 nnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
47 vnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
48
49 " Mark done {{{2
50 nnoremap <script> <silent> <buffer> <localleader>x :call todo#txt#mark_as_done()<CR>
51 vnoremap <script> <silent> <buffer> <localleader>x :call todo#txt#mark_as_done()<CR>
52
53 " Mark all done {{{2
54 nnoremap <script> <silent> <buffer> <localleader>X :call todo#txt#mark_all_as_done()<CR>
55
56 " Remove completed {{{2
57 nnoremap <script> <silent> <buffer> <localleader>D :call todo#txt#remove_completed()<CR>
58
59 " Folding {{{1
60 " Options {{{2
61 setlocal foldmethod=expr
62 setlocal foldexpr=s:todo_fold_level(v:lnum)
63 setlocal foldtext=s:todo_fold_text()
64
65 " s:todo_fold_level(lnum) {{{2
66 function! 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
76 endfunction
77
78 " s:todo_fold_text() {{{2
79 function! 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 '
85 endfunction
86
87 " Restore context {{{1
88 let &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.041871 seconds and 4 git commands to generate.