aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION4
-rw-r--r--vim/autoload/vimrc.vim39
m---------vim/bundle/fixed_join0
-rw-r--r--vim/vimrc7
4 files changed, 46 insertions, 4 deletions
diff --git a/VERSION b/VERSION
index 04945fbb..1dcd1d76 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v1.2.0
-Sun Jun 24 23:54:16 UTC 2018
+tejr dotfiles v1.3.0
+Mon Jun 25 02:01:41 UTC 2018
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
new file mode 100644
index 00000000..eaeefd5d
--- /dev/null
+++ b/vim/autoload/vimrc.vim
@@ -0,0 +1,39 @@
+" Get all buffer-local mappings into a string variable
+function! vimrc#GetBufferLocalMaps() abort
+ redir => l:out
+ map <buffer>
+ redir END
+ let g:vimrc#buffer_local_maps = l:out
+endfunction
+
+" Clear all buffer-local mappings beginning with <LocalLeader>
+function! vimrc#ClearLocalLeaderMaps() abort
+
+ " Do nothing if there isn't a defined local leader
+ if !exists('g:maplocalleader')
+ return
+ endif
+
+ " Get all the buffer-local mappings into a list
+ silent call vimrc#GetBufferLocalMaps()
+ let l:mappings = split(g:vimrc#buffer_local_maps, '\n')
+
+ " Iterate through the mappings
+ for l:mapping in l:mappings
+
+ " Match the list mapping and mode; skip if no match
+ let l:matchlist = matchlist(l:mapping, '\m\C^\(.\)\s\+\(\S\+\)')
+ if !len(l:matchlist)
+ continue
+ endif
+ let l:mode = l:matchlist[1]
+ let l:sequence = l:matchlist[2]
+
+ " If the mapping starts with our local leader, clear it
+ if stridx(l:sequence, g:maplocalleader) == 0
+ execute l:mode.'unmap <buffer> '.l:sequence
+ endif
+
+ endfor
+
+endfunction
diff --git a/vim/bundle/fixed_join b/vim/bundle/fixed_join
-Subproject f4564785ea7538d91a9400d082fea4ba8eed8ac
+Subproject 5e55ca6dd34e8a6caed0e265e5e94fd63a92732
diff --git a/vim/vimrc b/vim/vimrc
index a6a3beae..86f13359 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -200,6 +200,9 @@ nnoremap ]t :<C-U>tabnext<CR>
nmap [<Space> <Plug>PutBlankLinesAbove
nmap ]<Space> <Plug>PutBlankLinesBelow
+" Remap normal J to hold the cursor still while joining lines
+nmap J <Plug>FixedJoin
+
" Remap normal Y to yank to end of line (consistent with C, D)
nnoremap Y y$
@@ -277,8 +280,8 @@ if has('autocmd') && v:version >= 700
augroup vimrc_filetype_mappings
autocmd!
- " Clear away existing local mappings
- autocmd FileType * mapclear <buffer>
+ " Clear existing local leader maps
+ autocmd FileType * call vimrc#ClearLocalLeaderMaps()
" Diff: prune sections
autocmd FileType diff nmap <buffer> _p <Plug>DiffPrune