Skip to content

Instantly share code, notes, and snippets.

@soh335
Created May 8, 2009 04:39
Show Gist options
  • Save soh335/108622 to your computer and use it in GitHub Desktop.
Save soh335/108622 to your computer and use it in GitHub Desktop.
"{{{ taskpaper.vim
map <silent><space>td <Plug>ToggleDone
function! s:OpenTaskPaper()
let g:Taskpaper_default_path = '/path/to/file'
execute 'e '.g:Taskpaper_default_path
setlocal noswapfile
setlocal nonumber
noremap <buffer> <silent> q :close<Cr>
endfunction
nnoremap <silent><space>ts :<C-u>split \| call <SID>OpenTaskPaper()<Cr>
nnoremap <silent><space>tv :<C-u>vsplit \| call <SID>OpenTaskPaper()<Cr>
"}}}
"taskpaper.vim indent file
"soh kitahara
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
setlocal indentexpr=GetTaskpaperIndent()
setlocal indentkeys+=<:>
function! GetTaskpaperIndent()
let pnum = prevnonblank(v:lnum - 1)
if pnum == 0
return 0
endif
let line = getline(v:lnum)
let pline = getline(pnum)
let ind = indent(pnum)
let project = '^.\+:\s*$'
let item = '^\s*[-+]\s\+'
if pline =~ project && pline !~ item
let ind = ind + &sw
elseif line =~ project && line !~ item
let ind = ind - &sw
endif
return ind
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment