Small fixes and documentation updates.

This commit is contained in:
Israel Chauca Fuentes
2010-05-09 15:23:30 -05:00
parent e748b461b6
commit 2c8b586679
5 changed files with 56 additions and 46 deletions

View File

@@ -16,6 +16,7 @@ doc_update: install
zip: zip:
zip -r ${PLUGIN}.zip doc plugin autoload zip -r ${PLUGIN}.zip doc plugin autoload
zip ${PLUGIN}.zip -d \*.sw\? zip ${PLUGIN}.zip -d \*.sw\?
zip ${PLUGIN}.zip -d autoload/${PLUGIN}Tests.vim
vimball: install vimball: install
echo doc/${PLUGIN}.txt > vimball.txt echo doc/${PLUGIN}.txt > vimball.txt

View File

@@ -115,7 +115,7 @@ endfunction "}}}
function! delimitMate#IsCRExpansion() " {{{ function! delimitMate#IsCRExpansion() " {{{
let nchar = getline(line('.')-1)[-1:] let nchar = getline(line('.')-1)[-1:]
let schar = getline(line('.')+1)[-1:] let schar = getline(line('.')+1)[:0]
let isEmpty = getline('.') == "" let isEmpty = getline('.') == ""
if index(b:delimitMate_left_delims, nchar) > -1 && if index(b:delimitMate_left_delims, nchar) > -1 &&
\ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) && \ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) &&
@@ -375,7 +375,7 @@ function! delimitMate#Finish() " {{{
let buffer = join(b:delimitMate_buffer, '') let buffer = join(b:delimitMate_buffer, '')
let line = getline('.') let line = getline('.')
let col = col('.') -2 let col = col('.') -2
echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer "echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
call setline('.', line[:col] . line[col+len+1:]) call setline('.', line[:col] . line[col+len+1:])
let i = 1 let i = 1
let lefts = '' let lefts = ''
@@ -469,14 +469,14 @@ function! delimitMate#ExtraMappings() "{{{
inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc> inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
" Flush the char buffer on mouse click: " Flush the char buffer on mouse click:
inoremap <buffer> <LeftMouse> <C-R>=delimitMate#FlushBuffer()<CR><LeftMouse> inoremap <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
inoremap <buffer> <RightMouse> <C-R>=delimitMate#FlushBuffer()<CR><RightMouse> inoremap <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
" Flush the char buffer on key movements: " Flush the char buffer on key movements:
inoremap <buffer> <Left> <C-R>=delimitMate#FlushBuffer()<CR><Left> inoremap <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
inoremap <buffer> <Right> <C-R>=delimitMate#FlushBuffer()<CR><Right> inoremap <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
inoremap <buffer> <Up> <C-R>=delimitMate#FlushBuffer()<CR><Up> inoremap <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
inoremap <buffer> <Down> <C-R>=delimitMate#FlushBuffer()<CR><Down> inoremap <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR> inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>

View File

