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 -r ${PLUGIN}.zip doc plugin autoload
zip ${PLUGIN}.zip -d \*.sw\?
zip ${PLUGIN}.zip -d autoload/${PLUGIN}Tests.vim
vimball: install
echo doc/${PLUGIN}.txt > vimball.txt

View File

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

View File

@@ -1,6 +1,6 @@
function! delimitMateTests#Main() " {{{
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
endif
nmap <F1> :qall!<CR>
@@ -10,7 +10,7 @@ function! delimitMateTests#Main() " {{{
let b:delimitMate_autoclose = 1
let b:delimitMate_matchpairs = &matchpairs
let b:delimitMate_quotes = "\" ' `"
let b:delimitMate_excluded_regions = ["Comment"]
let b:delimitMate_excluded_regions = "Comment"
silent! unlet b:delimitMate_visual_leader
let b:delimitMate_expand_space = 0
let b:delimitMate_expand_cr = 0
@@ -45,7 +45,6 @@ function! delimitMateTests#Main() " {{{
let text = text . "<cr>" . getline(i)
let i += 1
endwhile
echom "text: " . text
if result == 0
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "'] = 'Passed: ' . text . ' == ' . join(a:output, '<cr>')"
else
@@ -58,7 +57,6 @@ function! delimitMateTests#Main() " {{{
call setpos('.', [0, 1, 1, 0])
let result = len(a:output) != line('$')
for line in a:output
echom line . " vs " . getline('.')
if getline('.') != line || result == 1
let result = 1
break
@@ -129,13 +127,21 @@ function! delimitMateTests#Main() " {{{
call RepeatLast("S Tab", ["()|()|"])
" 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", ['( | )( | )'])
" Car return expansion
call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1'])
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
call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","'])
cal RepeatLast("Visual wrapping left paren", ['(1)23(4)'])
@@ -216,8 +222,4 @@ function! delimitMateTests#Main() " {{{
hi def link resultInequal Error
" }}}
endfunction " }}}
function! delimitMateTests#Go()
call system("gvim -c 'call delimitMateTests\#Main()'")
endfunction
" 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*
The delimitMate plugin tries to provide some not so dumb help in the work with
delimiters (brackets, quotes, etc.), with some optional auto-completions and
expansions.
This plug-in provides automatic closing of quotes, parenthesis, brackets,
etc., besides some other related features that should make your time in insert
mode a little bit easier.
When automatic closing is enabled, if an opening delimiter is inserted
delimitMate inserts the closing pair and places the cursor between them. When
automatic closing is disabled, no closing delimiters is inserted by
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.
Most of the features can be modified or disabled permanently, using global
variables, or on a FileType basis, using autocommands. With a couple of
exceptions and limitations, this features don't brake undo, redo or history.
==============================================================================
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
in expansions global, so they can be used to make custom mappings. Read
|delimitMateFunctions| for more details.
@@ -125,17 +117,26 @@ in expansions global, so they can be used to make custom mappings. Read
------------------------------------------------------------------------------
2.3 BACKSPACE *delimitMateBackspace*
If you press backspace inside an empty pair, both delimiters are deleted. If
you type shift + backspace instead, only the closing delimiter will be
If you press backspace inside an empty pair, both delimiters are deleted. When
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.
e.g. typing at the "|": >
What | Before | After
What | Before | After
==============================================
<BS> | call expand(|) | call expand|
---------|------------------|-----------------
<S-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(|
<
------------------------------------------------------------------------------
@@ -144,8 +145,8 @@ e.g. typing at the "|": >
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.
This feature doesn't currently work on blockwise visual mode, any suggestions
will be welcome.
NOTE that this feature brakes the redo command and doesn't currently work on
blockwise visual mode, any suggestions will be welcome.
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 ~
|---------|------------|-----------------------------------------------------|
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.
- A single quote typed after an alphanumeric
character is considered an apostrophe and one

View File

@@ -25,7 +25,7 @@ if v:version < 700
endif
let s:loaded_delimitMate = 1 " }}}
let delimitMate_version = '2.1_DEV'
let delimitMate_version = '2.1'
"}}}
@@ -70,8 +70,8 @@ function! s:Init() "{{{
else
let s:excluded_regions = "Comment"
endif
let b:delimitMate_excluded_regions_list = split(s:excluded_regions) " }}}
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list)
let b:delimitMate_excluded_regions_list = split(s:excluded_regions, ',\s*')
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) " }}}
" 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:
command! DelimitMateTest call s:TestMappingsDo()
"command! DelimitMateRegions echo s:excluded_regions
" Turn
" Run on file type events.