This commit is contained in:
Leandro Freitas
2011-06-10 00:13:12 -03:00
parent eb9c759aea
commit 83da7c7f0b
2 changed files with 33 additions and 10 deletions

View File

@@ -1,13 +1,13 @@
(A) 2011-06-06 Easier date input @ftplugin (A) 2011-06-06 Check file syntax @syntax
(B) 2011-05-31 Start documentation @doc (B) 2011-05-31 Start documentation @doc
(C) 2011-05-30 Create README.markdown to be published in github @doc
(C) 2011-06-01 Improve syntax file @syntax (C) 2011-06-01 Improve syntax file @syntax
2011-05-30 Contact main project for reference 2011-05-30 Contact main project for reference
2011-05-30 Map commands to add, rm, ls, pri, depri etc @ftplugin 2011-05-30 Map commands to add, rm, ls, pri, depri etc @ftplugin
2011-06-06 Check file syntax @syntax X 2011-05-30 Create README.markdown to be published in github @doc
X 2011-05-30 Implement colorized priorities @syntax X 2011-05-30 Implement colorized priorities @syntax
X 2011-05-30 Implement filetype detection @ftdetect X 2011-05-30 Implement filetype detection @ftdetect
X 2011-05-30 Sort lines per priority @ftplugin X 2011-05-30 Sort lines per priority @ftplugin
X 2011-05-31 Highlight date, project and context of tasks with no priority @syntax X 2011-05-31 Highlight date, project and context of tasks with no priority @syntax
X 2011-05-31 Stop breaking lines automatically @ftplugin X 2011-05-31 Stop breaking lines automatically @ftplugin
X 2011-06-06 Easier date input @ftplugin
X 2011-06-06 Implement foldings @ftplugin X 2011-06-06 Implement foldings @ftplugin

View File

@@ -3,26 +3,45 @@
" Author: Leandro Freitas <freitass@gmail.com> " Author: Leandro Freitas <freitass@gmail.com>
" Licence: Vim licence " Licence: Vim licence
" Website: http://github.com/freitass/todo.txt.vim " Website: http://github.com/freitass/todo.txt.vim
" Version: 0.3 " Version: 0.4
" Save context {{{1
let s:save_cpo = &cpo
set cpo&vim
" General options {{{1
" Some options lose their values when window changes. They will be set every " Some options lose their values when window changes. They will be set every
" time this script is invocated, which is whenever a file of this type is " time this script is invocated, which is whenever a file of this type is
" created or edited. " created or edited.
setlocal textwidth=0 setlocal textwidth=0
setlocal wrapmargin=0 setlocal wrapmargin=0
if exists("g:loaded_todo") " Mappings {{{1
finish " Sort tasks {{{2
if !hasmapto("<leader>s",'n')
nnoremap <script> <silent> <buffer> <leader>s :sort<CR>
endif endif
let g:loaded_todo = 1
let s:save_cpo = &cpo " Insert date {{{2
set cpo&vim if !hasmapto("<leader>d",'n')
nnoremap <script> <silent> <buffer> <leader>d "=strftime("%Y-%m-%d")<CR>P
endif
if !hasmapto("date<Tab>",'i')
inoremap <script> <silent> <buffer> date<Tab> <C-R>=strftime("%Y-%m-%d")<CR>
endif
if !hasmapto("<leader>d",'v')
vnoremap <script> <silent> <buffer> <leader>d c<C-R>=strftime("%Y-%m-%d")<CR><Esc>
endif
" Folding {{{1
" Options {{{2
setlocal foldmethod=expr setlocal foldmethod=expr
setlocal foldexpr=TodoFoldLevel(v:lnum) setlocal foldexpr=TodoFoldLevel(v:lnum)
setlocal foldtext=TodoFoldText() setlocal foldtext=TodoFoldText()
" TodoFoldLevel(lnum) {{{2
function! TodoFoldLevel(lnum) function! TodoFoldLevel(lnum)
" The match function returns the index of the matching pattern or -1 if " The match function returns the index of the matching pattern or -1 if
" the pattern doesn't match. In this case, we always try to match a " the pattern doesn't match. In this case, we always try to match a
@@ -35,12 +54,16 @@ function! TodoFoldLevel(lnum)
return match(getline(a:lnum),'^[xX]\s.\+$') + 1 return match(getline(a:lnum),'^[xX]\s.\+$') + 1
endfunction endfunction
" TodoFoldText() {{{2
function! TodoFoldText() function! TodoFoldText()
" The text displayed at the fold is formatted as '+- N Completed tasks' " The text displayed at the fold is formatted as '+- N Completed tasks'
" where N is the number of lines folded. " where N is the number of lines folded.
return '+' . v:folddashes . ' ' return '+' . v:folddashes . ' '
\ . (v:foldend - v:foldstart + 1) \ . (v:foldend - v:foldstart + 1)
\ . ' Completed tasks' \ . ' Completed tasks '
endfunction endfunction
" Restore context {{{1
let &cpo = s:save_cpo let &cpo = s:save_cpo
" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1