mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Remove Visual Wrapping. Closes #38.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
" ============================================================================
|
||||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.5
|
||||
" Modified: 2010-09-22
|
||||
" Version: 2.5.1
|
||||
" Modified: 2010-09-27
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
@@ -46,47 +46,6 @@ function! delimitMate#ShouldJump() "{{{
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#Visual(del) " {{{
|
||||
if len(getline('.')) == 0
|
||||
" This for proper wrap of empty lines.
|
||||
let @" = "\n"
|
||||
endif
|
||||
|
||||
" Let's find which kind of delimiter we got:
|
||||
let index = index(b:_l_delimitMate_left_delims, a:del)
|
||||
if index >= 0
|
||||
let ld = a:del
|
||||
let rd = b:_l_delimitMate_right_delims[index]
|
||||
endif
|
||||
|
||||
let index = index(b:_l_delimitMate_right_delims, a:del)
|
||||
if index >= 0
|
||||
let ld = b:_l_delimitMate_left_delims[index]
|
||||
let rd = a:del
|
||||
endif
|
||||
|
||||
if index(b:_l_delimitMate_quotes_list, a:del) >= 0
|
||||
let ld = a:del
|
||||
let rd = ld
|
||||
endif
|
||||
|
||||
let mode = mode()
|
||||
if mode == "\<C-V>"
|
||||
" Block-wise visual
|
||||
return "I" . ld . "\<Esc>gv\<Right>A" . rd . "\<Esc>"
|
||||
elseif mode ==# "V"
|
||||
let dchar = "\<BS>"
|
||||
else
|
||||
let dchar = ""
|
||||
endif
|
||||
|
||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
||||
let b:save_reg = getreg('"')
|
||||
let b:save_reg_mode = getregtype('"')
|
||||
|
||||
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#IsEmptyPair(str) "{{{
|
||||
for pair in b:_l_delimitMate_matchpairs_list
|
||||
if a:str == join( split( pair, ':' ),'' )
|
||||
@@ -168,12 +127,6 @@ function! delimitMate#WriteAfter(str) "{{{
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#RestoreRegister() " {{{
|
||||
" Restore unnamed register values stored in delimitMate#Visual().
|
||||
call setreg('"', b:save_reg, b:save_reg_mode)
|
||||
echo ""
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#GetSyntaxRegion(line, col) "{{{
|
||||
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
|
||||
endfunction " }}}
|
||||
@@ -499,8 +452,6 @@ function! delimitMate#TestMappings() "{{{
|
||||
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
|
||||
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
|
||||
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
|
||||
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
@@ -510,7 +461,6 @@ function! delimitMate#TestMappings() "{{{
|
||||
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
|
||||
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
@@ -523,8 +473,6 @@ function! delimitMate#TestMappings() "{{{
|
||||
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
|
||||
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
|
||||
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
|
||||
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
@@ -534,7 +482,6 @@ function! delimitMate#TestMappings() "{{{
|
||||
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
|
||||
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
|
||||
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
@@ -570,36 +517,18 @@ function! delimitMate#TestMappings() "{{{
|
||||
endfor
|
||||
let ibroken = len(ibroken) > 0 ? ['IMAP'] + ibroken : []
|
||||
|
||||
let vbroken = []
|
||||
if !exists("b:_l_delimitMate_visual_leader")
|
||||
let vleader = ""
|
||||
else
|
||||
let vleader = b:_l_delimitMate_visual_leader
|
||||
endif
|
||||
for map in vmaps
|
||||
if maparg(vleader . map, "v") !~? "delimitMate"
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
let vbroken = vbroken + [vleader.map.": is not set:"] + split(output,'\n')
|
||||
endif
|
||||
endfor
|
||||
let vbroken = len(vbroken) > 0 ? ['VMAP'] + vbroken : []
|
||||
|
||||
unlet! output
|
||||
if ibroken == [] && vbroken == []
|
||||
if ibroken == []
|
||||
let output = ['Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
|
||||
else
|
||||
let output = ['Mappings:', ''] + ibroken + vbroken + ['--------------------', '', '']
|
||||
let output = ['Mappings:', ''] + ibroken + ['--------------------', '', '']
|
||||
endif
|
||||
call append('$', output)
|
||||
" }}}
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#OptionsList() "{{{
|
||||
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'visual_leader' : ( exists('mapleader') ? mapleader : exists('b:maplocalleader') ? b:maplocalleader : '\' ), 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||
endfunction " delimitMate#OptionsList }}}
|
||||
"}}}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ function! delimitMateTests#Main()
|
||||
let b:delimitMate_matchpairs = &matchpairs
|
||||
let b:delimitMate_quotes = "\" ' `"
|
||||
let b:delimitMate_excluded_regions = "Comment"
|
||||
silent! unlet b:delimitMate_visual_leader
|
||||
let b:delimitMate_expand_space = 0
|
||||
let b:delimitMate_expand_cr = 0
|
||||
let b:delimitMate_smart_quotes = 1
|
||||
@@ -164,36 +163,6 @@ function! delimitMateTests#Main()
|
||||
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
||||
call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
|
||||
|
||||
" Visual wrapping
|
||||
call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual wrapping left paren", ['(1)23(4)'], 1)
|
||||
|
||||
" Visual line wrapping
|
||||
call Type("Visual line wrapping left paren", "1234\<Esc>V,(", ['(1234)'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual line wrapping left paren", ['((1234))'], 1)
|
||||
|
||||
" Visual wrapping
|
||||
call Type("Visual wrapping right paren", "1234\<Esc>v,)", ['123(4)'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual wrapping right paren", ['(1)23(4)'], 1)
|
||||
|
||||
" Visual line wrapping
|
||||
call Type("Visual line wrapping right paren", "1234\<Esc>V,)", ['(1234)'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual line wrapping right paren", ['((1234))'], 1)
|
||||
|
||||
" Visual wrapping
|
||||
call Type("Visual wrapping quote", "1234\<Esc>v,\"", ['123"4"'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual wrapping quote", ['"1"23"4"'], 1)
|
||||
|
||||
" Visual line wrapping
|
||||
call Type("Visual line wrapping quote", "1234\<Esc>V,\"", ['"1234"'], ['visual_leader:","'])
|
||||
cal RepeatLast("Visual line wrapping quote", ['""1234""'], 1)
|
||||
|
||||
" Visual line wrapping empty line
|
||||
call Type("Visual line wrapping paren empty line", "\<Esc>V,(", ['()'], ['visual_leader:","'])
|
||||
|
||||
" Visual line wrapping empty line
|
||||
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
|
||||
|
||||
" Smart quotes
|
||||
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
|
||||
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5 *delimitMate*
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5.1 *delimitMate*
|
||||
|
||||
|
||||
|
||||
@@ -27,11 +27,10 @@
|
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||
3.3 Backspace__________________________|delimitMateBackspace|
|
||||
3.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
||||
3.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.6 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.7 FileType based configuration_______|delimitMateFileType|
|
||||
3.8 Syntax awareness___________________|delimitMateSyntax|
|
||||
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.6 FileType based configuration_______|delimitMateFileType|
|
||||
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||
4. Commands________________________________|delimitMateCommands|
|
||||
5. Mappings________________________________|delimitMateMappings|
|
||||
6. Functions_______________________________|delimitMateFunctions|
|
||||
@@ -88,8 +87,6 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||
allowed to be nested.
|
||||
|
||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||
@@ -178,18 +175,6 @@ e.g.: >
|
||||
let delimitMate_nesting_quotes = ['"','`']
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_visual_leader'*
|
||||
*'b:delimitMate_visual_leader'*
|
||||
Values: Any character. ~
|
||||
Default: q ~
|
||||
|
||||
The value of this option will be used to wrap the selection in visual mode
|
||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
||||
e.g: >
|
||||
let delimitMate_visual_leader = "f"
|
||||
au FileType html let b:delimitMate_visual_leader = "f"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_cr'*
|
||||
*'b:delimitMate_expand_cr'*
|
||||
@@ -373,24 +358,7 @@ e.g. typing at the "|": >
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
||||
|
||||
When visual mode is active this script allows for the selection to be enclosed
|
||||
with delimiters. But, since brackets have special meaning in visual mode, a
|
||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
||||
NOTE that this feature brakes the repeat command and doesn't currently work
|
||||
well on blockwise visual mode when the selection has lines one character
|
||||
smaller than the rest, any suggestions to fix this will be very welcome.
|
||||
|
||||
e.g. (selection represented between square brackets): >
|
||||
|
||||
Selected text | After \"
|
||||
=============================================
|
||||
An [absurd] example! | An "absurd" example!
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.5 SMART QUOTES *delimitMateSmartQuotes*
|
||||
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
||||
|
||||
Only one quote will be inserted following a quote, a "\" or, following or
|
||||
preceding an alphanumeric character. This should cover closing quotes after a
|
||||
@@ -408,7 +376,7 @@ e.g. typing at the "|": >
|
||||
'm | I| | I'm|
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.6 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||
enabled, delimitMate will try to balance the closing pairs in the current
|
||||
@@ -423,7 +391,7 @@ e.g. typing at the "|": >
|
||||
( | (|) | ((|))
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.7 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
|
||||
delimitMate options can be set globally for all buffers using global
|
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||
@@ -443,7 +411,7 @@ NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.8 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
3.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings
|
||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||
@@ -668,8 +636,11 @@ This script was inspired by the auto-completion of delimiters on TextMate.
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5 2010-09-22 * Current release:
|
||||
- Better handling of mappings.
|
||||
2.5.1 2010-09-27 * Current release:
|
||||
- Remove visual wrapping. Surround.vim offers a much
|
||||
better implementation.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.5 2010-09-22 * - Better handling of mappings.
|
||||
- Add report for mappings in |:DelimitMateTest|.
|
||||
- Allow the use of "|" and multi-byte characters in
|
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
" ============================================================================
|
||||
" File: plugin/delimitMate.vim
|
||||
" Version: 2.5
|
||||
" Modified: 2010-09-22
|
||||
" Version: 2.5.1
|
||||
" Modified: 2010-09-27
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
@@ -27,7 +27,7 @@ if v:version < 700
|
||||
endif
|
||||
|
||||
let s:loaded_delimitMate = 1
|
||||
let delimitMate_version = "2.5"
|
||||
let delimitMate_version = "2.5.1"
|
||||
|
||||
function! s:option_init(name, default) "{{{
|
||||
let b = exists("b:delimitMate_" . a:name)
|
||||
@@ -76,11 +76,6 @@ function! s:init() "{{{
|
||||
" excluded filetypes
|
||||
call s:option_init("excluded_ft", "")
|
||||
|
||||
" visual_leader
|
||||
let leader = exists('b:maplocalleader') ? b:maplocalleader :
|
||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
||||
call s:option_init("visual_leader", leader)
|
||||
|
||||
" expand_space
|
||||
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||
@@ -154,7 +149,6 @@ function! s:Map() "{{{
|
||||
else
|
||||
call s:NoAutoClose()
|
||||
endif
|
||||
call s:VisualMaps()
|
||||
call s:ExtraMappings()
|
||||
finally
|
||||
let &cpo = save_cpo
|
||||
@@ -177,11 +171,6 @@ function! s:Unmap() " {{{
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>']
|
||||
|
||||
let vmaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list
|
||||
|
||||
for map in imaps
|
||||
if maparg(map, "i") =~? 'delimitMate'
|
||||
if map == '|'
|
||||
@@ -191,20 +180,6 @@ function! s:Unmap() " {{{
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !exists("b:_l_delimitMate_visual_leader")
|
||||
let vleader = ""
|
||||
else
|
||||
let vleader = b:_l_delimitMate_visual_leader
|
||||
endif
|
||||
for map in vmaps
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
if maparg(vleader . map, "v") =~? "delimitMate"
|
||||
exec 'silent! vunmap <buffer> ' . vleader . map
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !has('gui_running')
|
||||
silent! iunmap <C-[>OC
|
||||
endif
|
||||
@@ -342,16 +317,6 @@ function! s:AutoClose() "{{{
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:VisualMaps() " {{{
|
||||
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
||||
let vleader = b:_l_delimitMate_visual_leader
|
||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
||||
for del in b:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
|
||||
exec "vnoremap <silent> <expr> <Plug>delimitMateVisual" . del . ' delimitMate#Visual("' . escape(del, '")|') . '")'
|
||||
exec 'silent! vmap <unique> <buffer> ' . vleader . del . ' <Plug>delimitMateVisual' . del
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:ExtraMappings() "{{{
|
||||
" If pair is empty, delete both delimiters:
|
||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||
|
||||
Reference in New Issue
Block a user