aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-27 17:18:35 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-27 17:18:35 +1200
commit3f73517e2dd1be08af6588b3d49cf470e0fb4acd (patch)
treee0ca1e212d04029ba5e20119a702b42409c6359c
parente82ab7f7b65c86d908ded5401ee6c1e6f844657a (diff)
parent595f866f02f5a49b339bdf358ee3760950f0f3a2 (diff)
downloaddotfiles-3f73517e2dd1be08af6588b3d49cf470e0fb4acd.tar.gz
Merge branch 'release/v1.62.0'v1.62.0
* release/v1.62.0: Bump VERSION Improve diff block navigation in Vim with function Correct a comment Silence Vim diff section navigation maps Use local leader keys in Vim diff section nav maps Use search() in Vim diff section navigation maps
-rw-r--r--VERSION4
-rw-r--r--vim/after/ftplugin/diff.vim24
-rw-r--r--vim/after/ftplugin/mail.vim2
-rw-r--r--vim/autoload/diff.vim29
4 files changed, 51 insertions, 8 deletions
diff --git a/VERSION b/VERSION
index 51fdab64..fceba156 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v1.61.0
-Sun Aug 26 05:40:26 UTC 2018
+tejr dotfiles v1.62.0
+Mon Aug 27 05:18:35 UTC 2018
diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim
index eecc8b8c..a52b3fdd 100644
--- a/vim/after/ftplugin/diff.vim
+++ b/vim/after/ftplugin/diff.vim
@@ -8,11 +8,25 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps')
finish
endif
-" Modify curly braces to navigate by diff block
-nnoremap <buffer> { ?^@@<CR>
-nnoremap <buffer> } /^@@<CR>
-let b:undo_ftplugin .= '|nunmap <buffer> {'
- \ . '|nunmap <buffer> }'
+" Maps using autoloaded function for quoted block movement
+nnoremap <buffer> <silent> <LocalLeader>[
+ \ :<C-U>call diff#MoveBlock(v:count1, 1, 0)<CR>
+nnoremap <buffer> <silent> <LocalLeader>]
+ \ :<C-U>call diff#MoveBlock(v:count1, 0, 0)<CR>
+onoremap <buffer> <silent> <LocalLeader>[
+ \ :<C-U>call diff#MoveBlock(v:count1, 1, 0)<CR>
+onoremap <buffer> <silent> <LocalLeader>]
+ \ :<C-U>call diff#MoveBlock(v:count1, 0, 0)<CR>
+xnoremap <buffer> <silent> <LocalLeader>[
+ \ :<C-U>call diff#MoveBlock(v:count1, 1, 1)<CR>
+xnoremap <buffer> <silent> <LocalLeader>]
+ \ :<C-U>call diff#MoveBlock(v:count1, 0, 1)<CR>
+let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>['
+ \ . '|nunmap <buffer> <LocalLeader>]'
+ \ . '|ounmap <buffer> <LocalLeader>['
+ \ . '|ounmap <buffer> <LocalLeader>]'
+ \ . '|xunmap <buffer> <LocalLeader>['
+ \ . '|xunmap <buffer> <LocalLeader>]'
" Set mappings
nmap <buffer> <LocalLeader>p
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 4b6c827c..3aa3fec3 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -64,7 +64,7 @@ let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q'
\ . '|nunmap <buffer> <LocalLeader>QQ'
\ . '|xunmap <buffer> <LocalLeader>Q'
-" Maps using NewBlank() function above for quoted paragraph movement
+" Maps using autoloaded function for quoted paragraph movement
nnoremap <buffer> <silent> <LocalLeader>[
\ :<C-U>call mail#NewBlank(v:count1, 1, 0)<CR>
nnoremap <buffer> <silent> <LocalLeader>]
diff --git a/vim/autoload/diff.vim b/vim/autoload/diff.vim
new file mode 100644
index 00000000..32e9333a
--- /dev/null
+++ b/vim/autoload/diff.vim
@@ -0,0 +1,29 @@
+" Move between diff block headers
+function! diff#MoveBlock(count, up, visual) abort
+
+ " Reselect visual selection
+ if a:visual
+ normal! gv
+ endif
+
+ " Flag for the number of blocks passed
+ let l:blocks = 0
+
+ " Iterate through buffer lines
+ let l:num = line('.')
+ while a:up ? l:num > 1 : l:num < line('$')
+ let l:num += a:up ? -1 : 1
+ if getline(l:num) =~# '^@@'
+ let l:blocks += 1
+ if l:blocks == a:count
+ break
+ endif
+ endif
+ endwhile
+
+ " Move to line if nonzero and not equal to the current line
+ if l:num != line('.')
+ execute 'normal '.l:num.'G'
+ endif
+
+endfunction