mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-09 14:14:46 +08:00
Rename and reorder some function, update doc.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: autoload/delimitMate.vim
|
" File: autoload/delimitMate.vim
|
||||||
" Version: 2.3.1
|
" Version: 2.4DEV
|
||||||
" Modified: 2010-06-06
|
" Modified: 2010-06-06
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
@@ -348,10 +348,41 @@ function! delimitMate#FlushBuffer() " {{{
|
|||||||
let b:delimitMate_buffer = []
|
let b:delimitMate_buffer = []
|
||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Doers {{{
|
" Doers {{{
|
||||||
function! delimitMate#JumpIn(char) " {{{
|
function! delimitMate#SkipDelim(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
|
let col = col('.') - 1
|
||||||
|
let line = getline('.')
|
||||||
|
if col > 0
|
||||||
|
let cur = line[col]
|
||||||
|
let pre = line[col-1]
|
||||||
|
else
|
||||||
|
let cur = line[col]
|
||||||
|
let pre = ""
|
||||||
|
endif
|
||||||
|
if pre == "\\"
|
||||||
|
" Escaped character
|
||||||
|
return a:char
|
||||||
|
elseif cur == a:char
|
||||||
|
" Exit pair
|
||||||
|
"return delimitMate#WriteBefore(a:char)
|
||||||
|
return a:char . delimitMate#Del()
|
||||||
|
elseif delimitMate#IsEmptyPair( pre . a:char )
|
||||||
|
" Add closing delimiter and jump back to the middle.
|
||||||
|
call insert(b:delimitMate_buffer, a:char)
|
||||||
|
return delimitMate#WriteAfter(a:char)
|
||||||
|
else
|
||||||
|
" Nothing special here, return the same character.
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! delimitMate#ParenDelim(char) " {{{
|
||||||
if delimitMate#IsForbidden(a:char)
|
if delimitMate#IsForbidden(a:char)
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@@ -368,6 +399,35 @@ function! delimitMate#JumpIn(char) " {{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! delimitMate#QuoteDelim(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.') - 2
|
||||||
|
if line[col] == "\\"
|
||||||
|
" Seems like a escaped character, insert one quotation mark.
|
||||||
|
return a:char
|
||||||
|
elseif line[col + 1] == a:char
|
||||||
|
" Get out of the string.
|
||||||
|
"return delimitMate#WriteBefore(a:char)
|
||||||
|
return a:char . delimitMate#Del()
|
||||||
|
elseif (line[col] =~ '[a-zA-Z0-9]' && a:char == "'") ||
|
||||||
|
\(line[col] =~ '[a-zA-Z0-9]' && b:delimitMate_smart_quotes)
|
||||||
|
" Seems like an apostrophe or a closing, insert a single quote.
|
||||||
|
return a:char
|
||||||
|
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:delimitMate_smart_quotes
|
||||||
|
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
||||||
|
call insert(b:delimitMate_buffer, a:char)
|
||||||
|
return delimitMate#WriteAfter(a:char)
|
||||||
|
else
|
||||||
|
" Insert a pair and jump to the middle.
|
||||||
|
call insert(b:delimitMate_buffer, a:char)
|
||||||
|
call delimitMate#WriteAfter(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#JumpOut(char) "{{{
|
function! delimitMate#JumpOut(char) "{{{
|
||||||
if delimitMate#IsForbidden(a:char)
|
if delimitMate#IsForbidden(a:char)
|
||||||
return a:char
|
return a:char
|
||||||
@@ -406,65 +466,6 @@ function! delimitMate#JumpAny(key) " {{{
|
|||||||
endif
|
endif
|
||||||
endfunction " delimitMate#JumpAny() }}}
|
endfunction " delimitMate#JumpAny() }}}
|
||||||
|
|
||||||
function! delimitMate#SkipDelim(char) "{{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let col = col('.') - 1
|
|
||||||
let line = getline('.')
|
|
||||||
if col > 0
|
|
||||||
let cur = line[col]
|
|
||||||
let pre = line[col-1]
|
|
||||||
else
|
|
||||||
let cur = line[col]
|
|
||||||
let pre = ""
|
|
||||||
endif
|
|
||||||
if pre == "\\"
|
|
||||||
" Escaped character
|
|
||||||
return a:char
|
|
||||||
elseif cur == a:char
|
|
||||||
" Exit pair
|
|
||||||
"return delimitMate#WriteBefore(a:char)
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
|
||||||
" Add closing delimiter and jump back to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
return delimitMate#WriteAfter(a:char)
|
|
||||||
else
|
|
||||||
" Nothing special here, return the same character.
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#QuoteDelim(char) "{{{
|
|
||||||
if delimitMate#IsForbidden(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') - 2
|
|
||||||
if line[col] == "\\"
|
|
||||||
" Seems like a escaped character, insert one quotation mark.
|
|
||||||
return a:char
|
|
||||||
elseif line[col + 1] == a:char
|
|
||||||
" Get out of the string.
|
|
||||||
"return delimitMate#WriteBefore(a:char)
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
elseif (line[col] =~ '[a-zA-Z0-9]' && a:char == "'") ||
|
|
||||||
\(line[col] =~ '[a-zA-Z0-9]' && b:delimitMate_smart_quotes)
|
|
||||||
" Seems like an apostrophe or a closing, insert a single quote.
|
|
||||||
return a:char
|
|
||||||
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:delimitMate_smart_quotes
|
|
||||||
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
return delimitMate#WriteAfter(a:char)
|
|
||||||
else
|
|
||||||
" Insert a pair and jump to the middle.
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
call delimitMate#WriteAfter(a:char)
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#MapMsg(msg) "{{{
|
function! delimitMate#MapMsg(msg) "{{{
|
||||||
redraw
|
redraw
|
||||||
echomsg a:msg
|
echomsg a:msg
|
||||||
@@ -577,7 +578,7 @@ function! delimitMate#AutoClose() "{{{
|
|||||||
while i < len(b:delimitMate_matchpairs_list)
|
while i < len(b:delimitMate_matchpairs_list)
|
||||||
let ld = b:delimitMate_left_delims[i]
|
let ld = b:delimitMate_left_delims[i]
|
||||||
let rd = b:delimitMate_right_delims[i]
|
let rd = b:delimitMate_right_delims[i]
|
||||||
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#JumpIn("' . rd . '")<CR>'
|
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . rd . '")<CR>'
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.3.1 *delimitMate.txt*
|
*delimitMate* Trying to keep those beasts at bay! v2.4DEV *delimitMate.txt*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -541,19 +541,32 @@ from the following sources:
|
|||||||
From the comments on the previous blog post and from:
|
From the comments on the previous blog post and from:
|
||||||
http://gist.github.com/144619
|
http://gist.github.com/144619
|
||||||
|
|
||||||
- Vim Scripts:
|
- Karl Guertin
|
||||||
http://www.vim.org/scripts
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=1849
|
||||||
|
|
||||||
This script was inspired by the auto-completion of delimiters of TextMate.
|
- Thiago Alves
|
||||||
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2009
|
||||||
|
|
||||||
|
- Edoardo Vacchi
|
||||||
|
ClosePairs:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2373
|
||||||
|
|
||||||
|
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. HISTORY *delimitMateHistory*
|
9. HISTORY *delimitMateHistory*
|
||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.3.1 2010-06-06 * Current release:
|
2.4DEV 2010-06-06 * Current release:
|
||||||
- Fix: an extra <Space> is inserted after <Space>
|
- xxx
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||||
expansion.
|
expansion.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
or other regions, customizable.
|
or other regions, customizable.
|
||||||
@@ -562,16 +575,19 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
indentation adjustments anymore.
|
indentation adjustments anymore.
|
||||||
- Fix: Arrow keys would insert A, B, C or D instead
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
of moving the cursor when using Vim on a terminal.
|
of moving the cursor when using Vim on a terminal.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||||
- Fix: A small problem when inserting a delimiter at
|
- Fix: A small problem when inserting a delimiter at
|
||||||
the beginning of the line.
|
the beginning of the line.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
2.1 2010-05-10 * - Most of the functions have been moved to an
|
||||||
autoload script to avoid loading unnecessary ones.
|
autoload script to avoid loading unnecessary ones.
|
||||||
- Fixed a problem with the redo command.
|
- Fixed a problem with the redo command.
|
||||||
- Many small fixes.
|
- Many small fixes.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.0 2010-04-01 * New features:
|
2.0 2010-04-01 * New features:
|
||||||
- All features are redo/undo-wise safe.
|
- All features are redo/undo-wise safe.
|
||||||
@@ -587,7 +603,6 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
active if you have any of the expansion options
|
active if you have any of the expansion options
|
||||||
set.
|
set.
|
||||||
- <S-Backspace> deletes the closing delimiter.
|
- <S-Backspace> deletes the closing delimiter.
|
||||||
|
|
||||||
* Fixed bug:
|
* Fixed bug:
|
||||||
- s:vars were being used to store buffer options.
|
- s:vars were being used to store buffer options.
|
||||||
|
|
||||||
@@ -646,4 +661,4 @@ _____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|||||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: plugin/delimitMate.vim
|
" File: plugin/delimitMate.vim
|
||||||
" Version: 2.3.1
|
" Version: 2.4DEV
|
||||||
" Modified: 2010-06-06
|
" Modified: 2010-06-06
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
@@ -26,7 +26,7 @@ if v:version < 700
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1 " }}}
|
let s:loaded_delimitMate = 1 " }}}
|
||||||
let delimitMate_version = "2.3.1"
|
let delimitMate_version = "2.4DEV"
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user