mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-08 21:54:47 +08:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9cea6312a | ||
|
|
1b37d60840 | ||
|
|
a70aa5285e | ||
|
|
2eba04961d | ||
|
|
3519f82f79 | ||
|
|
e9491e473c | ||
|
|
9e3075cff5 | ||
|
|
7c9ba95565 | ||
|
|
3ae285424c | ||
|
|
fa1d3b3d6a | ||
|
|
63f8c2af4f | ||
|
|
29eb98d79d | ||
|
|
5b004ca49d | ||
|
|
34df78f8ab | ||
|
|
e234e45846 | ||
|
|
081ec279ed | ||
|
|
4399fa327f | ||
|
|
ceaa6e01ed | ||
|
|
235f0dcbfb | ||
|
|
fadd7fefbc | ||
|
|
193b6027c2 | ||
|
|
a76439a641 | ||
|
|
89cc598217 | ||
|
|
28ce6213fc | ||
|
|
6d1f48c1bf | ||
|
|
0e20bcaff8 | ||
|
|
aae61ad8ba | ||
|
|
4dac6ce6ac | ||
|
|
875a9e450b | ||
|
|
48d2e3b9d1 | ||
|
|
5626a633d5 | ||
|
|
3652ba24e3 | ||
|
|
740fc90ae7 | ||
|
|
e0de2dbf39 | ||
|
|
efcf9eb341 | ||
|
|
2545fa5967 | ||
|
|
c91674eed2 | ||
|
|
542728671e | ||
|
|
d1621b6672 | ||
|
|
6d1cc1187b | ||
|
|
377c3a37e1 | ||
|
|
d03324135c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
|||||||
*.sw?
|
*.sw?
|
||||||
|
*.un?
|
||||||
*.vba
|
*.vba
|
||||||
*.zip
|
*.zip
|
||||||
*.gz
|
*.gz
|
||||||
vimball.txt
|
vimball.txt
|
||||||
*.orig
|
*.orig
|
||||||
|
tags
|
||||||
|
|||||||
24
Makefile
24
Makefile
@@ -10,12 +10,12 @@ VIM=/usr/bin/vim
|
|||||||
|
|
||||||
.PHONY: $(PLUGIN).vba README
|
.PHONY: $(PLUGIN).vba README
|
||||||
|
|
||||||
install: vimball
|
#install: vimball
|
||||||
@echo install
|
#@echo install
|
||||||
$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
|
#$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
|
||||||
cp -f $(TESTS) $(VIMFOLDER)$(TESTS)
|
#cp -f $(TESTS) $(VIMFOLDER)$(TESTS)
|
||||||
|
|
||||||
all: uninstall vimball install README zip gzip
|
all: vimball README zip gzip
|
||||||
|
|
||||||
vimball: $(PLUGIN).vba
|
vimball: $(PLUGIN).vba
|
||||||
|
|
||||||
@@ -25,10 +25,10 @@ clean:
|
|||||||
|
|
||||||
dist-clean: clean
|
dist-clean: clean
|
||||||
|
|
||||||
uninstall:
|
#uninstall:
|
||||||
@echo uninstall
|
#@echo uninstall
|
||||||
$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
|
#$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
|
||||||
rm -f $(VIMFOLDER)$(TESTS)
|
#rm -f $(VIMFOLDER)$(TESTS)
|
||||||
|
|
||||||
undo:
|
undo:
|
||||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||||
@@ -47,8 +47,10 @@ zip:
|
|||||||
@echo zip
|
@echo zip
|
||||||
rm -f *.zip
|
rm -f *.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\? || echo 1
|
||||||
zip $(PLUGIN).zip -d \*.orig
|
zip $(PLUGIN).zip -d \*.un\? || echo 1
|
||||||
|
zip $(PLUGIN).zip -d \*.orig || echo 1
|
||||||
|
zip $(PLUGIN).zip -d \*tags || echo 1
|
||||||
zip $(PLUGIN).zip -d $(TESTS)
|
zip $(PLUGIN).zip -d $(TESTS)
|
||||||
ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
|
ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
|
||||||
|
|
||||||
|
|||||||
104
README
104
README
@@ -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.4 *delimitMate.txt*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -90,6 +90,9 @@ Without auto-close: >
|
|||||||
–––––––––-|––––––––––
|
–––––––––-|––––––––––
|
||||||
()<S-Tab> | ()|
|
()<S-Tab> | ()|
|
||||||
<
|
<
|
||||||
|
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||||
|
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||||
|
|
||||||
@@ -125,8 +128,9 @@ If you press backspace inside an empty pair, both delimiters are deleted. When
|
|||||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||||
deleting <CR> expansions will brake the redo command.
|
deleting <CR> expansions will brake the redo command.
|
||||||
|
|
||||||
If you type shift + backspace instead, only the closing delimiter will be
|
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||||
deleted.
|
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||||
|
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
@@ -149,8 +153,9 @@ 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.
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
NOTE that this feature brakes the redo command and doesn't currently work well
|
||||||
blockwise visual mode, any suggestions to fix this will be very welcome.
|
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): >
|
e.g. (selection represented between square brackets): >
|
||||||
|
|
||||||
@@ -162,9 +167,10 @@ e.g. (selection represented between square brackets): >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
||||||
|
|
||||||
Only one quote will be inserted following a quote, a "\" or an alphanumeric
|
Only one quote will be inserted following a quote, a "\" or, following or
|
||||||
character. This should cover closing quotes, escaped quotes and apostrophes.
|
preceding an alphanumeric character. This should cover closing quotes after a
|
||||||
Except for apostrophes, this feature can be disabled setting the option
|
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||||
|
for apostrophes, this feature can be disabled setting the option
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
|'delimitMate_smart_quotes'| to 0.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
@@ -233,6 +239,10 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||||
used.
|
used.
|
||||||
|
|
||||||
|
|'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_visual_leader'| Sets the leader to be used in visual mode.
|
||||||
|
|
||||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||||
@@ -286,7 +296,7 @@ e.g.: >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_matchpairs'*
|
*'delimitMate_matchpairs'*
|
||||||
*'b:delimitMate_matchpairs'*
|
*'b:delimitMate_matchpairs'*
|
||||||
Values: A string with |matchpairs| syntax. ~
|
Values: A string with |'matchpairs'| syntax. ~
|
||||||
Default: &matchpairs ~
|
Default: &matchpairs ~
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered
|
Use this option to tell delimitMate which characters should be considered
|
||||||
@@ -304,9 +314,21 @@ Default: "\" ' `" ~
|
|||||||
Use this option to tell delimitMate which characters should be considered as
|
Use this option to tell delimitMate which characters should be considered as
|
||||||
quotes. Read |delimitMateAutoClose| for details.
|
quotes. Read |delimitMateAutoClose| for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_quotes = "\" ' ` *"
|
let delimitMate_quotes = "\" ' ` *"
|
||||||
au FileType html let b:delimitMate_quotes = "\" '"
|
au FileType html let b:delimitMate_quotes = "\" '"
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_nesting_quotes'*
|
||||||
|
*'b:delimitMate_nesting_quotes'*
|
||||||
|
Values: A list of quotes. ~
|
||||||
|
Default: [] ~
|
||||||
|
|
||||||
|
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||||
|
allowing the autoclosed quotes to be nested.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_quotes = ['"','`']
|
||||||
|
au FileType python let b:delimitMate_quotes = ['"']
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_visual_leader'*
|
*'delimitMate_visual_leader'*
|
||||||
*'b:delimitMate_visual_leader'*
|
*'b:delimitMate_visual_leader'*
|
||||||
@@ -328,20 +350,20 @@ Default: 0 ~
|
|||||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
|
let delimitMate_expand_cr = 1
|
||||||
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
|
au FileType mail let b:delimitMate_expand_cr = 1
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_expand_space'*
|
*'delimitMate_expand_space'*
|
||||||
*'b:delimitMate_expand_space'*
|
*'b:delimitMate_expand_space'*
|
||||||
Values: A key mapping. ~
|
Values: 1 or 0 ~
|
||||||
Default: "\<Space>" ~
|
Default: 0 ~
|
||||||
|
|
||||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
|
let delimitMate_expand_space = 1
|
||||||
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
|
au FileType tcl let b:delimitMate_expand_space = 1
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_excluded_ft'*
|
*'delimitMate_excluded_ft'*
|
||||||
@@ -471,9 +493,15 @@ Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
|||||||
might not work as expected or at all.
|
might not work as expected or at all.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||||
|
e.g.: >
|
||||||
|
|
||||||
|
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||||
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||||
|
\ "external_mapping"
|
||||||
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
||||||
@@ -484,7 +512,8 @@ Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
|||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
||||||
<CR> inside an empty pair: >
|
<CR> inside an empty pair: >
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
inoremap <expr> <CR> pumvisible() ?
|
||||||
|
\"\<c-y>" :
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
@@ -509,14 +538,14 @@ This function returns a mapping that will make the cursor jump to the right
|
|||||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. TODO LIST *delimitMateTodo*
|
6. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
7. MAINTAINER *delimitMateMaintainer*
|
||||||
@@ -541,19 +570,38 @@ 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.4 2010-07-29 * Current release:
|
||||||
- Fix: an extra <Space> is inserted after <Space>
|
- Unbalanced parens: see :help delimitMateBalance.
|
||||||
|
- Visual wrapping now works on block-wise visual
|
||||||
|
with some limitations.
|
||||||
|
- Arrow keys didn't work on terminal.
|
||||||
|
- Added option to allow nested quotes.
|
||||||
|
- Expand Smart Quotes to look for a string on the
|
||||||
|
right of the cursor.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
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 +610,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 +638,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 +696,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,158 +1,170 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: autoload/delimitMate.vim
|
" File: autoload/delimitMate.vim
|
||||||
" Version: 2.3.1
|
" Version: 2.4
|
||||||
" Modified: 2010-06-06
|
" Modified: 2010-07-29
|
||||||
" 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>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
|
|
||||||
" Utilities {{{
|
" Utilities {{{
|
||||||
|
|
||||||
|
function! delimitMate#option_init(name, default) "{{{
|
||||||
|
let b = exists("b:delimitMate_" . a:name)
|
||||||
|
let g = exists("g:delimitMate_" . a:name)
|
||||||
|
let prefix = "_l_delimitMate_"
|
||||||
|
|
||||||
|
if !b && !g
|
||||||
|
let sufix = a:default
|
||||||
|
elseif !b && g
|
||||||
|
exec "let sufix = g:delimitMate_" . a:name
|
||||||
|
else
|
||||||
|
exec "let sufix = b:delimitMate_" . a:name
|
||||||
|
endif
|
||||||
|
if exists("b:" . prefix . a:name)
|
||||||
|
exec "unlockvar! b:" . prefix . a:name
|
||||||
|
endif
|
||||||
|
exec "let b:" . prefix . a:name . " = " . string(sufix)
|
||||||
|
exec "lockvar! b:" . prefix . a:name
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#Init() "{{{
|
function! delimitMate#Init() "{{{
|
||||||
" Initialize variables:
|
" Initialize variables:
|
||||||
|
|
||||||
" delimitMate_autoclose {{{
|
" autoclose
|
||||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
call delimitMate#option_init("autoclose", 1)
|
||||||
let b:delimitMate_autoclose = 1
|
|
||||||
elseif !exists("b:delimitMate_autoclose") && exists("g:delimitMate_autoclose")
|
|
||||||
let b:delimitMate_autoclose = g:delimitMate_autoclose
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_matchpairs {{{
|
" matchpairs
|
||||||
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
|
call delimitMate#option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||||
let s:matchpairs_temp = &matchpairs
|
call delimitMate#option_init("matchpairs_list", split(b:_l_delimitMate_matchpairs, ','))
|
||||||
elseif exists("b:delimitMate_matchpairs")
|
call delimitMate#option_init("left_delims", split(b:_l_delimitMate_matchpairs, ':.,\='))
|
||||||
let s:matchpairs_temp = b:delimitMate_matchpairs
|
call delimitMate#option_init("right_delims", split(b:_l_delimitMate_matchpairs, ',\=.:'))
|
||||||
else
|
|
||||||
let s:matchpairs_temp = g:delimitMate_matchpairs
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_quotes {{{
|
" quotes
|
||||||
if exists("b:delimitMate_quotes")
|
call delimitMate#option_init("quotes", "\" ' `")
|
||||||
let s:quotes = split(b:delimitMate_quotes)
|
call delimitMate#option_init("quotes_list", split(b:_l_delimitMate_quotes))
|
||||||
elseif exists("g:delimitMate_quotes")
|
|
||||||
let s:quotes = split(g:delimitMate_quotes)
|
|
||||||
else
|
|
||||||
let s:quotes = split("\" ' `")
|
|
||||||
endif
|
|
||||||
let b:delimitMate_quotes_list = s:quotes " }}}
|
|
||||||
|
|
||||||
" delimitMate_excluded_regions {{{
|
" nesting_quotes
|
||||||
if exists("b:delimitMate_excluded_regions")
|
call delimitMate#option_init("nesting_quotes", [])
|
||||||
let s:excluded_regions = b:delimitMate_excluded_regions
|
|
||||||
elseif exists("g:delimitMate_excluded_regions")
|
|
||||||
let s:excluded_regions = g:delimitMate_excluded_regions
|
|
||||||
else
|
|
||||||
let s:excluded_regions = "Comment"
|
|
||||||
endif
|
|
||||||
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 {{{
|
" excluded_regions
|
||||||
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
|
call delimitMate#option_init("excluded_regions", "Comment")
|
||||||
let b:delimitMate_visual_leader = exists('b:maplocalleader') ? b:maplocalleader :
|
call delimitMate#option_init("excluded_regions_list", split(b:_l_delimitMate_excluded_regions, ',\s*'))
|
||||||
|
let enabled = len(b:_l_delimitMate_excluded_regions_list) > 0
|
||||||
|
call delimitMate#option_init("excluded_regions_enabled", enabled)
|
||||||
|
|
||||||
|
" visual_leader
|
||||||
|
let leader = exists('b:maplocalleader') ? b:maplocalleader :
|
||||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
\ exists('g:mapleader') ? g:mapleader : "\\"
|
||||||
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
|
call delimitMate#option_init("visual_leader", leader)
|
||||||
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_expand_space {{{
|
" expand_space
|
||||||
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||||
let b:delimitMate_expand_space = 0
|
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
elseif !exists("b:delimitMate_expand_space") && exists("g:delimitMate_expand_space")
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
let b:delimitMate_expand_space = g:delimitMate_expand_space
|
unlet b:delimitMate_expand_space
|
||||||
else
|
let b:delimitMate_expand_space = 1
|
||||||
" Nothing to do.
|
endif
|
||||||
endif " }}}
|
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("")
|
||||||
|
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
|
unlet g:delimitMate_expand_space
|
||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
endif
|
||||||
|
call delimitMate#option_init("expand_space", 0)
|
||||||
|
|
||||||
" delimitMate_expand_cr {{{
|
" expand_cr
|
||||||
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
|
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
||||||
|
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet b:delimitMate_expand_cr
|
||||||
|
let b:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
||||||
|
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet g:delimitMate_expand_cr
|
||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if &backspace !~ 'eol' || &backspace !~ 'start'
|
||||||
|
echom "delimitMate: In order to use the <CR> expansion, you need to have 'eol' and 'start' in your backspace option. Read :help 'backspace'."
|
||||||
let b:delimitMate_expand_cr = 0
|
let b:delimitMate_expand_cr = 0
|
||||||
elseif !exists("b:delimitMate_expand_cr") && exists("g:delimitMate_expand_cr")
|
|
||||||
let b:delimitMate_expand_cr = g:delimitMate_expand_cr
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_smart_quotes {{{
|
|
||||||
if !exists("b:delimitMate_smart_quotes") && !exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = 1
|
|
||||||
elseif !exists("b:delimitMate_smart_quotes") && exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = split(g:delimitMate_smart_quotes)
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_apostrophes {{{
|
|
||||||
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes")
|
|
||||||
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
|
|
||||||
let s:apostrophes = []
|
|
||||||
elseif !exists("b:delimitMate_apostrophes") && exists("g:delimitMate_apostrophes")
|
|
||||||
let s:apostrophes = split(g:delimitMate_apostrophes)
|
|
||||||
else
|
|
||||||
let s:apostrophes = split(b:delimitMate_apostrophes)
|
|
||||||
endif
|
endif
|
||||||
let b:delimitMate_apostrophes_list = s:apostrophes " }}}
|
call delimitMate#option_init("expand_cr", 0)
|
||||||
|
|
||||||
" delimitMate_tab2exit {{{
|
" smart_quotes
|
||||||
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
|
call delimitMate#option_init("smart_quotes", 1)
|
||||||
let b:delimitMate_tab2exit = 1
|
|
||||||
elseif !exists("b:delimitMate_tab2exit") && exists("g:delimitMate_tab2exit")
|
|
||||||
let b:delimitMate_tab2exit = g:delimitMate_tab2exit
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
let b:delimitMate_matchpairs_list = split(s:matchpairs_temp, ',')
|
" apostrophes
|
||||||
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
|
call delimitMate#option_init("apostrophes", "")
|
||||||
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
|
call delimitMate#option_init("apostrophes_list", split(b:_l_delimitMate_apostrophes, ":\s*"))
|
||||||
|
|
||||||
let b:delimitMate_buffer = []
|
" tab2exit
|
||||||
|
call delimitMate#option_init("tab2exit", 1)
|
||||||
|
|
||||||
call delimitMate#UnMap()
|
" unbalanced_parens
|
||||||
if b:delimitMate_autoclose
|
call delimitMate#option_init("unbalanced_parens", 0)
|
||||||
call delimitMate#AutoClose()
|
|
||||||
else
|
let b:_l_delimitMate_buffer = []
|
||||||
call delimitMate#NoAutoClose()
|
|
||||||
endif
|
|
||||||
call delimitMate#VisualMaps()
|
|
||||||
call delimitMate#ExtraMappings()
|
|
||||||
|
|
||||||
let b:loaded_delimitMate = 1
|
let b:loaded_delimitMate = 1
|
||||||
let b:delimitMate_enabled = 1
|
|
||||||
endfunction "}}} Init()
|
endfunction "}}} Init()
|
||||||
|
|
||||||
|
function! delimitMate#Map() "{{{
|
||||||
|
" Set mappings:
|
||||||
|
try
|
||||||
|
let save_cpo = &cpo
|
||||||
|
let save_keymap = &keymap
|
||||||
|
let save_iminsert = &iminsert
|
||||||
|
let save_imsearch = &imsearch
|
||||||
|
set keymap=
|
||||||
|
set cpo&vim
|
||||||
|
if b:_l_delimitMate_autoclose
|
||||||
|
call delimitMate#AutoClose()
|
||||||
|
else
|
||||||
|
call delimitMate#NoAutoClose()
|
||||||
|
endif
|
||||||
|
call delimitMate#VisualMaps()
|
||||||
|
call delimitMate#ExtraMappings()
|
||||||
|
finally
|
||||||
|
let &cpo = save_cpo
|
||||||
|
let &keymap = save_keymap
|
||||||
|
let &iminsert = save_iminsert
|
||||||
|
let &imsearch = save_imsearch
|
||||||
|
endtry
|
||||||
|
|
||||||
|
let b:delimitMate_enabled = 1
|
||||||
|
|
||||||
|
endfunction "}}} Map()
|
||||||
|
|
||||||
function! delimitMate#ShouldJump() "{{{
|
function! delimitMate#ShouldJump() "{{{
|
||||||
" Returns 1 if the next character is a closing delimiter.
|
" Returns 1 if the next character is a closing delimiter.
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
let lcol = col('$')
|
let lcol = col('$')
|
||||||
let char = getline('.')[col - 1]
|
let char = getline('.')[col - 1]
|
||||||
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
" Closing delimiter on the right.
|
||||||
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if char == cdel
|
if char == cdel
|
||||||
" Closing delimiter on the right.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Closing delimiter with space expansion.
|
||||||
let nchar = getline('.')[col]
|
let nchar = getline('.')[col]
|
||||||
if b:delimitMate_expand_space && char == " "
|
if b:_l_delimitMate_expand_space && char == " "
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if nchar == cdel
|
if nchar == cdel
|
||||||
" Closing delimiter with space expansion.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Closing delimiter with CR expansion.
|
||||||
let uchar = getline(line('.') + 1)[0]
|
let uchar = getline(line('.') + 1)[0]
|
||||||
if b:delimitMate_expand_cr && char == ""
|
if b:_l_delimitMate_expand_cr && char == ""
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if uchar == cdel
|
if uchar == cdel
|
||||||
" Closing delimiter with CR expansion.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -161,71 +173,54 @@ function! delimitMate#ShouldJump() "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsBlockVisual() " {{{
|
function! delimitMate#Visual(del) " {{{
|
||||||
if mode() == "\<C-V>"
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
if len(getline('.')) == 0
|
||||||
" This for proper wrap of empty lines.
|
" This for proper wrap of empty lines.
|
||||||
let @" = "\n"
|
let @" = "\n"
|
||||||
endif
|
endif
|
||||||
return 0
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#Visual(del) " {{{
|
" 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()
|
let mode = mode()
|
||||||
if mode == "\<C-V>"
|
if mode == "\<C-V>"
|
||||||
redraw
|
" Block-wise visual
|
||||||
echom "delimitMate: delimitMate is disabled on blockwise visual mode."
|
return "I" . ld . "\<Esc>gv\<Right>A" . rd . "\<Esc>"
|
||||||
return ""
|
elseif mode ==# "V"
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if mode ==# "V"
|
|
||||||
let dchar = "\<BS>"
|
let dchar = "\<BS>"
|
||||||
else
|
else
|
||||||
let dchar = ""
|
let dchar = ""
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let index = index(b:delimitMate_left_delims, a:del)
|
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
||||||
if index >= 0
|
let b:save_reg = getreg('"')
|
||||||
let ld = a:del
|
let b:save_reg_mode = getregtype('"')
|
||||||
let rd = b:delimitMate_right_delims[index]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_right_delims, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = b:delimitMate_left_delims[index]
|
|
||||||
let rd = a:del
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_quotes_list, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = a:del
|
|
||||||
let rd = ld
|
|
||||||
endif
|
|
||||||
|
|
||||||
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
|
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#IsEmptyPair(str) "{{{
|
function! delimitMate#IsEmptyPair(str) "{{{
|
||||||
for pair in b:delimitMate_matchpairs_list
|
for pair in b:_l_delimitMate_matchpairs_list
|
||||||
if a:str == join( split( pair, ':' ),'' )
|
if a:str == join( split( pair, ':' ),'' )
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for quote in b:delimitMate_quotes_list
|
for quote in b:_l_delimitMate_quotes_list
|
||||||
if a:str == quote . quote
|
if a:str == quote . quote
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -237,12 +232,12 @@ function! delimitMate#IsCRExpansion() " {{{
|
|||||||
let nchar = getline(line('.')-1)[-1:]
|
let nchar = getline(line('.')-1)[-1:]
|
||||||
let schar = getline(line('.')+1)[:0]
|
let schar = getline(line('.')+1)[:0]
|
||||||
let isEmpty = getline('.') == ""
|
let isEmpty = getline('.') == ""
|
||||||
if index(b:delimitMate_left_delims, nchar) > -1 &&
|
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
|
||||||
\ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) &&
|
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
|
||||||
\ isEmpty
|
\ isEmpty
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:delimitMate_quotes_list, nchar) > -1 &&
|
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
|
||||||
\ index(b:delimitMate_quotes_list, nchar) == index(b:delimitMate_quotes_list, schar) &&
|
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
|
||||||
\ isEmpty
|
\ isEmpty
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
@@ -258,12 +253,12 @@ function! delimitMate#IsSpaceExpansion() " {{{
|
|||||||
let nchar = line[col + 2]
|
let nchar = line[col + 2]
|
||||||
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
||||||
|
|
||||||
if index(b:delimitMate_left_delims, pchar) > -1 &&
|
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
|
||||||
\ index(b:delimitMate_left_delims, pchar) == index(b:delimitMate_right_delims, nchar) &&
|
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:delimitMate_quotes_list, pchar) > -1 &&
|
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
|
||||||
\ index(b:delimitMate_quotes_list, pchar) == index(b:delimitMate_quotes_list, nchar) &&
|
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -301,7 +296,7 @@ function! delimitMate#WriteAfter(str) "{{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#RestoreRegister() " {{{
|
function! delimitMate#RestoreRegister() " {{{
|
||||||
" Restore unnamed register values store in delimitMate#IsBlockVisual().
|
" Restore unnamed register values stored in delimitMate#Visual().
|
||||||
call setreg('"', b:save_reg, b:save_reg_mode)
|
call setreg('"', b:save_reg, b:save_reg_mode)
|
||||||
echo ""
|
echo ""
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
@@ -329,45 +324,156 @@ function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsForbidden(char) "{{{
|
function! delimitMate#IsForbidden(char) "{{{
|
||||||
if b:delimitMate_excluded_regions_enabled == 0
|
if b:_l_delimitMate_excluded_regions_enabled == 0
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
"let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
"let result = index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
if index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
if index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
"echom "Forbidden 1!"
|
"echom "Forbidden 1!"
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
||||||
"let result = index(b:delimitMate_excluded_regions_list, region) >= 0
|
"let result = index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||||
"return result || region == 'Comment'
|
"return result || region == 'Comment'
|
||||||
"echom "Forbidden 2!"
|
"echom "Forbidden 2!"
|
||||||
return index(b:delimitMate_excluded_regions_list, region) >= 0
|
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#FlushBuffer() " {{{
|
function! delimitMate#FlushBuffer() " {{{
|
||||||
let b:delimitMate_buffer = []
|
let b:_l_delimitMate_buffer = []
|
||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! delimitMate#BalancedParens(char) "{{{
|
||||||
|
" Returns:
|
||||||
|
" = 0 => Parens balanced.
|
||||||
|
" > 0 => More opening parens.
|
||||||
|
" < 0 => More closing parens.
|
||||||
|
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.') - 2
|
||||||
|
let col = col >= 0 ? col : 0
|
||||||
|
let list = split(line, '\zs')
|
||||||
|
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
|
||||||
|
let right = a:char
|
||||||
|
let opening = 0
|
||||||
|
let closing = 0
|
||||||
|
|
||||||
|
" If the cursor is not at the beginning, count what's behind it.
|
||||||
|
if col > 0
|
||||||
|
" Find the first opening paren:
|
||||||
|
let start = index(list, left)
|
||||||
|
" Must be before cursor:
|
||||||
|
let start = start < col ? start : col - 1
|
||||||
|
" Now count from the first opening until the cursor, this will prevent
|
||||||
|
" extra closing parens from being counted.
|
||||||
|
let opening = count(list[start : col - 1], left)
|
||||||
|
let closing = count(list[start : col - 1], right)
|
||||||
|
" I don't care if there are more closing parens than opening parens.
|
||||||
|
let closing = closing > opening ? opening : closing
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Evaluate parens from the cursor to the end:
|
||||||
|
let opening += count(list[col :], left)
|
||||||
|
let closing += count(list[col :], right)
|
||||||
|
|
||||||
|
"echom "–––––––––"
|
||||||
|
"echom line
|
||||||
|
"echom col
|
||||||
|
""echom left.":".a:char
|
||||||
|
"echom string(list)
|
||||||
|
"echom string(list[start : col - 1]) . " : " . string(list[col :])
|
||||||
|
"echom opening . " - " . closing . " = " . (opening - closing)
|
||||||
|
|
||||||
|
" Return the found balance:
|
||||||
|
return opening - closing
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Doers {{{
|
" Doers {{{
|
||||||
function! delimitMate#JumpIn(char) " {{{
|
function! delimitMate#SkipDelim(char) "{{{
|
||||||
if delimitMate#IsForbidden(a: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:_l_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
|
||||||
|
if b:_l_delimitMate_unbalanced_parens &&
|
||||||
|
\ delimitMate#BalancedParens(a:char) <= 0
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')-2
|
let col = col('.')-2
|
||||||
if (col) < 0
|
if (col) < 0
|
||||||
call setline('.',a:char.line)
|
call setline('.',a:char.line)
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
else
|
else
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
endif
|
endif
|
||||||
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 &&
|
||||||
|
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
|
||||||
|
" Get out of the string.
|
||||||
|
return a:char . delimitMate#Del()
|
||||||
|
elseif (line[col] =~ '[[:alnum:]]' && a:char == "'") ||
|
||||||
|
\ (b:_l_delimitMate_smart_quotes &&
|
||||||
|
\ (line[col] =~ '[[:alnum:]]' ||
|
||||||
|
\ line[col + 1] =~ '[[:alnum:]]'))
|
||||||
|
" Seems like an apostrophe or a smart quote case, insert a single quote.
|
||||||
|
return a:char
|
||||||
|
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
|
||||||
|
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
||||||
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
|
return delimitMate#WriteAfter(a:char)
|
||||||
|
else
|
||||||
|
" Insert a pair and jump to the middle.
|
||||||
|
call insert(b:_l_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
|
||||||
@@ -398,7 +504,7 @@ function! delimitMate#JumpAny(key) " {{{
|
|||||||
elseif char == ""
|
elseif char == ""
|
||||||
" CR expansion.
|
" CR expansion.
|
||||||
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||||
let b:delimitMate_buffer = []
|
let b:_l_delimitMate_buffer = []
|
||||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||||
else
|
else
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
@@ -406,65 +512,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
|
||||||
@@ -491,7 +538,7 @@ function! delimitMate#ExpandSpace() "{{{
|
|||||||
endif
|
endif
|
||||||
if delimitMate#WithinEmptyPair()
|
if delimitMate#WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
call insert(b:delimitMate_buffer, 's')
|
call insert(b:_l_delimitMate_buffer, 's')
|
||||||
return delimitMate#WriteAfter(' ') . "\<Space>"
|
return delimitMate#WriteAfter(' ') . "\<Space>"
|
||||||
else
|
else
|
||||||
return "\<Space>"
|
return "\<Space>"
|
||||||
@@ -517,7 +564,7 @@ function! delimitMate#BS() " {{{
|
|||||||
endfunction " }}} delimitMate#BS()
|
endfunction " }}} delimitMate#BS()
|
||||||
|
|
||||||
function! delimitMate#Del() " {{{
|
function! delimitMate#Del() " {{{
|
||||||
if len(b:delimitMate_buffer) > 0
|
if len(b:_l_delimitMate_buffer) > 0
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') - 2
|
let col = col('.') - 2
|
||||||
call delimitMate#RmBuffer(1)
|
call delimitMate#RmBuffer(1)
|
||||||
@@ -529,11 +576,11 @@ function! delimitMate#Del() " {{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#Finish() " {{{
|
function! delimitMate#Finish() " {{{
|
||||||
let len = len(b:delimitMate_buffer)
|
let len = len(b:_l_delimitMate_buffer)
|
||||||
if len > 0
|
if len > 0
|
||||||
let buffer = join(b:delimitMate_buffer, '')
|
let buffer = join(b:_l_delimitMate_buffer, '')
|
||||||
" Reset buffer:
|
" Reset buffer:
|
||||||
let b:delimitMate_buffer = []
|
let b:_l_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
|
||||||
@@ -554,8 +601,8 @@ function! delimitMate#Finish() " {{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#RmBuffer(num) " {{{
|
function! delimitMate#RmBuffer(num) " {{{
|
||||||
if len(b:delimitMate_buffer) > 0
|
if len(b:_l_delimitMate_buffer) > 0
|
||||||
call remove(b:delimitMate_buffer, 0, (a:num-1))
|
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
|
||||||
endif
|
endif
|
||||||
return ""
|
return ""
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
@@ -565,107 +612,107 @@ endfunction " }}}
|
|||||||
" Mappers: {{{
|
" Mappers: {{{
|
||||||
function! delimitMate#NoAutoClose() "{{{
|
function! delimitMate#NoAutoClose() "{{{
|
||||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||||
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for delim in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"\|') . '")<CR>'
|
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"\|') . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#AutoClose() "{{{
|
function! delimitMate#AutoClose() "{{{
|
||||||
" Add matching pair and jump to the midle:
|
" Add matching pair and jump to the midle:
|
||||||
" inoremap <buffer> ( ()<Left>
|
" inoremap <silent> <buffer> ( ()<Left>
|
||||||
let i = 0
|
let i = 0
|
||||||
while i < len(b:delimitMate_matchpairs_list)
|
while i < len(b:_l_delimitMate_matchpairs_list)
|
||||||
let ld = b:delimitMate_left_delims[i]
|
let ld = b:_l_delimitMate_left_delims[i]
|
||||||
let rd = b:delimitMate_right_delims[i]
|
let rd = b:_l_delimitMate_right_delims[i]
|
||||||
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#JumpIn("' . rd . '")<CR>'
|
exec 'inoremap <silent> <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . rd . '")<CR>'
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Exit from inside the matching pair:
|
" Exit from inside the matching pair:
|
||||||
for delim in b:delimitMate_right_delims
|
for delim in b:_l_delimitMate_right_delims
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||||
" inoremap <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||||
for delim in b:delimitMate_quotes_list
|
for delim in b:_l_delimitMate_quotes_list
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Try to fix the use of apostrophes (de-activated by default):
|
" Try to fix the use of apostrophes (de-activated by default):
|
||||||
" inoremap <buffer> n't n't
|
" inoremap <silent> <buffer> n't n't
|
||||||
for map in b:delimitMate_apostrophes_list
|
for map in b:_l_delimitMate_apostrophes_list
|
||||||
exec "inoremap <buffer> " . map . " " . map
|
exec "inoremap <silent> <buffer> " . map . " " . map
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#VisualMaps() " {{{
|
function! delimitMate#VisualMaps() " {{{
|
||||||
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
||||||
let vleader = b:delimitMate_visual_leader
|
let vleader = b:_l_delimitMate_visual_leader
|
||||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
||||||
for del in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes_list
|
for del in b:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
|
||||||
exec "vnoremap <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
|
exec "vnoremap <silent> <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#ExtraMappings() "{{{
|
function! delimitMate#ExtraMappings() "{{{
|
||||||
" If pair is empty, delete both delimiters:
|
" If pair is empty, delete both delimiters:
|
||||||
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
inoremap <silent> <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
||||||
|
|
||||||
" If pair is empty, delete closing delimiter:
|
" If pair is empty, delete closing delimiter:
|
||||||
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() && !delimitMate#IsForbidden("") ? "\<Del>" : "\<S-BS>"
|
inoremap <silent> <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
" Expand return if inside an empty pair:
|
||||||
if b:delimitMate_expand_cr != 0
|
if b:_l_delimitMate_expand_cr != 0
|
||||||
inoremap <buffer> <CR> <C-R>=delimitMate#ExpandReturn()<CR>
|
inoremap <silent> <buffer> <CR> <C-R>=delimitMate#ExpandReturn()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Expand space if inside an empty pair:
|
" Expand space if inside an empty pair:
|
||||||
if b:delimitMate_expand_space != 0
|
if b:_l_delimitMate_expand_space != 0
|
||||||
inoremap <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
inoremap <silent> <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Jump out ot any empty pair:
|
" Jump out ot any empty pair:
|
||||||
if b:delimitMate_tab2exit
|
if b:_l_delimitMate_tab2exit
|
||||||
inoremap <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
inoremap <silent> <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Fix the re-do feature:
|
" Fix the re-do feature:
|
||||||
inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
|
inoremap <silent> <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#Finish()<CR><LeftMouse>
|
inoremap <silent> <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
|
||||||
inoremap <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
|
inoremap <silent> <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#Finish()<CR><Left>
|
inoremap <silent> <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
|
||||||
inoremap <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
|
inoremap <silent> <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
|
||||||
inoremap <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
|
inoremap <silent> <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
|
||||||
inoremap <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
|
inoremap <silent> <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
|
||||||
|
|
||||||
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>
|
inoremap <silent> <buffer> <Del> <C-R>=delimitMate#Del()<CR>
|
||||||
|
|
||||||
"the following simply creates an ambiguous mapping so vim fully
|
" The following simply creates an ambiguous mapping so vim fully processes
|
||||||
"processes the escape sequence for terminal keys, see 'ttimeout' for a
|
" the escape sequence for terminal keys, see 'ttimeout' for a rough
|
||||||
"rough explanation, this just forces it to work
|
" explanation, this just forces it to work
|
||||||
if &term[:4] == "xterm"
|
if !has('gui_running')
|
||||||
inoremap <silent> <C-[>OC <RIGHT>
|
imap <silent> <C-[>OC <RIGHT>
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#UnMap() " {{{
|
function! delimitMate#UnMap() " {{{
|
||||||
let imaps =
|
let imaps =
|
||||||
\ b:delimitMate_right_delims +
|
\ b:_l_delimitMate_right_delims +
|
||||||
\ b:delimitMate_left_delims +
|
\ b:_l_delimitMate_left_delims +
|
||||||
\ b:delimitMate_quotes_list +
|
\ b:_l_delimitMate_quotes_list +
|
||||||
\ b:delimitMate_apostrophes_list +
|
\ b:_l_delimitMate_apostrophes_list +
|
||||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>']
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>']
|
||||||
|
|
||||||
let vmaps =
|
let vmaps =
|
||||||
\ b:delimitMate_right_delims +
|
\ b:_l_delimitMate_right_delims +
|
||||||
\ b:delimitMate_left_delims +
|
\ b:_l_delimitMate_left_delims +
|
||||||
\ b:delimitMate_quotes_list
|
\ b:_l_delimitMate_quotes_list
|
||||||
|
|
||||||
for map in imaps
|
for map in imaps
|
||||||
if maparg(map, "i") =~? 'delimitMate'
|
if maparg(map, "i") =~? 'delimitMate'
|
||||||
@@ -673,10 +720,10 @@ function! delimitMate#UnMap() " {{{
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if !exists("b:delimitMate_visual_leader")
|
if !exists("b:_l_delimitMate_visual_leader")
|
||||||
let vleader = ""
|
let vleader = ""
|
||||||
else
|
else
|
||||||
let vleader = b:delimitMate_visual_leader
|
let vleader = b:_l_delimitMate_visual_leader
|
||||||
endif
|
endif
|
||||||
for map in vmaps
|
for map in vmaps
|
||||||
if maparg(vleader . map, "v") =~? "delimitMate"
|
if maparg(vleader . map, "v") =~? "delimitMate"
|
||||||
@@ -684,6 +731,10 @@ function! delimitMate#UnMap() " {{{
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
if !has('gui_running')
|
||||||
|
silent! iunmap <C-[>OC
|
||||||
|
endif
|
||||||
|
|
||||||
let b:delimitMate_enabled = 0
|
let b:delimitMate_enabled = 0
|
||||||
endfunction " }}} delimitMate#UnMap()
|
endfunction " }}} delimitMate#UnMap()
|
||||||
|
|
||||||
@@ -691,55 +742,58 @@ endfunction " }}} delimitMate#UnMap()
|
|||||||
|
|
||||||
" Tools: {{{
|
" Tools: {{{
|
||||||
function! delimitMate#TestMappings() "{{{
|
function! delimitMate#TestMappings() "{{{
|
||||||
exec "normal i*b:delimitMate_autoclose = " . b:delimitMate_autoclose . "\<CR>"
|
exec "normal i*b:_l_delimitMate_autoclose = " . b:_l_delimitMate_autoclose . "\<Esc>o"
|
||||||
exec "normal i*b:delimitMate_expand_space = " . b:delimitMate_expand_space . "\<CR>"
|
exec "normal i*b:_l_delimitMate_expand_space = " . b:_l_delimitMate_expand_space . "\<Esc>o"
|
||||||
exec "normal i*b:delimitMate_expand_cr = " . b:delimitMate_expand_cr . "\<CR>\<CR>"
|
exec "normal i*b:_l_delimitMate_expand_cr = " . b:_l_delimitMate_expand_cr . "\<Esc>o\<Esc>o"
|
||||||
|
echom b:_l_delimitMate_autoclose.b:_l_delimitMate_expand_space.b:_l_delimitMate_expand_cr
|
||||||
if b:delimitMate_autoclose
|
if b:_l_delimitMate_autoclose
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
" {{{
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
|
for i in range(len(b:_l_delimitMate_left_delims))
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
|
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i]. "|"
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
|
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . " \<BS>|"
|
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . " |"
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|"
|
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
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>GGA\<Esc>o\<Esc>o"
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
exec "normal GGAOpen & close: " . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Delete: "
|
exec "normal oDelete: "
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . " |"
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
|
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . "\<CR>|"
|
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
|
||||||
endfor
|
endfor
|
||||||
|
"}}}
|
||||||
else
|
else
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
"{{{
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
for i in range(len(b:_l_delimitMate_left_delims))
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
|
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
|
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
|
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " \<BS>|"
|
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|"
|
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
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>GGA\<Esc>o\<Esc>o"
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
exec "normal GGoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<BS>|"
|
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |"
|
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " \<BS>|"
|
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>|"
|
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif "}}}
|
||||||
exec "normal \<Esc>i"
|
exec "normal \<Esc>i"
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
function! delimitMateTests#Main() " {{{
|
function! delimitMateTests#Main()
|
||||||
if !exists("g:delimitMate_testing")
|
if !exists("g:delimitMate_testing")
|
||||||
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
||||||
return
|
return
|
||||||
|
elseif g:delimitMate_testing == "fork"
|
||||||
|
!gvim -N -u NONE -U NONE -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "so autoload/delimitMate.vim" -c "so autoload/delimitMateTests.vim" -c "so plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
|
||||||
|
return ""
|
||||||
endif
|
endif
|
||||||
nmap <F1> :qall!<CR>
|
nmap <F1> :qall!<CR>
|
||||||
|
let nomore = &more
|
||||||
|
set nomore
|
||||||
let b:test_results = {}
|
let b:test_results = {}
|
||||||
let b:errors = 0
|
let b:errors = 0
|
||||||
let b:corrects = 0
|
let b:corrects = 0
|
||||||
@@ -45,6 +50,7 @@ function! delimitMateTests#Main() " {{{
|
|||||||
normal gg.
|
normal gg.
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
exec "normal \<Esc>"
|
||||||
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
|
||||||
@@ -245,9 +251,10 @@ function! delimitMateTests#Main() " {{{
|
|||||||
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
||||||
normal "_ddgg
|
normal "_ddgg
|
||||||
let @/ = ".\\+Failed:.*!="
|
let @/ = ".\\+Failed:.*!="
|
||||||
|
2,$sort /^.\+':/
|
||||||
|
normal gg
|
||||||
|
exec search('Ignored:','nW').",$sort! /^.\\+':/"
|
||||||
set nohlsearch
|
set nohlsearch
|
||||||
"syntax match failedLine "^.*Failed.*$" contains=ALL
|
|
||||||
"syn match passedLine ".*Passed.*"
|
|
||||||
syn match lineIgnored ".*Ignored.*"
|
syn match lineIgnored ".*Ignored.*"
|
||||||
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
||||||
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
||||||
@@ -267,6 +274,8 @@ function! delimitMateTests#Main() " {{{
|
|||||||
hi def link resultSummary SpecialComment
|
hi def link resultSummary SpecialComment
|
||||||
hi def link resultSummaryNumber Error
|
hi def link resultSummaryNumber Error
|
||||||
" }}}
|
" }}}
|
||||||
endfunction " }}}
|
|
||||||
|
let &more = nomore
|
||||||
|
endfunction
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
" vim:foldmethod=marker:foldcolumn=4
|
||||||
|
|
||||||
|
|||||||
@@ -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.4 *delimitMate.txt*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -90,6 +90,9 @@ Without auto-close: >
|
|||||||
–––––––––-|––––––––––
|
–––––––––-|––––––––––
|
||||||
()<S-Tab> | ()|
|
()<S-Tab> | ()|
|
||||||
<
|
<
|
||||||
|
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||||
|
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||||
|
|
||||||
@@ -125,8 +128,9 @@ If you press backspace inside an empty pair, both delimiters are deleted. When
|
|||||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||||
deleting <CR> expansions will brake the redo command.
|
deleting <CR> expansions will brake the redo command.
|
||||||
|
|
||||||
If you type shift + backspace instead, only the closing delimiter will be
|
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||||
deleted.
|
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||||
|
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
@@ -149,8 +153,9 @@ 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.
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
NOTE that this feature brakes the redo command and doesn't currently work well
|
||||||
blockwise visual mode, any suggestions to fix this will be very welcome.
|
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): >
|
e.g. (selection represented between square brackets): >
|
||||||
|
|
||||||
@@ -162,9 +167,10 @@ e.g. (selection represented between square brackets): >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
||||||
|
|
||||||
Only one quote will be inserted following a quote, a "\" or an alphanumeric
|
Only one quote will be inserted following a quote, a "\" or, following or
|
||||||
character. This should cover closing quotes, escaped quotes and apostrophes.
|
preceding an alphanumeric character. This should cover closing quotes after a
|
||||||
Except for apostrophes, this feature can be disabled setting the option
|
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||||
|
for apostrophes, this feature can be disabled setting the option
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
|'delimitMate_smart_quotes'| to 0.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
@@ -233,6 +239,10 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||||
used.
|
used.
|
||||||
|
|
||||||
|
|'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_visual_leader'| Sets the leader to be used in visual mode.
|
||||||
|
|
||||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||||
@@ -286,7 +296,7 @@ e.g.: >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_matchpairs'*
|
*'delimitMate_matchpairs'*
|
||||||
*'b:delimitMate_matchpairs'*
|
*'b:delimitMate_matchpairs'*
|
||||||
Values: A string with |matchpairs| syntax. ~
|
Values: A string with |'matchpairs'| syntax. ~
|
||||||
Default: &matchpairs ~
|
Default: &matchpairs ~
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered
|
Use this option to tell delimitMate which characters should be considered
|
||||||
@@ -304,9 +314,21 @@ Default: "\" ' `" ~
|
|||||||
Use this option to tell delimitMate which characters should be considered as
|
Use this option to tell delimitMate which characters should be considered as
|
||||||
quotes. Read |delimitMateAutoClose| for details.
|
quotes. Read |delimitMateAutoClose| for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_quotes = "\" ' ` *"
|
let delimitMate_quotes = "\" ' ` *"
|
||||||
au FileType html let b:delimitMate_quotes = "\" '"
|
au FileType html let b:delimitMate_quotes = "\" '"
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_nesting_quotes'*
|
||||||
|
*'b:delimitMate_nesting_quotes'*
|
||||||
|
Values: A list of quotes. ~
|
||||||
|
Default: [] ~
|
||||||
|
|
||||||
|
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||||
|
allowing the autoclosed quotes to be nested.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_quotes = ['"','`']
|
||||||
|
au FileType python let b:delimitMate_quotes = ['"']
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_visual_leader'*
|
*'delimitMate_visual_leader'*
|
||||||
*'b:delimitMate_visual_leader'*
|
*'b:delimitMate_visual_leader'*
|
||||||
@@ -328,20 +350,20 @@ Default: 0 ~
|
|||||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
|
let delimitMate_expand_cr = 1
|
||||||
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
|
au FileType mail let b:delimitMate_expand_cr = 1
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_expand_space'*
|
*'delimitMate_expand_space'*
|
||||||
*'b:delimitMate_expand_space'*
|
*'b:delimitMate_expand_space'*
|
||||||
Values: A key mapping. ~
|
Values: 1 or 0 ~
|
||||||
Default: "\<Space>" ~
|
Default: 0 ~
|
||||||
|
|
||||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
|
let delimitMate_expand_space = 1
|
||||||
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
|
au FileType tcl let b:delimitMate_expand_space = 1
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_excluded_ft'*
|
*'delimitMate_excluded_ft'*
|
||||||
@@ -471,9 +493,15 @@ Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
|||||||
might not work as expected or at all.
|
might not work as expected or at all.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||||
|
e.g.: >
|
||||||
|
|
||||||
|
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||||
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||||
|
\ "external_mapping"
|
||||||
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
||||||
@@ -484,7 +512,8 @@ Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
|||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
||||||
<CR> inside an empty pair: >
|
<CR> inside an empty pair: >
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
inoremap <expr> <CR> pumvisible() ?
|
||||||
|
\"\<c-y>" :
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
@@ -509,14 +538,14 @@ This function returns a mapping that will make the cursor jump to the right
|
|||||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. TODO LIST *delimitMateTodo*
|
6. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
7. MAINTAINER *delimitMateMaintainer*
|
||||||
@@ -541,19 +570,38 @@ 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.4 2010-07-29 * Current release:
|
||||||
- Fix: an extra <Space> is inserted after <Space>
|
- Unbalanced parens: see :help delimitMateBalance.
|
||||||
|
- Visual wrapping now works on block-wise visual
|
||||||
|
with some limitations.
|
||||||
|
- Arrow keys didn't work on terminal.
|
||||||
|
- Added option to allow nested quotes.
|
||||||
|
- Expand Smart Quotes to look for a string on the
|
||||||
|
right of the cursor.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
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 +610,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 +638,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 +696,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,14 +1,15 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: plugin/delimitMate.vim
|
" File: plugin/delimitMate.vim
|
||||||
" Version: 2.3.1
|
" Version: 2.4
|
||||||
" Modified: 2010-06-06
|
" Modified: 2010-07-29
|
||||||
" 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>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
|
|
||||||
" Initialization: {{{
|
" Initialization: {{{
|
||||||
if exists("g:loaded_delimitMate") "{{{
|
|
||||||
" User doesn't want this plugin, let's get out!
|
if exists("g:loaded_delimitMate") || &cp
|
||||||
|
" User doesn't want this plugin or compatible is set, let's get out!
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_delimitMate = 1
|
let g:loaded_delimitMate = 1
|
||||||
@@ -25,25 +26,27 @@ if v:version < 700
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1 " }}}
|
let s:loaded_delimitMate = 1
|
||||||
let delimitMate_version = "2.3.1"
|
let delimitMate_version = "2.4"
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Tools: {{{
|
" Functions: {{{
|
||||||
|
|
||||||
function! s:TestMappingsDo() "{{{
|
function! s:TestMappingsDo() "{{{
|
||||||
if !exists("g:delimitMate_testing")
|
if !exists("g:delimitMate_testing")
|
||||||
silent call delimitMate#TestMappings()
|
silent call delimitMate#TestMappings()
|
||||||
else
|
else
|
||||||
let temp_varsDM = [b:delimitMate_expand_space, b:delimitMate_expand_cr, b:delimitMate_autoclose]
|
let temp_varsDM = [b:_l_delimitMate_expand_space, b:_l_delimitMate_expand_cr, b:_l_delimitMate_autoclose]
|
||||||
for i in [0,1]
|
for i in [0,1]
|
||||||
let b:delimitMate_expand_space = i
|
let b:delimitMate_expand_space = i
|
||||||
let b:delimitMate_expand_cr = i
|
let b:delimitMate_expand_cr = i
|
||||||
for a in [0,1]
|
for a in [0,1]
|
||||||
let b:delimitMate_autoclose = a
|
let b:delimitMate_autoclose = a
|
||||||
call delimitMate#Init()
|
call delimitMate#Init()
|
||||||
|
call delimitMate#UnMap()
|
||||||
|
call delimitMate#Map()
|
||||||
call delimitMate#TestMappings()
|
call delimitMate#TestMappings()
|
||||||
exec "normal i\<CR>"
|
normal o
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
let b:delimitMate_expand_space = temp_varsDM[0]
|
let b:delimitMate_expand_space = temp_varsDM[0]
|
||||||
@@ -55,38 +58,41 @@ function! s:TestMappingsDo() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo(...) "{{{
|
function! s:DelimitMateDo(...) "{{{
|
||||||
if exists("g:delimitMate_excluded_ft")
|
" Initialize settings:
|
||||||
" Check if this file type is excluded:
|
call delimitMate#Init()
|
||||||
for ft in split(g:delimitMate_excluded_ft,',')
|
|
||||||
if ft ==? &filetype
|
" Check if this file type is excluded:
|
||||||
"echomsg "excluded"
|
if exists("g:delimitMate_excluded_ft") &&
|
||||||
call delimitMate#UnMap()
|
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||||
return 1
|
|
||||||
endif
|
" Remove any magic:
|
||||||
endfor
|
call delimitMate#UnMap()
|
||||||
|
|
||||||
|
" Finish here:
|
||||||
|
return 1
|
||||||
endif
|
endif
|
||||||
try
|
|
||||||
"echomsg "included"
|
" First, remove all magic, if needed:
|
||||||
let save_cpo = &cpo
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
||||||
let save_keymap = &keymap
|
call delimitMate#UnMap()
|
||||||
set keymap=
|
endif
|
||||||
set cpo&vim
|
|
||||||
call delimitMate#Init()
|
" Now, add magic:
|
||||||
finally
|
call delimitMate#Map()
|
||||||
let &cpo = save_cpo
|
|
||||||
let &keymap = save_keymap
|
|
||||||
endtry
|
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
echo "delimitMate has been reset."
|
echo "delimitMate has been reset."
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateSwitch() "{{{
|
function! s:DelimitMateSwitch() "{{{
|
||||||
if b:delimitMate_enabled
|
call delimitMate#Init()
|
||||||
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
||||||
call delimitMate#UnMap()
|
call delimitMate#UnMap()
|
||||||
echo "delimitMate has been disabled."
|
echo "delimitMate has been disabled."
|
||||||
else
|
else
|
||||||
call delimitMate#Init()
|
call delimitMate#UnMap()
|
||||||
|
call delimitMate#Map()
|
||||||
echo "delimitMate has been enabled."
|
echo "delimitMate has been enabled."
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@@ -94,6 +100,7 @@ endfunction "}}}
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Commands: {{{
|
" Commands: {{{
|
||||||
|
|
||||||
call s:DelimitMateDo()
|
call s:DelimitMateDo()
|
||||||
|
|
||||||
" Let me refresh without re-loading the buffer:
|
" Let me refresh without re-loading the buffer:
|
||||||
@@ -104,19 +111,30 @@ command! DelimitMateTest call s:TestMappingsDo()
|
|||||||
|
|
||||||
" Switch On/Off:
|
" Switch On/Off:
|
||||||
command! DelimitMateSwitch call s:DelimitMateSwitch()
|
command! DelimitMateSwitch call s:DelimitMateSwitch()
|
||||||
|
"}}}
|
||||||
|
|
||||||
" Run on file type events.
|
" Autocommands: {{{
|
||||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
|
||||||
autocmd FileType * call <SID>DelimitMateDo()
|
|
||||||
|
|
||||||
" Run on new buffers.
|
augroup delimitMate
|
||||||
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
|
au!
|
||||||
|
" Run on file type change.
|
||||||
|
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
||||||
|
autocmd FileType * call <SID>DelimitMateDo()
|
||||||
|
|
||||||
" Flush the char buffer:
|
" Run on new buffers.
|
||||||
autocmd InsertEnter * call delimitMate#FlushBuffer()
|
autocmd BufNewFile,BufRead,BufEnter *
|
||||||
autocmd BufEnter * if mode() == 'i' | call delimitMate#FlushBuffer() | endif
|
\ if !exists("b:loaded_delimitMate") |
|
||||||
|
\ call <SID>DelimitMateDo() |
|
||||||
|
\ endif
|
||||||
|
|
||||||
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
|
" Flush the char buffer:
|
||||||
|
autocmd InsertEnter * call delimitMate#FlushBuffer()
|
||||||
|
autocmd BufEnter *
|
||||||
|
\ if mode() == 'i' |
|
||||||
|
\ call delimitMate#FlushBuffer() |
|
||||||
|
\ endif
|
||||||
|
|
||||||
|
augroup END
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user