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
(C) 2011-05-30 Create README.markdown to be published in github @doc
(C) 2011-06-01 Improve syntax file @syntax
2011-05-30 Contact main project for reference
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 filetype detection @ftdetect
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 Stop breaking lines automatically @ftplugin
X 2011-06-06 Easier date input @ftplugin
X 2011-06-06 Implement foldings @ftplugin

View File

@@ -3,26 +3,45 @@
" Author: Leandro Freitas <freitass@gmail.com>
" Licence: Vim licence
" 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
" time this script is invocated, which is whenever a file of this type is
" created or edited.
setlocal textwidth=0
setlocal wrapmargin=0
if exists("g:loaded_todo")
finish
" Mappings {{{1
" Sort tasks {{{2
if !hasmapto("<leader>s",'n')
nnoremap <script> <silent> <buffer> <leader>s :sort<CR>
endif
let g:loaded_todo = 1
let s:save_cpo = &cpo
set cpo&vim
" Insert date {{{2
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 foldexpr=TodoFoldLevel(v:lnum)
setlocal foldtext=TodoFoldText()
" TodoFoldLevel(lnum) {{{2
function! TodoFoldLevel(lnum)
" 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
@@ -35,12 +54,16 @@ function! TodoFoldLevel(lnum)
return match(getline(a:lnum),'^[xX]\s.\+$') + 1
endfunction
" TodoFoldText() {{{2
function! TodoFoldText()
" The text displayed at the fold is formatted as '+- N Completed tasks'
" where N is the number of lines folded.
return '+' . v:folddashes . ' '
\ . (v:foldend - v:foldstart + 1)
\ . ' Completed tasks'
\ . ' Completed tasks '
endfunction
" Restore context {{{1
let &cpo = s:save_cpo
" Modeline {{{1
" vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1