From 3687fc268f2797d26271d453a83e273211d36289 Mon Sep 17 00:00:00 2001 From: Konfekt Date: Fri, 3 Apr 2015 22:24:54 +0200 Subject: [PATCH] silence mappings and make operator maps more robust This makes the operator mappings work if not all of the following conditions are fulfilled: - `v` entered character-wise or block-wise visual mode, and - the visual mode map was mapped to the default key sequence --- autoload/vimtex/motion.vim | 55 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/autoload/vimtex/motion.vim b/autoload/vimtex/motion.vim index 3682d57..57c9953 100644 --- a/autoload/vimtex/motion.vim +++ b/autoload/vimtex/motion.vim @@ -11,34 +11,35 @@ function! vimtex#motion#init(initialized) " {{{1 " Set default options call vimtex#util#set_default('g:vimtex_motion_matchparen', 1) + nnoremap (v) v " Define mappings - nnoremap (vimtex-%) :call vimtex#motion#find_matching_pair() - xnoremap (vimtex-%) :call vimtex#motion#find_matching_pair(1) - onoremap (vimtex-%) :normal v% - nnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,0) - nnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,0) - nnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,0) - nnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,0) - xnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,1) - xnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,1) - xnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,1) - xnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,1) - onoremap (vimtex-]]) :normal v]] - onoremap (vimtex-][) :normal v][ - onoremap (vimtex-[]) :normal v[] - onoremap (vimtex-[[) :normal v[[ - xnoremap (vimtex-ie) :call vimtex#motion#sel_environment(1) - xnoremap (vimtex-ae) :call vimtex#motion#sel_environment() - onoremap (vimtex-ie) :normal vie - onoremap (vimtex-ae) :normal vae - xnoremap (vimtex-i$) :call vimtex#motion#sel_inline_math(1) - xnoremap (vimtex-a$) :call vimtex#motion#sel_inline_math() - onoremap (vimtex-i$) :normal vi$ - onoremap (vimtex-a$) :normal va$ - xnoremap (vimtex-id) :call vimtex#motion#sel_delimiter(1) - xnoremap (vimtex-ad) :call vimtex#motion#sel_delimiter() - onoremap (vimtex-id) :normal vi( - onoremap (vimtex-ad) :normal va( + nnoremap (vimtex-%) :call vimtex#motion#find_matching_pair() + xnoremap (vimtex-%) :call vimtex#motion#find_matching_pair(1) + onoremap (vimtex-%) :execute "normal \(v)\(vimtex-%)" + nnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,0) + nnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,0) + nnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,0) + nnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,0) + xnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,1) + xnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,1) + xnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,1) + xnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,1) + onoremap (vimtex-]]) :execute "normal \(v)\(vimtex-]])" + onoremap (vimtex-][) :execute "normal \(v)\(vimtex-][)" + onoremap (vimtex-[]) :execute "normal \(v)\(vimtex-[])" + onoremap (vimtex-[[) :execute "normal \(v)\(vimtex-[[])" + xnoremap (vimtex-ie) :call vimtex#motion#sel_environment(1) + xnoremap (vimtex-ae) :call vimtex#motion#sel_environment() + onoremap (vimtex-ie) :execute "normal \(v)\(vimtex-ie)" + onoremap (vimtex-ae) :execute "normal \(v)\(vimtex-ae)" + xnoremap (vimtex-i$) :call vimtex#motion#sel_inline_math(1) + xnoremap (vimtex-a$) :call vimtex#motion#sel_inline_math() + onoremap (vimtex-i$) :execute "normal \(v)\(vimtex-i$)" + onoremap (vimtex-a$) :execute "normal \(v)\(vimtex-a$)" + xnoremap (vimtex-id) :call vimtex#motion#sel_delimiter(1) + xnoremap (vimtex-ad) :call vimtex#motion#sel_delimiter() + onoremap (vimtex-id) :execute "normal \(v)\(vimtex-id)" + onoremap (vimtex-ad) :execute "normal \(v)\(vimtex-ad)" " Highlight matching parens ($, (), ...) if !a:initialized && g:vimtex_motion_matchparen