From 54853a954c86dcebb936691c2e46b8253ed4d313 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Sat, 4 Jan 2014 16:43:45 -0500 Subject: [PATCH] Consider | for matchpairs. Also some minor formatting. Fix #155. --- autoload/delimitMate.vim | 24 +++++++++++++----------- plugin/delimitMate.vim | 11 ++--------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim index 87bce8d..1aae08b 100644 --- a/autoload/delimitMate.vim +++ b/autoload/delimitMate.vim @@ -471,13 +471,15 @@ function! delimitMate#ExpandReturn() "{{{ endif let escaped = delimitMate#CursorIdx() >= 2 \ && delimitMate#GetCharFromCursor(-2) == '\' - if !pumvisible() && ( - \ delimitMate#WithinEmptyMatchpair() - \ || (s:g('expand_cr') == 2 - \ && index(s:g('right_delims'), delimitMate#GetCharFromCursor(0)) > -1) - \ || (s:g('expand_inside_quotes') - \ && delimitMate#WithinEmptyQuotes() - \ && !escaped)) + let expand_right_matchpair = s:g('expand_cr') == 2 + \ && index(s:g('right_delims'), delimitMate#GetCharFromCursor(0)) > -1 + let expand_inside_quotes = s:g('expand_inside_quotes') + \ && delimitMate#WithinEmptyQuotes() + \ && !escaped + if !pumvisible() + \ && (delimitMate#WithinEmptyMatchpair() + \ || expand_right_matchpair + \ || expand_inside_quotes) " Expand: " XXX zv prevents breaking expansion with syntax folding enabled by " InsertLeave. @@ -493,10 +495,10 @@ function! delimitMate#ExpandSpace() "{{{ endif let escaped = delimitMate#CursorIdx() >= 2 \ && delimitMate#GetCharFromCursor(-2) == '\' - if delimitMate#WithinEmptyMatchpair() - \ || (s:g('expand_inside_quotes') - \ && delimitMate#WithinEmptyQuotes() - \ && !escaped) + let expand_inside_quotes = s:g('expand_inside_quotes') + \ && delimitMate#WithinEmptyQuotes() + \ && !escaped + if delimitMate#WithinEmptyMatchpair() || expand_inside_quotes " Expand: return "\\\" else diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index 8c22a50..3dff651 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -16,13 +16,6 @@ let g:loaded_delimitMate = 1 let save_cpo = &cpo set cpo&vim -if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing") - " Don't define the functions if they already exist: just do the work - " (unless we are testing): - call s:DelimitMateDo() - finish -endif - if v:version < 700 echoerr "delimitMate: this plugin requires vim >= 7!" finish @@ -294,6 +287,7 @@ function! s:AutoClose() "{{{ " Exit from inside the matching pair: for delim in s:g('right_delims') + let delim = delim == '|' ? '' : delim exec 'inoremap delimitMate' . delim \. ' TriggerAbb().delimitMate#JumpOut("\' . delim . '")' exec 'silent! imap ' . delim @@ -362,8 +356,6 @@ endfunction "}}} " Commands: {{{ -call s:DelimitMateDo() - " Let me refresh without re-loading the buffer: command! -bar DelimitMateReload call s:DelimitMateDo(1) @@ -388,6 +380,7 @@ augroup delimitMate \ call DelimitMateDo() | \ let b:delimitMate_was_here = 1 | \ endif + autocmd VimEnter * call DelimitMateDo() augroup END "}}}