aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-06-03 09:37:02 -0400
committerTeddy Wing2016-06-03 09:37:02 -0400
commitcaec071d634877f05d53acf4f38a1039a1f162d9 (patch)
treea09339eb354368cbd6f55c3c53893c7c0a75ab22
parent17684a8b4898e5aecd33b86689c386e483ab698f (diff)
downloadvim-twodo-caec071d634877f05d53acf4f38a1039a1f162d9.tar.bz2
Add Escalate mapping
Define the `todo#Escalate()` function which does the opposite of `todo#Descalate()` and add a mapping to invoke the function.
-rw-r--r--autoload/todo.vim14
-rw-r--r--ftplugin/todo.vim5
2 files changed, 19 insertions, 0 deletions
diff --git a/autoload/todo.vim b/autoload/todo.vim
index 926f1e7..758d0d5 100644
--- a/autoload/todo.vim
+++ b/autoload/todo.vim
@@ -1,4 +1,18 @@
function! todo#Escalate()
+ let todo = getline('.')
+
+ " First non-whitespace character
+ let col = match(todo, '\S')
+
+ let priority = todo[col]
+
+ if priority ==# '_'
+ let todo = substitute(todo, '_', '-', '')
+ elseif priority ==# '-'
+ let todo = substitute(todo, '-', '!', '')
+ endif
+
+ call setline(line('.'), todo)
endfunction
diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim
index 85b2b66..f392c94 100644
--- a/ftplugin/todo.vim
+++ b/ftplugin/todo.vim
@@ -10,6 +10,7 @@ nnoremap <silent> <buffer> <Plug>TwodoMarkComplete m`:<c-u>s/\v^(\s*)[-_!xS] /\1
nnoremap <silent> <buffer> <Plug>TwodoMarkDeleted m`:<c-u>s/\v^(\s*)[-_!vS] /\1x / \| nohlsearch<cr>``
nnoremap <silent> <buffer> <Plug>TwodoMarkPartiallyCompleted m`:<c-u>s/\v^(\s*)[-_!xv] /\1S / \| nohlsearch<cr>``
nnoremap <silent> <buffer> <Plug>TwodoRemoveOldTodos :<c-u>g/^\s*[vx] /d \| nohlsearch<cr>
+nnoremap <silent> <buffer> <Plug>TwodoEscalate :<c-u>call todo#Escalate()<cr>
nnoremap <silent> <buffer> <Plug>TwodoDescalate :<c-u>call todo#Descalate()<cr>
if !hasmapto('<Plug>TwodoNewTodoBelow') || !maparg('<leader>n', 'n')
@@ -36,6 +37,10 @@ if !hasmapto('<Plug>TwodoRemoveOldTodos') || !maparg('<leader>R', 'n')
nmap <silent> <buffer> <leader>R <Plug>TwodoRemoveOldTodos
endif
+if !hasmapto('<Plug>TwodoEscalate') || !maparg('<leader>=', 'n')
+ nmap <silent> <buffer> <leader>= <Plug>TwodoEscalate
+endif
+
if !hasmapto('<Plug>TwodoDescalate') || !maparg('<leader>-', 'n')
nmap <silent> <buffer> <leader>- <Plug>TwodoDescalate
endif