mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Rename and reorder some function, update doc.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
" ============================================================================
|
||||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.3.1
|
||||
" Version: 2.4DEV
|
||||
" Modified: 2010-06-06
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
@@ -348,10 +348,41 @@ function! delimitMate#FlushBuffer() " {{{
|
||||
let b:delimitMate_buffer = []
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" 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)
|
||||
return ''
|
||||
endif
|
||||
@@ -368,6 +399,35 @@ function! delimitMate#JumpIn(char) " {{{
|
||||
return ''
|
||||
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) "{{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return a:char
|
||||
@@ -406,65 +466,6 @@ function! delimitMate#JumpAny(key) " {{{
|
||||
endif
|
||||
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) "{{{
|
||||
redraw
|
||||
echomsg a:msg
|
||||
@@ -577,7 +578,7 @@ function! delimitMate#AutoClose() "{{{
|
||||
while i < len(b:delimitMate_matchpairs_list)
|
||||
let ld = b:delimitMate_left_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
|
||||
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:
|
||||
http://gist.github.com/144619
|
||||
|
||||
- Vim Scripts:
|
||||
http://www.vim.org/scripts
|
||||
- Karl Guertin
|
||||
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*
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3.1 2010-06-06 * Current release:
|
||||
- Fix: an extra <Space> is inserted after <Space>
|
||||
2.4DEV 2010-06-06 * Current release:
|
||||
- xxx
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||
expansion.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||
or other regions, customizable.
|
||||
@@ -562,16 +575,19 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
||||
indentation adjustments anymore.
|
||||
- Fix: Arrow keys would insert A, B, C or D instead
|
||||
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.
|
||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||
- Fix: A small problem when inserting a delimiter at
|
||||
the beginning of the line.
|
||||
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
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.
|
||||
@@ -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
|
||||
set.
|
||||
- <S-Backspace> deletes the closing delimiter.
|
||||
|
||||
* Fixed bug:
|
||||
- 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
|
||||
" Version: 2.3.1
|
||||
" Version: 2.4DEV
|
||||
" Modified: 2010-06-06
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
@@ -26,7 +26,7 @@ if v:version < 700
|
||||
endif
|
||||
|
||||
let s:loaded_delimitMate = 1 " }}}
|
||||
let delimitMate_version = "2.3.1"
|
||||
let delimitMate_version = "2.4DEV"
|
||||
|
||||
"}}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user