mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Replaced all s:vars by b:vars. Fixed test function.
This commit is contained in:
@@ -18,7 +18,8 @@
|
|||||||
" - Vim Scripts:
|
" - Vim Scripts:
|
||||||
" http://www.vim.org/scripts/
|
" http://www.vim.org/scripts/
|
||||||
|
|
||||||
if exists("g:loaded_delimitMate") "{{{1
|
" Initialization: {{{
|
||||||
|
if exists("g:loaded_delimitMate") "{{{
|
||||||
" User doesn't want this plugin, let's get out!
|
" User doesn't want this plugin, let's get out!
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
@@ -36,19 +37,21 @@ if v:version < 700
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1 " }}}1
|
let s:loaded_delimitMate = 1 " }}}
|
||||||
|
|
||||||
function! s:Init() "{{{1
|
function! s:Init() "{{{
|
||||||
|
|
||||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose") " {{{
|
" delimitMate_autoclose {{{
|
||||||
let s:autoclose = 1
|
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
||||||
elseif exists("b:delimitMate_autoclose")
|
let b:delimitMate_autoclose = 1
|
||||||
let s:autoclose = b:delimitMate_autoclose
|
elseif !exists("b:delimitMate_autoclose") && exists("g:delimitMate_autoclose")
|
||||||
|
let b:delimitMate_autoclose = g:delimitMate_autoclose
|
||||||
else
|
else
|
||||||
let s:autoclose = g:delimitMate_autoclose
|
" Nothing to do.
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs") " {{{
|
" delimitMate_matchpairs {{{
|
||||||
|
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
|
||||||
if s:ValidMatchpairs(&matchpairs) == 1
|
if s:ValidMatchpairs(&matchpairs) == 1
|
||||||
let s:matchpairs_temp = &matchpairs
|
let s:matchpairs_temp = &matchpairs
|
||||||
else
|
else
|
||||||
@@ -82,7 +85,8 @@ function! s:Init() "{{{1
|
|||||||
|
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if exists("b:delimitMate_quotes") " {{{
|
" delimitMate_quotes {{{
|
||||||
|
if exists("b:delimitMate_quotes")
|
||||||
if b:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || b:delimitMate_quotes == ""
|
if b:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || b:delimitMate_quotes == ""
|
||||||
let s:quotes = split(b:delimitMate_quotes)
|
let s:quotes = split(b:delimitMate_quotes)
|
||||||
else
|
else
|
||||||
@@ -98,62 +102,75 @@ function! s:Init() "{{{1
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let s:quotes = split("\" ' `")
|
let s:quotes = split("\" ' `")
|
||||||
endif " }}}
|
endif
|
||||||
|
if exists('b:delimitMate_quotes') | unlet b:delimitMate_quotes | endif
|
||||||
|
let b:delimitMate_quotes = s:quotes " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader") " {{{
|
" delimitMate_visual_leader {{{
|
||||||
if !exists("g:mapleader")
|
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
|
||||||
let s:visual_leader = "\\"
|
let b:delimitMate_visual_leader = exists('g:maplocalleader') ? g:maplocalleader :
|
||||||
else
|
\ exists('mapleader') ? g:mapleader : "\\"
|
||||||
let s:visual_leader = g:mapleader
|
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
|
||||||
endif
|
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
|
||||||
elseif exists("b:delimitMate_visual_leader")
|
|
||||||
let s:visual_leader = b:delimitMate_visual_leader
|
|
||||||
else
|
else
|
||||||
let s:visual_leader = g:delimitMate_visual_leader
|
" Nothing to do.
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space") " {{{
|
" delimitMate_expand_space {{{
|
||||||
let s:expand_space = 0
|
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
||||||
elseif exists("b:delimitMate_expand_space")
|
let b:delimitMate_expand_space = 0
|
||||||
let s:expand_space = b:delimitMate_expand_space
|
elseif !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
||||||
|
let b:delimitMate_expand_space = g:delimitMate_expand_space
|
||||||
else
|
else
|
||||||
let s:expand_space = g:delimitMate_expand_space
|
" Nothing to do.
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr") " {{{
|
" delimitMate_expand_cr {{{
|
||||||
let s:expand_cr = 0
|
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
|
||||||
elseif exists("b:delimitMate_expand_cr")
|
let b:delimitMate_expand_cr = 0
|
||||||
let s:expand_cr = b:delimitMate_expand_cr
|
elseif !exists("b:delimitMate_expand_cr") && exists("g:delimitMate_expand_cr")
|
||||||
|
let b:delimitMate_expand_cr = g:delimitMate_expand_cr
|
||||||
else
|
else
|
||||||
let s:expand_cr = g:delimitMate_expand_cr
|
" Nothing to do.
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes") " {{{
|
" delimitMate_smart_quotes {{{
|
||||||
|
if !exists("b:delimitMate_smart_quotes") && !exists("g:delimitMate_smart_quotes")
|
||||||
|
let b:delimitMate_smart_quotes = 1
|
||||||
|
elseif !exists("b:delimitMate_smart_quotes") && exists("g:delimitMate_smart_quotes")
|
||||||
|
let b:delimitMate_smart_quotes = split(g:delimitMate_smart_quotes)
|
||||||
|
else
|
||||||
|
" Nothing to do.
|
||||||
|
endif " }}}
|
||||||
|
|
||||||
|
" delimitMate_apostrophes {{{
|
||||||
|
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes")
|
||||||
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
|
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
|
||||||
let s:apostrophes = []
|
let b:delimitMate_apostrophes = []
|
||||||
|
elseif !exists("b:delimitMate_apostrophes") && exists("g:delimitMate_apostrophes")
|
||||||
elseif exists("b:delimitMate_apostrophes")
|
let b:delimitMate_apostrophes = split(g:delimitMate_apostrophes)
|
||||||
|
else
|
||||||
let s:apostrophes = split(b:delimitMate_apostrophes)
|
let s:apostrophes = split(b:delimitMate_apostrophes)
|
||||||
else
|
unlet b:delimitMate_apostrophes
|
||||||
let s:apostrophes = split(g:delimitMate_apostrophes)
|
let b:delimitMate_apostrophes = s:apostrophes
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit") " {{{
|
" delimitMate_tab2exit {{{
|
||||||
let s:tab2exit = 1
|
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
|
||||||
|
let b:delimitMate_tab2exit = 1
|
||||||
elseif exists("b:delimitMate_tab2exit")
|
elseif !exists("b:delimitMate_tab2exit") && exists("g:delimitMate_tab2exit")
|
||||||
let s:tab2exit = split(b:delimitMate_tab2exit)
|
let b:delimitMate_tab2exit = g:delimitMate_tab2exit
|
||||||
else
|
else
|
||||||
let s:tab2exit = split(g:delimitMate_tab2exit)
|
" Nothing to do.
|
||||||
endif " }}}
|
endif " }}}
|
||||||
|
|
||||||
let s:matchpairs = split(s:matchpairs_temp, ',')
|
let b:delimitMate_matchpairs = split(s:matchpairs_temp, ',')
|
||||||
let s:left_delims = split(s:matchpairs_temp, ':.,\=')
|
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
|
||||||
let s:right_delims = split(s:matchpairs_temp, ',\=.:')
|
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
|
||||||
let s:VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
let s:VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
||||||
|
|
||||||
"call s:UnMap()
|
call s:UnMap()
|
||||||
if s:autoclose
|
if b:delimitMate_autoclose
|
||||||
call s:AutoClose()
|
call s:AutoClose()
|
||||||
else
|
else
|
||||||
call s:NoAutoClose()
|
call s:NoAutoClose()
|
||||||
@@ -162,9 +179,11 @@ function! s:Init() "{{{1
|
|||||||
call s:ExtraMappings()
|
call s:ExtraMappings()
|
||||||
let b:loaded_delimitMate = 1
|
let b:loaded_delimitMate = 1
|
||||||
|
|
||||||
endfunction "}}}1 Init()
|
endfunction "}}} Init()
|
||||||
|
"}}}
|
||||||
|
|
||||||
function! s:ValidMatchpairs(str) "{{{1
|
" Utilities: {{{
|
||||||
|
function! s:ValidMatchpairs(str) "{{{
|
||||||
if a:str !~ '^.:.\(,.:.\)*$'
|
if a:str !~ '^.:.\(,.:.\)*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
@@ -174,46 +193,59 @@ function! s:ValidMatchpairs(str) "{{{1
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return 1
|
return 1
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! DelimitMate_ShouldJump() "{{{1
|
function! DelimitMate_ShouldJump() "{{{
|
||||||
let char = getline('.')[col('.') - 1]
|
let char = getline('.')[col('.') - 1]
|
||||||
for pair in s:matchpairs
|
for pair in b:delimitMate_matchpairs
|
||||||
if char == split( pair, ':' )[1]
|
if char == split( pair, ':' )[1]
|
||||||
" Same character on the rigth, jump over it.
|
" Same character on the rigth, jump over it.
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for quote in s:quotes
|
for quote in b:delimitMate_quotes
|
||||||
if char == quote
|
if char == quote
|
||||||
" Same character on the rigth, jump over it.
|
" Same character on the rigth, jump over it.
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return 0
|
return 0
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:JumpIn(char) " {{{
|
function! s:IsBlockVisual() " {{{
|
||||||
let line = getline('.')
|
if visualmode() == "<C-V>"
|
||||||
let col = col('.')-2
|
return 1
|
||||||
if (col) < 0
|
|
||||||
call setline('.',a:char.line)
|
|
||||||
else
|
|
||||||
echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! s:JumpOut(char) "{{{
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if line[col+1] == a:char
|
|
||||||
call setline('.',line[:(col)].line[(col+2):])
|
|
||||||
endif
|
endif
|
||||||
return a:char
|
" Store unnamed register values for later use in s:RestoreRegister().
|
||||||
|
let s:save_reg = getreg('"')
|
||||||
|
let s:save_reg_mode = getregtype('"')
|
||||||
|
|
||||||
|
if len(getline('.')) == 0
|
||||||
|
" This for proper wrap of empty lines.
|
||||||
|
let @" = "\n"
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! s:IsEmptyPair(str) "{{{
|
||||||
|
for pair in b:delimitMate_matchpairs
|
||||||
|
if a:str == join( split( pair, ':' ),'' )
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
for quote in b:delimitMate_quotes
|
||||||
|
if a:str == quote . quote
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return 0
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! DelimitMate_WithinEmptyPair() "{{{
|
||||||
|
let cur = strpart( getline('.'), col('.')-2, 2 )
|
||||||
|
return s:IsEmptyPair( cur )
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:WriteBefore(str) "{{{
|
function! s:WriteBefore(str) "{{{
|
||||||
let len = len(a:str)
|
let len = len(a:str)
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
@@ -238,26 +270,36 @@ function! s:WriteAfter(str) "{{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:IsEmptyPair(str) "{{{1
|
function! s:RestoreRegister() " {{{
|
||||||
for pair in s:matchpairs
|
" Restore unnamed register values store in s:IsBlockVisual().
|
||||||
if a:str == join( split( pair, ':' ),'' )
|
call setreg('"', s:save_reg, s:save_reg_mode)
|
||||||
return 1
|
echo ""
|
||||||
endif
|
endfunction " }}}
|
||||||
endfor
|
" }}}
|
||||||
for quote in s:quotes
|
|
||||||
if a:str == quote . quote
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return 0
|
|
||||||
endfunction "}}}1
|
|
||||||
|
|
||||||
function! DelimitMate_WithinEmptyPair() "{{{1
|
" Doers: {{{
|
||||||
let cur = strpart( getline('.'), col('.')-2, 2 )
|
function! s:JumpIn(char) " {{{
|
||||||
return s:IsEmptyPair( cur )
|
let line = getline('.')
|
||||||
endfunction "}}}1
|
let col = col('.')-2
|
||||||
|
if (col) < 0
|
||||||
|
call setline('.',a:char.line)
|
||||||
|
else
|
||||||
|
echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||||
|
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:SkipDelim(char) "{{{1
|
function! s:JumpOut(char) "{{{
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.')-2
|
||||||
|
if line[col+1] == a:char
|
||||||
|
call setline('.',line[:(col)].line[(col+2):])
|
||||||
|
endif
|
||||||
|
return a:char
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! s:SkipDelim(char) "{{{
|
||||||
let cur = strpart( getline('.'), col('.')-2, 3 )
|
let cur = strpart( getline('.'), col('.')-2, 3 )
|
||||||
if cur[0] == "\\"
|
if cur[0] == "\\"
|
||||||
" Escaped character
|
" Escaped character
|
||||||
@@ -275,9 +317,9 @@ function! s:SkipDelim(char) "{{{1
|
|||||||
" Nothing special here, return the same character.
|
" Nothing special here, return the same character.
|
||||||
return a:char
|
return a:char
|
||||||
endif
|
endif
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:QuoteDelim(char) "{{{1
|
function! s:QuoteDelim(char) "{{{
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') - 2
|
let col = col('.') - 2
|
||||||
if line[col] == "\\"
|
if line[col] == "\\"
|
||||||
@@ -286,54 +328,33 @@ function! s:QuoteDelim(char) "{{{1
|
|||||||
elseif line[col + 1] == a:char
|
elseif line[col + 1] == a:char
|
||||||
" Get out of the string.
|
" Get out of the string.
|
||||||
return s:WriteBefore(a:char)
|
return s:WriteBefore(a:char)
|
||||||
elseif line[col] == a:char && line[col + 1 ] != a:char
|
elseif ((line[col] == a:char && line[col + 1 ] != a:char)
|
||||||
" Seems like we have an unbalanced quote, insert one quotation mark.
|
\ || line[col] =~ '[a-zA-Z0-9]')
|
||||||
|
\ && b:delimitMate_smart_quotes
|
||||||
|
" Seems like we have an unbalanced quote or a closing quote,
|
||||||
|
" insert one quotation mark and jump to tthe middle.
|
||||||
return s:WriteAfter(a:char)
|
return s:WriteAfter(a:char)
|
||||||
elseif line[col] =~ '[a-zA-Z0-9]'
|
elseif line[col] =~ '[a-zA-Z0-9]' && a:char == "'"
|
||||||
" Seems like we closing quotes, insert a single quote.
|
" Seems like an apostrophe, insert a single quote.
|
||||||
return a:char
|
return a:char
|
||||||
else
|
else
|
||||||
" Insert a pair and jump to the middle.
|
" Insert a pair and jump to the middle.
|
||||||
"call setline('.',line[:(col)].a:char.line[(col+3):])
|
|
||||||
call s:WriteAfter(a:char)
|
call s:WriteAfter(a:char)
|
||||||
return a:char
|
return a:char
|
||||||
endif
|
endif
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:ClosePair(char) "{{{1
|
function! s:MapMsg(msg) "{{{
|
||||||
"if getline('.')[col('.') - 1] == a:char
|
|
||||||
"" Same character on the rigth, jump it.
|
|
||||||
""return "\<Right>"
|
|
||||||
"else
|
|
||||||
"" Insert character.
|
|
||||||
"return a:char
|
|
||||||
"endif
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if line[col+1] == a:char
|
|
||||||
call setline('.',line[:(col)].line[(col+2):])
|
|
||||||
endif
|
|
||||||
return a:char
|
|
||||||
endfunction "}}}1
|
|
||||||
|
|
||||||
function! s:ResetMappings() "{{{1
|
|
||||||
for delim in s:right_delims + s:left_delims + s:quotes
|
|
||||||
silent! exec 'iunmap <buffer> ' . delim
|
|
||||||
silent! exec 'vunmap <buffer> ' . s:visual_leader . delim
|
|
||||||
endfor
|
|
||||||
silent! iunmap <buffer> <CR>
|
|
||||||
silent! iunmap <buffer> <Space>
|
|
||||||
endfunction "}}}1
|
|
||||||
|
|
||||||
function! s:MapMsg(msg) "{{{1
|
|
||||||
redraw
|
redraw
|
||||||
echomsg a:msg
|
echomsg a:msg
|
||||||
return ""
|
return ""
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" Mappings: {{{
|
||||||
function! s:NoAutoClose() "{{{
|
function! s:NoAutoClose() "{{{
|
||||||
" inoremap <buffer> ) <C-R>=<SID>SkipDelim('\)')<CR>
|
" inoremap <buffer> ) <C-R>=<SID>SkipDelim('\)')<CR>
|
||||||
for delim in s:right_delims + s:quotes
|
for delim in b:delimitMate_right_delims + b:delimitMate_quotes
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>SkipDelim("' . escape(delim,'"') . '")<CR>'
|
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@@ -341,28 +362,26 @@ endfunction "}}}
|
|||||||
function! s:AutoClose() "{{{
|
function! s:AutoClose() "{{{
|
||||||
" Add matching pair and jump to the midle:
|
" Add matching pair and jump to the midle:
|
||||||
" inoremap <buffer> ( ()<Left>
|
" inoremap <buffer> ( ()<Left>
|
||||||
let s:i = 0
|
let i = 0
|
||||||
while s:i < len(s:matchpairs)
|
while i < len(b:delimitMate_matchpairs)
|
||||||
"exec 'inoremap <buffer> ' . s:left_delims[s:i] . ' ' . s:left_delims[s:i] . s:right_delims[s:i] . '<Left>'
|
exec 'inoremap <buffer> ' . b:delimitMate_left_delims[i] . ' ' . b:delimitMate_left_delims[i] . '<C-R>=<SID>JumpIn("' . b:delimitMate_right_delims[i] . '")<CR>'
|
||||||
exec 'inoremap <buffer> ' . s:left_delims[s:i] . ' ' . s:left_delims[s:i] . '<C-R>=<SID>JumpIn("' . s:right_delims[s:i] . '")<CR>'
|
let i += 1
|
||||||
let s:i += 1
|
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||||
" inoremap <buffer> " <C-R>=<SID>QuoteDelim("\"")<CR>
|
" inoremap <buffer> " <C-R>=<SID>QuoteDelim("\"")<CR>
|
||||||
for delim in s:quotes
|
for delim in b:delimitMate_quotes
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>QuoteDelim("\' . delim . '")<CR>'
|
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>QuoteDelim("\' . delim . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Exit from inside the matching pair:
|
" Exit from inside the matching pair:
|
||||||
" inoremap <buffer> ) <C-R>=<SID>ClosePair(')')<CR>
|
for delim in b:delimitMate_right_delims
|
||||||
for delim in s:right_delims
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>JumpOut("\' . delim . '")<CR>'
|
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>JumpOut("\' . delim . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Try to fix the use of apostrophes (de-activated by default):
|
" Try to fix the use of apostrophes (de-activated by default):
|
||||||
" inoremap <buffer> n't n't
|
" inoremap <buffer> n't n't
|
||||||
for map in s:apostrophes
|
for map in b:delimitMate_apostrophes
|
||||||
exec "inoremap <buffer> " . map . " " . map
|
exec "inoremap <buffer> " . map . " " . map
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
@@ -370,46 +389,25 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:VisualMaps() " {{{
|
function! s:VisualMaps() " {{{
|
||||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
||||||
let s:i = 0
|
let i = 0
|
||||||
while s:i < len(s:matchpairs)
|
while i < len(b:delimitMate_matchpairs)
|
||||||
" Map left delimiter:
|
" Map left delimiter:
|
||||||
" vnoremap <buffer> <expr> \( <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s(\<C-R>\")\<Esc>:call <SID>RestoreRegister()<CR>"
|
" vnoremap <buffer> <expr> \( <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s(\<C-R>\")\<Esc>:call <SID>RestoreRegister()<CR>"
|
||||||
exec 'vnoremap <buffer> <expr> ' . s:visual_leader . s:left_delims[s:i] . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\"' . s:right_delims[s:i] . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
exec 'vnoremap <buffer> <expr> ' . b:delimitMate_visual_leader . b:delimitMate_left_delims[i] . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . b:delimitMate_left_delims[i] . '\<C-R>\"' . b:delimitMate_right_delims[i] . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||||
|
|
||||||
" Map right delimiter:
|
" Map right delimiter:
|
||||||
" vnoremap <buffer> <expr> \) <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s(\<C-R>\")\<Esc>:call <SID>RestoreRegister()<CR>"
|
" vnoremap <buffer> <expr> \) <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s(\<C-R>\")\<Esc>:call <SID>RestoreRegister()<CR>"
|
||||||
exec 'vnoremap <buffer> <expr> ' . s:visual_leader . s:right_delims[s:i] . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\"' . s:right_delims[s:i] . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
exec 'vnoremap <buffer> <expr> ' . b:delimitMate_visual_leader . b:delimitMate_right_delims[i] . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . b:delimitMate_left_delims[i] . '\<C-R>\"' . b:delimitMate_right_delims[i] . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||||
let s:i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Wrap the selection with matching quotes, but do nothing if blockwise visual mode is active:
|
" Wrap the selection with matching quotes, but do nothing if blockwise visual mode is active:
|
||||||
for quote in s:quotes
|
for quote in b:delimitMate_quotes
|
||||||
" vnoremap <buffer> <expr> \' <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s'\<C-R>\"'\<Esc>:call <SID>RestoreRegister()<CR>"
|
" vnoremap <buffer> <expr> \' <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s'\<C-R>\"'\<Esc>:call <SID>RestoreRegister()<CR>"
|
||||||
exec 'vnoremap <buffer> <expr> ' . s:visual_leader . quote . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') .'\<C-R>\"' . escape(quote,'"') . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
exec 'vnoremap <buffer> <expr> ' . b:delimitMate_visual_leader . quote . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') .'\<C-R>\"' . escape(quote,'"') . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:IsBlockVisual() " {{{
|
|
||||||
if visualmode() == "<C-V>"
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in s:RestoreRegister().
|
|
||||||
let s:save_reg = getreg('"')
|
|
||||||
let s:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
return 0
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! s:RestoreRegister() " {{{
|
|
||||||
" Restore unnamed register values store in s:IsBlockVisual().
|
|
||||||
call setreg('"', s:save_reg, s:save_reg_mode)
|
|
||||||
echo ""
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! s:ExpandReturn() "{{{
|
function! s:ExpandReturn() "{{{
|
||||||
if DelimitMate_WithinEmptyPair()
|
if DelimitMate_WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
@@ -428,9 +426,9 @@ function! s:ExpandSpace() "{{{
|
|||||||
" Don't
|
" Don't
|
||||||
return "\<Space>"
|
return "\<Space>"
|
||||||
endif
|
endif
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:ExtraMappings() "{{{1
|
function! s:ExtraMappings() "{{{
|
||||||
" If pair is empty, delete both delimiters:
|
" If pair is empty, delete both delimiters:
|
||||||
inoremap <buffer> <expr> <BS> DelimitMate_WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
|
inoremap <buffer> <expr> <BS> DelimitMate_WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
|
||||||
|
|
||||||
@@ -438,65 +436,69 @@ function! s:ExtraMappings() "{{{1
|
|||||||
inoremap <buffer> <expr> <S-BS> DelimitMate_WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
inoremap <buffer> <expr> <S-BS> DelimitMate_WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
" Expand return if inside an empty pair:
|
||||||
if s:expand_cr != 0
|
if b:delimitMate_expand_cr != 0
|
||||||
inoremap <buffer> <CR> <C-R>=<SID>ExpandReturn()<CR>
|
inoremap <buffer> <CR> <C-R>=<SID>ExpandReturn()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Expand space if inside an empty pair:
|
" Expand space if inside an empty pair:
|
||||||
if s:expand_space != 0
|
if b:delimitMate_expand_space != 0
|
||||||
inoremap <buffer> <Space> <C-R>=<SID>ExpandSpace()<CR>
|
inoremap <buffer> <Space> <C-R>=<SID>ExpandSpace()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Jump out ot any empty pair:
|
" Jump out ot any empty pair:
|
||||||
if s:tab2exit
|
if b:delimitMate_tab2exit
|
||||||
inoremap <buffer> <expr> <S-Tab> DelimitMate_ShouldJump() ? "\<Right>" : "\<S-Tab>"
|
inoremap <buffer> <expr> <S-Tab> DelimitMate_ShouldJump() ? "\<Right>" : "\<S-Tab>"
|
||||||
endif
|
endif
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
"}}}
|
||||||
|
|
||||||
function! s:TestMappings() "{{{1
|
" Tools: {{{
|
||||||
if s:autoclose
|
function! s:TestMappings() "{{{
|
||||||
|
if b:delimitMate_autoclose
|
||||||
exec "normal i* AUTOCLOSE:\<CR>"
|
exec "normal i* AUTOCLOSE:\<CR>"
|
||||||
for i in range(len(s:left_delims))
|
for i in range(len(b:delimitMate_left_delims))
|
||||||
exec "normal GGAOpen & close: " . s:left_delims[i]. "|"
|
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
|
||||||
exec "normal A\<CR>Delete: " . s:left_delims[i] . "\<BS>|"
|
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Exit: " . s:left_delims[i] . s:right_delims[i] . "|"
|
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . s:left_delims[i] . " |"
|
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . s:visual_leader . s:left_delims[i]
|
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . s:visual_leader . s:right_delims[i]
|
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
||||||
exec "normal A\<CR>Car return: " . s:left_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(s:quotes))
|
for i in range(len(b:delimitMate_quotes))
|
||||||
exec "normal GGAOpen & close: " . s:quotes[i] . "|"
|
exec "normal GGAOpen & close: " . b:delimitMate_quotes[i] . "|"
|
||||||
exec "normal A\<CR>Delete: " . s:quotes[i] . "\<BS>|"
|
exec "normal A\<CR>Delete: "
|
||||||
exec "normal A\<CR>Exit: " . s:quotes[i] . s:quotes[i] . "|"
|
exec "normal A". b:delimitMate_quotes[i]
|
||||||
exec "normal A\<CR>Space: " . s:quotes[i] . " |"
|
exec "normal a\<BS>|"
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . s:visual_leader . s:quotes[i]
|
exec "normal A\<CR>Exit: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . "|"
|
||||||
exec "normal A\<CR>Car return: " . s:quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal A\<CR>Space: " . b:delimitMate_quotes[i] . " |"
|
||||||
|
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes[i]
|
||||||
|
exec "normal A\<CR>Car return: " . b:delimitMate_quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
exec "normal i* NO AUTOCLOSE:\<CR>"
|
exec "normal i* NO AUTOCLOSE:\<CR>"
|
||||||
for i in range(len(s:left_delims))
|
for i in range(len(b:delimitMate_left_delims))
|
||||||
exec "normal GGAOpen & close: " . s:left_delims[i] . s:right_delims[i] . "|"
|
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Delete: " . s:left_delims[i] . s:right_delims[i] . "\<BS>|"
|
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Exit: " . s:left_delims[i] . s:right_delims[i] . s:right_delims[i] . "|"
|
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . s:left_delims[i] . s:right_delims[i] . " |"
|
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . s:visual_leader . s:left_delims[i]
|
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . s:visual_leader . s:right_delims[i]
|
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
||||||
exec "normal A\<CR>Car return: " . s:left_delims[i] . s:right_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(s:quotes))
|
for i in range(len(b:delimitMate_quotes))
|
||||||
exec "normal GGAOpen & close: " . s:quotes[i] . s:quotes[i] . "|"
|
exec "normal GGAOpen & close: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . "|"
|
||||||
exec "normal A\<CR>Delete: " . s:quotes[i] . s:quotes[i] . "\<BS>|"
|
exec "normal A\<CR>Delete: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Exit: " . s:quotes[i] . s:quotes[i] . s:quotes[i] . "|"
|
exec "normal A\<CR>Exit: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . s:quotes[i] . s:quotes[i] . " |"
|
exec "normal A\<CR>Space: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . " |"
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . s:visual_leader . s:quotes[i]
|
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes[i]
|
||||||
exec "normal A\<CR>Car return: " . s:quotes[i] . s:quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal A\<CR>Car return: " . b:delimitMate_quotes[i] . b:delimitMate_quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
exec "normal \<Esc>i"
|
exec "normal \<Esc>i"
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:SwitchAutoclose() "{{{1
|
function! s:SwitchAutoclose() "{{{
|
||||||
if !exists("g:delimitMate_autoclose")
|
if !exists("g:delimitMate_autoclose")
|
||||||
let g:delimitMate_autoclose = 1
|
let g:delimitMate_autoclose = 1
|
||||||
elseif g:delimitMate_autoclose == 1
|
elseif g:delimitMate_autoclose == 1
|
||||||
@@ -505,69 +507,78 @@ function! s:SwitchAutoclose() "{{{1
|
|||||||
let g:delimitMate_autoclose = 1
|
let g:delimitMate_autoclose = 1
|
||||||
endif
|
endif
|
||||||
DelimitMateReload
|
DelimitMateReload
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:UnMap() " {{{
|
function! s:UnMap() " {{{
|
||||||
" No Autoclose Mappings:
|
" No Autoclose Mappings:
|
||||||
for char in s:right_delims + s:quotes
|
for char in b:delimitMate_right_delims + b:delimitMate_quotes
|
||||||
if maparg('<buffer> '.char,"i") =~? 'SkipDelim'
|
if maparg(char,"i") =~? 'SkipDelim'
|
||||||
exec 'iunmap <buffer> ' . char
|
exec 'silent! iunmap <buffer> ' . char
|
||||||
"echomsg 'iunmap <buffer> ' . char
|
"echomsg 'iunmap <buffer> ' . char
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Autoclose Mappings:
|
" Autoclose Mappings:
|
||||||
let s:i = 0
|
let i = 0
|
||||||
while s:i < len(s:matchpairs)
|
let l = len(b:delimitMate_matchpairs)
|
||||||
if maparg('<buffer> '.s:left_delims[s:i],"i") =~? s:left_delims[s:i] . s:right_delims[s:i] . '<Left>'
|
while i < l
|
||||||
exec 'iunmap <buffer> ' . s:left_delims[s:i]
|
if maparg(b:delimitMate_left_delims[i],"i") =~? 'JumpIn'
|
||||||
"echomsg 'iunmap <buffer> ' . s:left_delims[s:i]
|
exec 'silent! iunmap <buffer> ' . b:delimitMate_left_delims[i]
|
||||||
|
"echomsg 'iunmap <buffer> ' . b:delimitMate_left_delims[i]
|
||||||
endif
|
endif
|
||||||
let s:i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
for char in s:quotes
|
for char in b:delimitMate_quotes
|
||||||
if maparg(char, "i") =~? 'QuoteDelim'
|
if maparg(char, "i") =~? 'QuoteDelim'
|
||||||
exec 'iunmap <buffer> ' . char
|
exec 'silent! iunmap <buffer> ' . char
|
||||||
"echomsg 'iunmap <buffer> ' . char
|
"echomsg 'iunmap <buffer> ' . char
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for char in s:right_delims
|
for char in b:delimitMate_right_delims
|
||||||
if maparg(char, "i") =~? 'ClosePair'
|
if maparg(char, "i") =~? 'JumpOut'
|
||||||
exec 'iunmap <buffer> ' . char
|
exec 'silent! iunmap <buffer> ' . char
|
||||||
"echomsg 'iunmap <buffer> ' . char
|
"echomsg 'iunmap <buffer> ' . char
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for map in s:apostrophes
|
for map in b:delimitMate_apostrophes
|
||||||
exec "silent! iunmap <buffer> " . map
|
exec "silent! iunmap <buffer> " . map
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Visual Mappings:
|
" Visual Mappings:
|
||||||
for char in s:right_delims + s:left_delims + s:quotes
|
for char in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes
|
||||||
if maparg(s:visual_leader . char,"v") =~? 'IsBlock'
|
if maparg(b:delimitMate_visual_leader . char,"v") =~? 'IsBlock'
|
||||||
exec 'vunmap <buffer> ' . s:visual_leader . char
|
exec 'silent! vunmap <buffer> ' . b:delimitMate_visual_leader . char
|
||||||
"echomsg 'vunmap <buffer> ' . s:visual_leader . char
|
"echomsg 'vunmap <buffer> ' . b:delimitMate_visual_leader . char
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Expansion Mappings:
|
" Expansion Mappings:
|
||||||
if maparg('<BS>', "i") =~? 'WithinEmptyPair'
|
if maparg('<BS>', "i") =~? 'WithinEmptyPair'
|
||||||
iunmap <buffer> <BS>
|
silent! iunmap <buffer> <BS>
|
||||||
"echomsg "iunmap <buffer> <BS>"
|
"echomsg "silent! iunmap <buffer> <BS>"
|
||||||
|
endif
|
||||||
|
if maparg('<S-BS>', "i") =~? 'WithinEmptyPair'
|
||||||
|
silent! iunmap <buffer> <BS>
|
||||||
|
"echomsg "silent! iunmap <buffer> <BS>"
|
||||||
endif
|
endif
|
||||||
if maparg('<CR>',"i") =~? 'ExpandReturn'
|
if maparg('<CR>',"i") =~? 'ExpandReturn'
|
||||||
iunmap <buffer> <CR>
|
silent! iunmap <buffer> <CR>
|
||||||
"echomsg "iunmap <buffer> <CR>"
|
"echomsg "silent! iunmap <buffer> <CR>"
|
||||||
endif
|
endif
|
||||||
if maparg('<Space>',"i") =~? 'ExpandSpace'
|
if maparg('<Space>',"i") =~? 'ExpandSpace'
|
||||||
iunmap <buffer> <Space>
|
silent! iunmap <buffer> <Space>
|
||||||
"echomsg "iunmap <buffer> <Space>"
|
"echomsg "silent! iunmap <buffer> <Space>"
|
||||||
endif
|
endif
|
||||||
|
if maparg('<S-Tab>', "i") =~? 'ShouldJump'
|
||||||
|
silent! iunmap <buffer> <S-Tab>
|
||||||
|
"echomsg "silent! iunmap <buffer> <S-Tab>"
|
||||||
|
endif
|
||||||
|
endfunction " }}} s:ExtraMappings()
|
||||||
|
|
||||||
endfunction " }}}
|
function! s:TestMappingsDo() "{{{
|
||||||
|
"DelimitMateReload
|
||||||
function! s:TestMappingsDo() "{{{1
|
|
||||||
if !exists("g:delimitMate_testing")
|
if !exists("g:delimitMate_testing")
|
||||||
call s:DelimitMateDo()
|
"call s:DelimitMateDo()
|
||||||
call s:TestMappings()
|
call s:TestMappings()
|
||||||
else
|
else
|
||||||
call s:SwitchAutoclose()
|
call s:SwitchAutoclose()
|
||||||
@@ -576,18 +587,18 @@ function! s:TestMappingsDo() "{{{1
|
|||||||
call s:SwitchAutoclose()
|
call s:SwitchAutoclose()
|
||||||
call s:TestMappings()
|
call s:TestMappings()
|
||||||
endif
|
endif
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo() "{{{1
|
function! s:DelimitMateDo() "{{{
|
||||||
if exists("g:delimitMate_excluded_ft")
|
if exists("g:delimitMate_excluded_ft")
|
||||||
" Check if this file type is excluded:
|
" Check if this file type is excluded:
|
||||||
for ft in split(g:delimitMate_excluded_ft,',')
|
for ft in split(g:delimitMate_excluded_ft,',')
|
||||||
if ft ==? &filetype
|
if ft ==? &filetype
|
||||||
if !exists("s:quotes")
|
if !exists("b:delimitMate_quotes")
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
"echomsg "excluded"
|
"echomsg "excluded"
|
||||||
"call s:UnMap()
|
call s:UnMap()
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -600,9 +611,10 @@ function! s:DelimitMateDo() "{{{1
|
|||||||
finally
|
finally
|
||||||
let &cpo = save_cpo
|
let &cpo = save_cpo
|
||||||
endtry
|
endtry
|
||||||
endfunction "}}}1
|
endfunction "}}}
|
||||||
|
"}}}
|
||||||
|
|
||||||
" Set some commands: {{{1
|
" Commands: {{{
|
||||||
call s:DelimitMateDo()
|
call s:DelimitMateDo()
|
||||||
|
|
||||||
" Let me refresh without re-loading the buffer:
|
" Let me refresh without re-loading the buffer:
|
||||||
@@ -619,6 +631,7 @@ autocmd FileType * call <SID>DelimitMateDo()
|
|||||||
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
|
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
|
||||||
|
|
||||||
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
|
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
|
||||||
|
"}}}
|
||||||
|
|
||||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
||||||
" vim:foldmethod=marker:foldcolumn=2
|
" vim:foldmethod=marker:foldcolumn=4
|
||||||
|
|||||||
Reference in New Issue
Block a user