@@ -1,6 +1,6 @@
function! delimitMateTests#Main() " {{{ function! delimitMateTests#Main() " {{{
if !exists("g:delimitMate_testing") if !exists("g:delimitMate_testing")
echoerr "delimitMateTests#Main(): You shouldn't use this function!" echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
return return
endif endif
nmap <F1> :qall!<CR> nmap <F1> :qall!<CR>
@@ -10,7 +10,7 @@ function! delimitMateTests#Main() " {{{
let b:delimitMate_autoclose = 1 let b:delimitMate_autoclose = 1
let b:delimitMate_matchpairs = &matchpairs let b:delimitMate_matchpairs = &matchpairs
let b:delimitMate_quotes = "\" ' `" let b:delimitMate_quotes = "\" ' `"
let b:delimitMate_excluded_regions = ["Comment"] let b:delimitMate_excluded_regions = "Comment"
silent! unlet b:delimitMate_visual_leader silent! unlet b:delimitMate_visual_leader
let b:delimitMate_expand_space = 0 let b:delimitMate_expand_space = 0
let b:delimitMate_expand_cr = 0 let b:delimitMate_expand_cr = 0
@@ -45,7 +45,6 @@ function! delimitMateTests#Main() " {{{
let text = text . "<cr>" . getline(i) let text = text . "<cr>" . getline(i)
let i += 1 let i += 1
endwhile endwhile
echom "text: " . text
if result == 0 if result == 0
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "'] = 'Passed: ' . text . ' == ' . join(a:output, '<cr>')" exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "'] = 'Passed: ' . text . ' == ' . join(a:output, '<cr>')"
else else
@@ -58,7 +57,6 @@ function! delimitMateTests#Main() " {{{
call setpos('.', [0, 1, 1, 0]) call setpos('.', [0, 1, 1, 0])
let result = len(a:output) != line('$') let result = len(a:output) != line('$')
for line in a:output for line in a:output
echom line . " vs " . getline('.')
if getline('.') != line || result == 1 if getline('.') != line || result == 1
let result = 1 let result = 1
break break
@@ -129,13 +127,21 @@ function! delimitMateTests#Main() " {{{
call RepeatLast("S Tab", ["()|()|"]) call RepeatLast("S Tab", ["()|()|"])
" Space expansion " Space expansion
call Type("Space expansion", "(\<Space>", ['( | )'], ['expand_space:1']) call Type("Space expansion", "(\<Space>\<BS>", ['(|)'], ['expand_space:1'])
call RepeatLast("BS with space expansion", ['(|)(|)'])
" BS with space expansion
call Type("BS with space expansion", "(\<Space>", ['( | )'], ['expand_space:1'])
call RepeatLast("Space expansion", ['( | )( | )']) call RepeatLast("Space expansion", ['( | )( | )'])
" Car return expansion " Car return expansion
call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1']) call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1'])
call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')']) call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'])
" BS with car return expansion
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
call RepeatLast("BS with CR expansion", ['(|)(|)'])
" Visual wrapping " Visual wrapping
call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","']) call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","'])
cal RepeatLast("Visual wrapping left paren", ['(1)23(4)']) cal RepeatLast("Visual wrapping left paren", ['(1)23(4)'])
@@ -216,8 +222,4 @@ function! delimitMateTests#Main() " {{{
hi def link resultInequal Error hi def link resultInequal Error
" }}} " }}}
endfunction " }}} endfunction " }}}
function! delimitMateTests#Go()
call system("gvim -c 'call delimitMateTests\#Main()'")
endfunction
" vim:foldmethod=marker:foldcolumn=4 " vim:foldmethod=marker:foldcolumn=4

View File

