diff options
-rw-r--r-- | .vim/UltiSnips/markdown.snippets | 3 | ||||
-rw-r--r-- | .vim/after/autoload/markdown.vim | 18 | ||||
-rw-r--r-- | .vim/after/ftplugin/markdown.vim | 3 |
3 files changed, 24 insertions, 0 deletions
diff --git a/.vim/UltiSnips/markdown.snippets b/.vim/UltiSnips/markdown.snippets new file mode 100644 index 0000000..6088ea8 --- /dev/null +++ b/.vim/UltiSnips/markdown.snippets @@ -0,0 +1,3 @@ +snippet todo "Create a TODO item" +* TODO :: ${0} +endsnippet diff --git a/.vim/after/autoload/markdown.vim b/.vim/after/autoload/markdown.vim new file mode 100644 index 0000000..1baac57 --- /dev/null +++ b/.vim/after/autoload/markdown.vim @@ -0,0 +1,18 @@ +let s:todo_items = ['TODO', 'DONE'] +let s:todo_items_regex = '\* \(TODO\|DONE\) ::' + +function! markdown#todo_items_set(state) abort + execute 's/' . s:todo_items_regex . '/* ' . a:state . ' ::/' +endfunction + +function! markdown#todo_items_set_next() abort + let l:line = getline('.') + + for i in range(len(s:todo_items)) + if l:line =~# ('.*\* ' . s:todo_items[i] . ' :: .*') + let l:next_todo_item_index = (i + 1) % len(s:todo_items) + let l:next_todo_item = s:todo_items[l:next_todo_item_index] + call markdown#todo_items_set(l:next_todo_item) + endif + endfor +endfunction diff --git a/.vim/after/ftplugin/markdown.vim b/.vim/after/ftplugin/markdown.vim index 9d2b097..a5a6268 100644 --- a/.vim/after/ftplugin/markdown.vim +++ b/.vim/after/ftplugin/markdown.vim @@ -7,3 +7,6 @@ setlocal iskeyword+=[,\- " setlocal formatoptions-=t " setlocal formatoptions-=c + +nnoremap <silent> <buffer> <localleader>t :call markdown#todo_items_set_next()<cr> +nnoremap <silent> <buffer> <localleader>Td :call markdown#todo_items_set('DONE')<cr> |