aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2024-04-10 20:19:18 +0800
committerGuangxiong Lin <[email protected]>2024-04-10 20:19:18 +0800
commit8edb3af29cd085a66b8a76010efe97e198eac109 (patch)
tree5101189bc292a34177edee33de576b032cf34408
parent8975ccf1c3b24c1088d3ec9449741a4092ba7ef5 (diff)
downloaddotfiles-8edb3af29cd085a66b8a76010efe97e198eac109.tar.gz
dotfiles-8edb3af29cd085a66b8a76010efe97e198eac109.tar.bz2
dotfiles-8edb3af29cd085a66b8a76010efe97e198eac109.zip
Add shortcuts to create todo items
-rw-r--r--.vim/UltiSnips/markdown.snippets3
-rw-r--r--.vim/after/autoload/markdown.vim18
-rw-r--r--.vim/after/ftplugin/markdown.vim3
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>