@@ -1,4 +1,4 @@
*delimitMate* Trying to keep those beasts at bay! v.2.0 *delimitMate.txt* *delimitMate* Trying to keep those beasts at bay! v.2.1 *delimitMate.txt*
========================================================================= ~ ========================================================================= ~
==== ========= ========================== ===== ===================== ~ ==== ========= ========================== ===== ===================== ~
@@ -37,23 +37,13 @@
============================================================================== ==============================================================================
1.- INTRODUCTION *delimitMateIntro* 1.- INTRODUCTION *delimitMateIntro*
The delimitMate plugin tries to provide some not so dumb help in the work with This plug-in provides automatic closing of quotes, parenthesis, brackets,
delimiters (brackets, quotes, etc.), with some optional auto-completions and etc., besides some other related features that should make your time in insert
expansions. mode a little bit easier.
When automatic closing is enabled, if an opening delimiter is inserted Most of the features can be modified or disabled permanently, using global
delimitMate inserts the closing pair and places the cursor between them. When variables, or on a FileType basis, using autocommands. With a couple of
automatic closing is disabled, no closing delimiters is inserted by exceptions and limitations, this features don't brake undo, redo or history.
delimitMate, but if a pair of delimiters is typed, the cursor is placed in the
middle. Also, to get out of a pair of delimiters just type shift+tab or the
right delimiter and the cursor will jump to the right.
If the cursor is inside an empty pair of delimiters, typing <Space> will
insert two spaces and the cursor will be placed in the middle; typing <CR>
will insert to car retunrs and place the cursor in the middle line, between
the delimiters.
All of the operations are undo/redo-wise safe.
============================================================================== ==============================================================================
2. FUNCTIONALITY *delimitMateFunctionality* 2. FUNCTIONALITY *delimitMateFunctionality*
@@ -118,6 +108,8 @@ Expand <CR> to: >
| ) | )
< <
NOTE that the expansion of <CR> will brake the redo command.
Since <Space> and <CR> are used everywhere, I have made the functions involved Since <Space> and <CR> are used everywhere, I have made the functions involved
in expansions global, so they can be used to make custom mappings. Read in expansions global, so they can be used to make custom mappings. Read
|delimitMateFunctions| for more details. |delimitMateFunctions| for more details.
@@ -125,8 +117,11 @@ in expansions global, so they can be used to make custom mappings. Read
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
2.3 BACKSPACE *delimitMateBackspace* 2.3 BACKSPACE *delimitMateBackspace*
If you press backspace inside an empty pair, both delimiters are deleted. If If you press backspace inside an empty pair, both delimiters are deleted. When
you type shift + backspace instead, only the closing delimiter will be expansions are enabled, <BS> will also delete the expansions. NOTE that
deleting <CR> expansions will brake the redo command.
If you type shift + backspace instead, only the closing delimiter will be
deleted. deleted.
e.g. typing at the "|": > e.g. typing at the "|": >
@@ -134,7 +129,13 @@ e.g. typing at the "|": >
What | Before | After What | Before | After
============================================== ==============================================
<BS> | call expand(|) | call expand| <BS> | call expand(|) | call expand|
---------|------------------|----------------- ---------|-------------------|-----------------
<BS> | call expand( | ) | call expand(|)
---------|-------------------|-----------------
<BS> | call expand( | call expand(|)
| | |
| ) |
---------|-------------------|-----------------
<S-BS> | call expand(|) | call expand(| <S-BS> | call expand(|) | call expand(|
< <
@@ -144,8 +145,8 @@ e.g. typing at the "|": >
When visual mode is active this script allows for the selection to be enclosed 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 with delimiters. But, since brackets have special meaning in visual mode, a
leader (the value of 'mapleader' by default) should precede the delimiter. leader (the value of 'mapleader' by default) should precede the delimiter.
This feature doesn't currently work on blockwise visual mode, any suggestions NOTE that this feature brakes the redo command and doesn't currently work on
will be welcome. blockwise visual mode, any suggestions will be welcome.
e.g. (selection represented between square brackets): > e.g. (selection represented between square brackets): >
@@ -487,7 +488,12 @@ This script was inspired by the auto-completion of delimiters of TextMate.
Version Date Release notes ~ Version Date Release notes ~
|---------|------------|-----------------------------------------------------| |---------|------------|-----------------------------------------------------|
2.0 2010-04-01 * New features: 2.1 2010-05-10 - Most of the functions have been moved to an
autoload script to avoid loading unnecessary ones.
- Fixed a problem with the redo command.
- Many small fixes.
|---------|------------|-----------------------------------------------------|
2.0 2010-04-01 New features:
- All features are redo/undo-wise safe. - All features are redo/undo-wise safe.
- A single quote typed after an alphanumeric - A single quote typed after an alphanumeric
character is considered an apostrophe and one character is considered an apostrophe and one

View File

@@ -25,7 +25,7 @@ if v:version < 700
endif endif
let s:loaded_delimitMate = 1 " }}} let s:loaded_delimitMate = 1 " }}}
let delimitMate_version = '2.1_DEV' let delimitMate_version = '2.1'
"}}} "}}}
@@ -70,8 +70,8 @@ function! s:Init() "{{{
else else
let s:excluded_regions = "Comment" let s:excluded_regions = "Comment"
endif endif
let b:delimitMate_excluded_regions_list = split(s:excluded_regions) " }}} let b:delimitMate_excluded_regions_list = split(s:excluded_regions, ',\s*')
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) " }}}
" delimitMate_visual_leader {{{ " delimitMate_visual_leader {{{
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader") if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
@@ -207,6 +207,7 @@ command! DelimitMateReload call s:DelimitMateDo()
" Quick test: " Quick test:
command! DelimitMateTest call s:TestMappingsDo() command! DelimitMateTest call s:TestMappingsDo()
"command! DelimitMateRegions echo s:excluded_regions
" Turn " Turn
" Run on file type events. " Run on file type events.