mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Compare commits
345 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
becbd2d353 | ||
|
|
382c36bf57 | ||
|
|
537a1da0fa | ||
|
|
055978491a | ||
|
|
16687aec24 | ||
|
|
728b57a656 | ||
|
|
98143957cf | ||
|
|
b5719054be | ||
|
|
39d8f522f7 | ||
|
|
8bc47fd1c4 | ||
|
|
bc97837c71 | ||
|
|
d24ad6b301 | ||
|
|
81de76fe52 | ||
|
|
5945fdfd14 | ||
|
|
9a77c3aee6 | ||
|
|
342a04b427 | ||
|
|
03e94587ae | ||
|
|
c78a6e6d93 | ||
|
|
470c053a3b | ||
|
|
254a89d67c | ||
|
|
e7b4dedb84 | ||
|
|
21a3ade90c | ||
|
|
8e30e70bcd | ||
|
|
ac792c01b6 | ||
|
|
c23ef684e3 | ||
|
|
b63924f2b2 | ||
|
|
07b7cc969f | ||
|
|
13e52d42ae | ||
|
|
aa9d737763 | ||
|
|
bf2b68edab | ||
|
|
fe9022433d | ||
|
|
6f7e6413ce | ||
|
|
a9a37854da | ||
|
|
0739792d01 | ||
|
|
6f4f1b06d3 | ||
|
|
0049b07a1c | ||
|
|
fe1983cfa1 | ||
|
|
a4ac44a84f | ||
|
|
4c13ed6aee | ||
|
|
eafd832c04 | ||
|
|
e13872fdb2 | ||
|
|
9a9b9edb9a | ||
|
|
0f353bd2b3 | ||
|
|
c1b832bbf8 | ||
|
|
073957f0a1 | ||
|
|
c678061b79 | ||
|
|
12c7d85ff6 | ||
|
|
66834e7209 | ||
|
|
21072cf13e | ||
|
|
d952f6c721 | ||
|
|
0efe44bc70 | ||
|
|
631d72465a | ||
|
|
4024181af2 | ||
|
|
38487bbec8 | ||
|
|
c74a48ccd8 | ||
|
|
df1f32f772 | ||
|
|
f2b9b3a0c2 | ||
|
|
1c45f7bbde | ||
|
|
a1f21e8ef5 | ||
|
|
eba94168ce | ||
|
|
06c1f31632 | ||
|
|
9826c667e0 | ||
|
|
35280c1444 | ||
|
|
82160a5de6 | ||
|
|
07d9fa9ddc | ||
|
|
54853a954c | ||
|
|
f00f6b6cf2 | ||
|
|
d280d23a83 | ||
|
|
821e0019fb | ||
|
|
5ef40e0234 | ||
|
|
399e18d669 | ||
|
|
92fba35d27 | ||
|
|
0528bdac15 | ||
|
|
5db098e953 | ||
|
|
b45536fe8d | ||
|
|
3dde5cc8cb | ||
|
|
5787ec4f59 | ||
|
|
2dc880bf1c | ||
|
|
440f38858f | ||
|
|
f7f895c211 | ||
|
|
654dc14e6e | ||
|
|
543be33b13 | ||
|
|
7345bfddef | ||
|
|
16a35eefab | ||
|
|
74ab16ea5b | ||
|
|
2adbf5a8d7 | ||
|
|
e4a02eb998 | ||
|
|
ad11ab2210 | ||
|
|
6b0d448f6a | ||
|
|
32c9db8f37 | ||
|
|
a77423a46f | ||
|
|
57fd02b2e0 | ||
|
|
14faba1c62 | ||
|
|
8ab087c95c | ||
|
|
61d62e8920 | ||
|
|
7ce61655a7 | ||
|
|
8d133d4726 | ||
|
|
7caa6092b7 | ||
|
|
d98d8c0a0d | ||
|
|
e2d63e38f6 | ||
|
|
579e3520a4 | ||
|
|
90d07a68be | ||
|
|
2cb3f4d5e6 | ||
|
|
3a23e89cb5 | ||
|
|
70e1ac1462 | ||
|
|
d4ba528935 | ||
|
|
8a8aad183f | ||
|
|
cfc6654855 | ||
|
|
f2efe4331b | ||
|
|
dfa7e9b730 | ||
|
|
765bdd80dc | ||
|
|
739d2f9bd4 | ||
|
|
eb7738e4aa | ||
|
|
32f5d8df07 | ||
|
|
7b5887c324 | ||
|
|
0326b7c14a | ||
|
|
1dfe26a538 | ||
|
|
9c1564a22f | ||
|
|
028964cf7d | ||
|
|
5a84c1a746 | ||
|
|
0f9563969d | ||
|
|
d3ffebab74 | ||
|
|
ece6c39a65 | ||
|
|
ad151d3e55 | ||
|
|
b65d719353 | ||
|
|
a42dff4ad8 | ||
|
|
4a7d5a6e54 | ||
|
|
50a0df0be4 | ||
|
|
cecebf6e86 | ||
|
|
ad4430706e | ||
|
|
93d4a373fb | ||
|
|
a9f51531d9 | ||
|
|
6bb98110b4 | ||
|
|
0b34aea202 | ||
|
|
f1e92d05d5 | ||
|
|
8ec2bcb89a | ||
|
|
beb87ef41f | ||
|
|
26a6def62f | ||
|
|
0fb597ef36 | ||
|
|
fe5dd9a61a | ||
|
|
bb9b0edcc5 | ||
|
|
f3176a664c | ||
|
|
1cbbe90a09 | ||
|
|
a9174f65ba | ||
|
|
2af2dd2350 | ||
|
|
9c77b8434a | ||
|
|
646794cbda | ||
|
|
93fdcf92e1 | ||
|
|
fbbd9514c5 | ||
|
|
be5c41b3c1 | ||
|
|
b853ee9f35 | ||
|
|
eb2625c4a7 | ||
|
|
e17f6cd23c | ||
|
|
54acd56b48 | ||
|
|
9bdd4b078a | ||
|
|
f5748da36c | ||
|
|
eade67b409 | ||
|
|
b3f62f79c2 | ||
|
|
9d133d5b69 | ||
|
|
9f003b5bf5 | ||
|
|
e688e20151 | ||
|
|
8749708115 | ||
|
|
5cc5d8d9b3 | ||
|
|
98b4119746 | ||
|
|
c889905e47 | ||
|
|
db54dadb46 | ||
|
|
604260f56e | ||
|
|
581a3ebc17 | ||
|
|
cc1acaba96 | ||
|
|
7b781ab6b6 | ||
|
|
233eb52a97 | ||
|
|
aff9743269 | ||
|
|
ce1d05fac5 | ||
|
|
6dad313734 | ||
|
|
5263e25548 | ||
|
|
39b8298390 | ||
|
|
57b80ea78a | ||
|
|
a5b7141fc4 | ||
|
|
9efb01da68 | ||
|
|
860c45ab2a | ||
|
|
8686edfc63 | ||
|
|
5e7a7c4738 | ||
|
|
928cc1146a | ||
|
|
d420afdacd | ||
|
|
f6015300a0 | ||
|
|
e183064744 | ||
|
|
40849c94ef | ||
|
|
4c1424f9bd | ||
|
|
0783f97fc0 | ||
|
|
e551885c24 | ||
|
|
4891a04258 | ||
|
|
ad77a9a75e | ||
|
|
5bf35a6b31 | ||
|
|
49044099dd | ||
|
|
7c423067a8 | ||
|
|
d08fa765b9 | ||
|
|
f47bcd8e3f | ||
|
|
873e79ec37 | ||
|
|
589b2ae85a | ||
|
|
f9f2b5f177 | ||
|
|
4157dc8a88 | ||
|
|
d0fc1456b7 | ||
|
|
86f70a7d9c | ||
|
|
f7b53f045d | ||
|
|
f3d140e363 | ||
|
|
93a1770f37 | ||
|
|
859a732509 | ||
|
|
eb778be64b | ||
|
|
2b2ae65182 | ||
|
|
e1b52d3676 | ||
|
|
ff4745b191 | ||
|
|
2ba694830d | ||
|
|
12c5c96ca2 | ||
|
|
a97af1fb97 | ||
|
|
5bf6a1e30c | ||
|
|
f8883cb700 | ||
|
|
f72ffe3c12 | ||
|
|
d2e896fbe1 | ||
|
|
a0b1799270 | ||
|
|
1d423ab2b9 | ||
|
|
7f5df4bf6e | ||
|
|
9f1fdc418d | ||
|
|
64cf4beb8a | ||
|
|
119174b7dd | ||
|
|
b3a7728299 | ||
|
|
2266a19900 | ||
|
|
1b587bee9a | ||
|
|
31b289adfe | ||
|
|
efadb34c84 | ||
|
|
58d63b4e5b | ||
|
|
0441a03bb9 | ||
|
|
90cb449ada | ||
|
|
a678d7baab | ||
|
|
2911bf33c9 | ||
|
|
221daf6e6a | ||
|
|
8f5a45f9e7 | ||
|
|
6f5fd80e0e | ||
|
|
1caeda0799 | ||
|
|
3fb33b8e47 | ||
|
|
e6288a7313 | ||
|
|
7dd7edff64 | ||
|
|
4b94c38f95 | ||
|
|
217adb3d8e | ||
|
|
e63e373ae1 | ||
|
|
9c11c5cc82 | ||
|
|
8b24f0fd9f | ||
|
|
701e14f72f | ||
|
|
c9c1464075 | ||
|
|
e831d89acf | ||
|
|
133c125f93 | ||
|
|
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 | ||
|
|
edeaff4730 | ||
|
|
c85fee6eb5 | ||
|
|
0ccb143a12 | ||
|
|
941beed3b3 | ||
|
|
739a3e606c | ||
|
|
61cc934b68 | ||
|
|
7aec4532f9 | ||
|
|
6f22aab0b8 | ||
|
|
592cf2fea1 | ||
|
|
3d818560eb | ||
|
|
da66a3f7c9 | ||
|
|
e5ce5b0967 | ||
|
|
03342b8d22 | ||
|
|
86c1895ceb | ||
|
|
fd4fb482fe | ||
|
|
0fbbc0f808 | ||
|
|
ced80ebb21 | ||
|
|
7b0d9367b2 | ||
|
|
37512d7f89 | ||
|
|
f8b5bbe555 | ||
|
|
698b3f1e43 | ||
|
|
bdf477de4b | ||
|
|
b03d5dce36 | ||
|
|
03390cfb5f | ||
|
|
45c66a4d07 | ||
|
|
a317b6ead7 | ||
|
|
ed672dd39b | ||
|
|
72e639ff1a | ||
|
|
95c899f3e2 | ||
|
|
6d4113e3c3 | ||
|
|
8d720b8932 | ||
|
|
422420c494 | ||
|
|
2c8b586679 | ||
|
|
e748b461b6 | ||
|
|
17a061a1fa | ||
|
|
29d42e0771 | ||
|
|
e818c05e33 | ||
|
|
29cb16c42e | ||
|
|
d478e75178 | ||
|
|
eb03c7058e | ||
|
|
1e7a5c7f6e | ||
|
|
b9bd9e3229 | ||
|
|
b25906e610 | ||
|
|
5ca0eee4cd | ||
|
|
a751498fbc | ||
|
|
9292c9294a | ||
|
|
4083c581d6 | ||
|
|
86ff123318 | ||
|
|
a8cbf2e429 | ||
|
|
96d53eaa31 | ||
|
|
b5292f7c58 | ||
|
|
6b80cfefb6 | ||
|
|
7540b37e8f |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,5 +1,12 @@
|
||||
*.sw?
|
||||
*.un?
|
||||
*.vba
|
||||
*.vmb
|
||||
*.zip
|
||||
*.gz
|
||||
vimball.txt
|
||||
*.orig
|
||||
tags
|
||||
test/build
|
||||
test/*.tap
|
||||
test/*.msgout
|
||||
|
||||
90
Makefile
90
Makefile
@@ -1,21 +1,81 @@
|
||||
PLUGIN=delimitMate
|
||||
PLUGIN = $(wildcard plugin/*.vim)
|
||||
SOURCES = $(PLUGIN)
|
||||
LIB = $(wildcard autoload/*.vim)
|
||||
SOURCES += $(LIB)
|
||||
DOC = $(wildcard doc/*.txt)
|
||||
SOURCES += $(DOC)
|
||||
NAME = delimitMate
|
||||
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
|
||||
FILENAME = $(NAME)-$(VERSION)
|
||||
DESTDIR = $(HOME)/.vim
|
||||
VIM = vim
|
||||
SED = $(shell command -v gsed || command -v sed)
|
||||
PERL = perl
|
||||
comma := ,
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
install:
|
||||
cp -f doc/* ~/.vim/doc/${PLUGIN}.txt
|
||||
cp -f plugin/* ~/.vim/plugin/${PLUGIN}.vim
|
||||
.PHONY: version clean distclean undo release test install uninstall
|
||||
|
||||
doc_update: install
|
||||
/usr/bin/vim -u NONE -c ':helptags ~/.vim/doc' -c ':q'
|
||||
all: zip gzip
|
||||
dist: version all
|
||||
vimball: $(FILENAME).vmb
|
||||
zip: $(FILENAME).zip $(FILENAME).vmb.zip
|
||||
gzip: $(FILENAME).tar.gz $(FILENAME).vmb.gz
|
||||
|
||||
zip:
|
||||
zip -r ${PLUGIN}.zip doc plugin
|
||||
zip ${PLUGIN}.zip -d \*.sw\?
|
||||
clean:
|
||||
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
|
||||
|
||||
vimball: install
|
||||
echo doc/${PLUGIN}.txt > vimball.txt
|
||||
echo plugin/${PLUGIN}.vim >> vimball.txt
|
||||
/usr/bin/vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q'
|
||||
distclean: clean
|
||||
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile|basic_vimrc)(.)'
|
||||
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile|basic_vimrc)*'
|
||||
|
||||
gzip: vimball
|
||||
gzip -f ${PLUGIN}.vba
|
||||
undo:
|
||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||
|
||||
version:
|
||||
$(PERL) -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(PLUGIN) $(LIB)
|
||||
$(PERL) -i.orig -pne \
|
||||
'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(PLUGIN)
|
||||
$(PERL) -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
|
||||
$(PERL) -i.orig -MPOSIX -pne \
|
||||
'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' \
|
||||
$(PLUGIN) $(LIB)
|
||||
$(PERL) -i.orig -MPOSIX -pne \
|
||||
'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' \
|
||||
$(DOC)
|
||||
|
||||
test:
|
||||
$(MAKE) -C test
|
||||
|
||||
install: $(SOURCES)
|
||||
for dir in $(^D);\
|
||||
do install -d -m 0755 $(DESTDIR)$(PREFIX)/$$dir;\
|
||||
done;\
|
||||
for file in $^;\
|
||||
do install -m 0644 $$file $(DESTDIR)$(PREFIX)/$$file;\
|
||||
done;
|
||||
|
||||
uninstall:
|
||||
for file in $(SOURCES);\
|
||||
do rm -f $(DESTDIR)$(PREFIX)/$$file;\
|
||||
done;
|
||||
|
||||
%.vmb: $(SOURCES)
|
||||
$(VIM) -N -es -u NORC \
|
||||
-c 'call setline(1,["$(subst $(space),"$(comma)",$^)"])'\
|
||||
-c "%MkVimball! $(basename $@) ." -c 'q!'
|
||||
|
||||
%.vmb.zip: vimball
|
||||
zip $@ $(basename $@)
|
||||
|
||||
%.zip: $(SOURCES)
|
||||
zip $@ $^
|
||||
|
||||
%.vmb.gz: vimball
|
||||
gzip -f < $(basename $@) > $@
|
||||
|
||||
%.tar.gz: $(SOURCES)
|
||||
tar -cvzf $@ $^
|
||||
|
||||
# vim:ts=2:sw=2
|
||||
|
||||
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that
|
||||
should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter
|
||||
in comments and other configurable regions), <CR> and <Space> expansions (off by default), and some more.
|
||||
|
||||
Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using
|
||||
:autocmd.
|
||||
656
autoload/delimitMate.vim
Normal file
656
autoload/delimitMate.vim
Normal file
@@ -0,0 +1,656 @@
|
||||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.7
|
||||
" Modified: 2013-07-15
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
" ============================================================================
|
||||
|
||||
"let delimitMate_loaded = 1
|
||||
|
||||
if !exists('s:options')
|
||||
let s:options = {}
|
||||
endif
|
||||
|
||||
function! s:set(name, value) "{{{
|
||||
let bufnr = bufnr('%')
|
||||
if !has_key(s:options, bufnr)
|
||||
let s:options[bufnr] = {}
|
||||
endif
|
||||
let s:options[bufnr][a:name] = a:value
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get(...) "{{{
|
||||
let options = deepcopy(eval('s:options.' . bufnr('%')))
|
||||
if a:0
|
||||
return options[a:1]
|
||||
endif
|
||||
return options
|
||||
endfunction "}}}
|
||||
|
||||
function! s:exists(name, ...) "{{{
|
||||
let scope = a:0 ? a:1 : 's'
|
||||
if scope == 's'
|
||||
let bufnr = bufnr('%')
|
||||
let name = 'options.' . bufnr . '.' . a:name
|
||||
else
|
||||
let name = 'delimitMate_' . a:name
|
||||
endif
|
||||
return exists(scope . ':' . name)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_jump(...) "{{{
|
||||
" Returns 1 if the next character is a closing delimiter.
|
||||
let char = s:get_char(0)
|
||||
let list = s:get('right_delims') + s:get('quotes_list')
|
||||
|
||||
" Closing delimiter on the right.
|
||||
if (!a:0 && index(list, char) > -1)
|
||||
\ || (a:0 && char == a:1)
|
||||
return 1
|
||||
endif
|
||||
|
||||
" Closing delimiter with space expansion.
|
||||
let nchar = s:get_char(1)
|
||||
if !a:0 && s:get('expand_space') && char == " "
|
||||
if index(list, nchar) > -1
|
||||
return 2
|
||||
endif
|
||||
elseif a:0 && s:get('expand_space') && nchar == a:1 && char == ' '
|
||||
return 3
|
||||
endif
|
||||
|
||||
if !s:get('jump_expansion')
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Closing delimiter with CR expansion.
|
||||
let uchar = matchstr(getline(line('.') + 1), '^\s*\zs\S')
|
||||
if !a:0 && s:get('expand_cr') && char == ""
|
||||
if index(list, uchar) > -1
|
||||
return 4
|
||||
endif
|
||||
elseif a:0 && s:get('expand_cr') && uchar == a:1
|
||||
return 5
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:rquote(char) "{{{
|
||||
let pos = matchstr(getline('.')[col('.') : ], escape(a:char, '[]*.^$\'), 1)
|
||||
let i = 0
|
||||
while s:get_char(i) ==# a:char
|
||||
let i += 1
|
||||
endwhile
|
||||
return i
|
||||
endfunction "}}}
|
||||
|
||||
function! s:lquote(char) "{{{
|
||||
let i = 0
|
||||
while s:get_char(i - 1) ==# a:char
|
||||
let i -= 1
|
||||
endwhile
|
||||
return i * -1
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_char(...) "{{{
|
||||
let idx = col('.') - 1
|
||||
if !a:0 || (a:0 && a:1 >= 0)
|
||||
" Get char from cursor.
|
||||
let line = getline('.')[idx :]
|
||||
let pos = a:0 ? a:1 : 0
|
||||
return matchstr(line, '^'.repeat('.', pos).'\zs.')
|
||||
endif
|
||||
" Get char behind cursor.
|
||||
let line = getline('.')[: idx - 1]
|
||||
let pos = 0 - (1 + a:1)
|
||||
return matchstr(line, '.\ze'.repeat('.', pos).'$')
|
||||
endfunction "s:get_char }}}
|
||||
|
||||
function! s:is_cr_expansion(...) " {{{
|
||||
let nchar = getline(line('.')-1)[-1:]
|
||||
let schar = matchstr(getline(line('.')+1), '^\s*\zs\S')
|
||||
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.'))
|
||||
if index(s:get('left_delims'), nchar) > -1
|
||||
\ && index(s:get('left_delims'), nchar)
|
||||
\ == index(s:get('right_delims'), schar)
|
||||
\ && isEmpty
|
||||
return 1
|
||||
elseif index(s:get('quotes_list'), nchar) > -1
|
||||
\ && index(s:get('quotes_list'), nchar)
|
||||
\ == index(s:get('quotes_list'), schar)
|
||||
\ && isEmpty
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}} s:is_cr_expansion()
|
||||
|
||||
function! s:is_space_expansion() " {{{
|
||||
if col('.') > 2
|
||||
let pchar = s:get_char(-2)
|
||||
let nchar = s:get_char(1)
|
||||
let isSpaces =
|
||||
\ (s:get_char(-1)
|
||||
\ == s:get_char(0)
|
||||
\ && s:get_char(-1) == " ")
|
||||
|
||||
if index(s:get('left_delims'), pchar) > -1 &&
|
||||
\ index(s:get('left_delims'), pchar)
|
||||
\ == index(s:get('right_delims'), nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
elseif index(s:get('quotes_list'), pchar) > -1 &&
|
||||
\ index(s:get('quotes_list'), pchar)
|
||||
\ == index(s:get('quotes_list'), nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}} IsSpaceExpansion()
|
||||
|
||||
function! s:is_empty_matchpair() "{{{
|
||||
" get char before the cursor.
|
||||
let open = s:get_char(-1)
|
||||
let idx = index(s:get('left_delims'), open)
|
||||
if idx == -1
|
||||
return 0
|
||||
endif
|
||||
let close = get(s:get('right_delims'), idx, '')
|
||||
return close ==# s:get_char(0)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_empty_quotes() "{{{
|
||||
" get char before the cursor.
|
||||
let quote = s:get_char(-1)
|
||||
let idx = index(s:get('quotes_list'), quote)
|
||||
if idx == -1
|
||||
return 0
|
||||
endif
|
||||
return quote ==# s:get_char(0)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:cursor_idx() "{{{
|
||||
let idx = len(split(getline('.')[: col('.') - 1], '\zs')) - 1
|
||||
return idx
|
||||
endfunction "delimitMate#CursorCol }}}
|
||||
|
||||
function! s:get_syn_name() "{{{
|
||||
let col = col('.')
|
||||
if col == col('$')
|
||||
let col = col - 1
|
||||
endif
|
||||
return synIDattr(synIDtrans(synID(line('.'), col, 1)), 'name')
|
||||
endfunction " }}}
|
||||
|
||||
function! s:is_excluded_ft(ft) "{{{
|
||||
if !exists("g:delimitMate_excluded_ft")
|
||||
return 0
|
||||
endif
|
||||
return index(split(g:delimitMate_excluded_ft, ','), a:ft, 0, 1) >= 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_forbidden(char) "{{{
|
||||
if s:is_excluded_ft(&filetype)
|
||||
return 1
|
||||
endif
|
||||
if !s:get('excluded_regions_enabled')
|
||||
return 0
|
||||
endif
|
||||
let region = s:get_syn_name()
|
||||
return index(s:get('excluded_regions_list'), region) >= 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:balance_matchpairs(char) "{{{
|
||||
" Returns:
|
||||
" = 0 => Parens balanced.
|
||||
" > 0 => More opening parens.
|
||||
" < 0 => More closing parens.
|
||||
|
||||
let line = getline('.')
|
||||
let col = s:cursor_idx() - 1
|
||||
let col = col >= 0 ? col : 0
|
||||
let list = split(line, '\zs')
|
||||
let left = s:get('left_delims')[index(s:get('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)
|
||||
|
||||
" Return the found balance:
|
||||
return opening - closing
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_smart_quote(char) "{{{
|
||||
" TODO: Allow using a:char in the pattern.
|
||||
let tmp = s:get('smart_quotes')
|
||||
if empty(tmp)
|
||||
return 0
|
||||
endif
|
||||
let regex = matchstr(tmp, '^!\?\zs.*')
|
||||
" Flip matched value if regex starts with !
|
||||
let mod = tmp =~ '^!' ? [1, 0] : [0, 1]
|
||||
let matched = search(regex, 'ncb', line('.')) > 0
|
||||
let noescaped = substitute(getline('.'), '\\.', '', 'g')
|
||||
let odd = (count(split(noescaped, '\zs'), a:char) % 2)
|
||||
let result = mod[matched] || odd
|
||||
return result
|
||||
endfunction "delimitMate#SmartQuote }}}
|
||||
|
||||
function! delimitMate#Set(...) "{{{
|
||||
return call('s:set', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#Get(...) "{{{
|
||||
return call('s:get', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ShouldJump(...) "{{{
|
||||
return call('s:is_jump', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#IsEmptyPair(str) "{{{
|
||||
if strlen(substitute(a:str, ".", "x", "g")) != 2
|
||||
return 0
|
||||
endif
|
||||
let idx = index(s:get('left_delims'), matchstr(a:str, '^.'))
|
||||
if idx > -1 &&
|
||||
\ s:get('right_delims')[idx] == matchstr(a:str, '.$')
|
||||
return 1
|
||||
endif
|
||||
let idx = index(s:get('quotes_list'), matchstr(a:str, '^.'))
|
||||
if idx > -1 &&
|
||||
\ s:get('quotes_list')[idx] == matchstr(a:str, '.$')
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#WithinEmptyPair() "{{{
|
||||
" if cursor is at column 1 return 0
|
||||
if col('.') == 1
|
||||
return 0
|
||||
endif
|
||||
" get char before the cursor.
|
||||
let char1 = s:get_char(-1)
|
||||
" get char under the cursor.
|
||||
let char2 = s:get_char(0)
|
||||
return delimitMate#IsEmptyPair( char1.char2 )
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#SkipDelim(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
let line = getline('.')
|
||||
if col > 0
|
||||
let cur = s:get_char(0)
|
||||
let pre = s:get_char(-1)
|
||||
else
|
||||
let cur = s:get_char(0)
|
||||
let pre = ""
|
||||
endif
|
||||
if pre == "\\"
|
||||
" Escaped character
|
||||
return a:char
|
||||
elseif cur == a:char
|
||||
" Exit pair
|
||||
return a:char . "\<Del>"
|
||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
||||
" Add closing delimiter and jump back to the middle.
|
||||
return a:char . s:joinUndo() . "\<Left>"
|
||||
else
|
||||
" Nothing special here, return the same character.
|
||||
return a:char
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ParenDelim(right) " {{{
|
||||
let left = s:get('left_delims')[index(s:get('right_delims'),a:right)]
|
||||
if s:is_forbidden(a:right)
|
||||
return left
|
||||
endif
|
||||
" Try to balance matchpairs
|
||||
if s:get('balance_matchpairs') &&
|
||||
\ s:balance_matchpairs(a:right) < 0
|
||||
return left
|
||||
endif
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if s:get('smart_matchpairs') != ''
|
||||
let smart_matchpairs = substitute(s:get('smart_matchpairs'), '\\!', left, 'g')
|
||||
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g')
|
||||
if line[col+1:] =~ smart_matchpairs
|
||||
return left
|
||||
endif
|
||||
endif
|
||||
if len(line) == (col + 1) && s:get('insert_eol_marker') == 1
|
||||
let tail = s:get('eol_marker')
|
||||
else
|
||||
let tail = ''
|
||||
endif
|
||||
return left . a:right . tail . repeat(s:joinUndo() . "\<Left>", len(split(tail, '\zs')) + 1)
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#QuoteDelim(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let char_at = s:get_char(0)
|
||||
let char_before = s:get_char(-1)
|
||||
let nesting_on = index(s:get('nesting_quotes'), a:char) > -1
|
||||
let left_q = nesting_on ? s:lquote(a:char) : 0
|
||||
if nesting_on && left_q > 1
|
||||
" Nesting quotes.
|
||||
let right_q = s:rquote(a:char)
|
||||
let quotes = right_q > left_q + 1 ? 0 : left_q - right_q + 2
|
||||
let lefts = quotes - 1
|
||||
return repeat(a:char, quotes) . repeat(s:joinUndo() . "\<Left>", lefts)
|
||||
elseif char_at == a:char
|
||||
" Inside an empty pair, jump out
|
||||
return a:char . "\<Del>"
|
||||
elseif a:char == '"' && index(split(&ft, '\.'), "vim") != -1 && getline('.') =~ '^\s*$'
|
||||
" If we are in a vim file and it looks like we're starting a comment, do
|
||||
" not add a closing char.
|
||||
return a:char
|
||||
elseif s:is_smart_quote(a:char)
|
||||
" Seems like a smart quote, insert a single char.
|
||||
return a:char
|
||||
elseif (char_before == a:char && char_at != a:char)
|
||||
\ && !empty(s:get('smart_quotes'))
|
||||
" Seems like we have an unbalanced quote, insert one quotation
|
||||
" mark and jump to the middle.
|
||||
return a:char . s:joinUndo() . "\<Left>"
|
||||
else
|
||||
" Insert a pair and jump to the middle.
|
||||
let sufix = ''
|
||||
if !empty(s:get('eol_marker')) && col('.') - 1 == len(getline('.'))
|
||||
let idx = len(s:get('eol_marker')) * -1
|
||||
let marker = getline('.')[idx : ]
|
||||
let has_marker = marker == s:get('eol_marker')
|
||||
let sufix = !has_marker ? s:get('eol_marker') : ''
|
||||
endif
|
||||
return a:char . a:char . s:joinUndo() . "\<Left>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#JumpOut(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let jump = s:is_jump(a:char)
|
||||
if jump == 1
|
||||
" HACK: Instead of <Right>, we remove the char to be jumped over and
|
||||
" insert it again. This will trigger re-indenting via 'indentkeys'.
|
||||
" Ref: https://github.com/Raimondi/delimitMate/issues/168
|
||||
return "\<Del>".a:char
|
||||
elseif jump == 3
|
||||
return s:joinUndo() . "\<Right>" . s:joinUndo() . "\<Right>"
|
||||
elseif jump == 5
|
||||
return "\<Down>\<C-O>I" . s:joinUndo() . "\<Right>"
|
||||
else
|
||||
return a:char
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#JumpAny(...) " {{{
|
||||
if s:is_forbidden('')
|
||||
return ''
|
||||
endif
|
||||
if !s:is_jump()
|
||||
return ''
|
||||
endif
|
||||
" Let's get the character on the right.
|
||||
let char = s:get_char(0)
|
||||
if char == " "
|
||||
" Space expansion.
|
||||
return s:joinUndo() . "\<Right>" . s:joinUndo() . "\<Right>"
|
||||
elseif char == ""
|
||||
" CR expansion.
|
||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>\<Del>"
|
||||
else
|
||||
return s:joinUndo() . "\<Right>"
|
||||
endif
|
||||
endfunction " delimitMate#JumpAny() }}}
|
||||
|
||||
function! delimitMate#JumpMany() " {{{
|
||||
let line = split(getline('.')[col('.') - 1 : ], '\zs')
|
||||
let rights = ""
|
||||
let found = 0
|
||||
for char in line
|
||||
if index(s:get('quotes_list'), char) >= 0 ||
|
||||
\ index(s:get('right_delims'), char) >= 0
|
||||
let rights .= s:joinUndo() . "\<Right>"
|
||||
let found = 1
|
||||
elseif found == 0
|
||||
let rights .= s:joinUndo() . "\<Right>"
|
||||
else
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if found == 1
|
||||
return rights
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction " delimitMate#JumpMany() }}}
|
||||
|
||||
function! delimitMate#ExpandReturn() "{{{
|
||||
if s:is_forbidden("")
|
||||
return "\<CR>"
|
||||
endif
|
||||
let escaped = s:cursor_idx() >= 2
|
||||
\ && s:get_char(-2) == '\'
|
||||
let expand_right_matchpair = s:get('expand_cr') == 2
|
||||
\ && index(s:get('right_delims'), s:get_char(0)) > -1
|
||||
let expand_inside_quotes = s:get('expand_inside_quotes')
|
||||
\ && s:is_empty_quotes()
|
||||
\ && !escaped
|
||||
let is_empty_matchpair = s:is_empty_matchpair()
|
||||
if !pumvisible( )
|
||||
\ && ( is_empty_matchpair
|
||||
\ || expand_right_matchpair
|
||||
\ || expand_inside_quotes)
|
||||
let val = "\<Esc>a"
|
||||
if is_empty_matchpair && s:get('insert_eol_marker') == 2
|
||||
\ && !search(escape(s:get('eol_marker'), '[]\.*^$').'$', 'cnW', '.')
|
||||
let tail = getline('.')[col('.') - 1 : ]
|
||||
let times = len(split(tail, '\zs'))
|
||||
let val .= repeat(s:joinUndo() . "\<Right>", times) . s:get('eol_marker') . repeat(s:joinUndo() . "\<Left>", times + 1)
|
||||
endif
|
||||
let val .= "\<CR>"
|
||||
if &smartindent && !&cindent && !&indentexpr
|
||||
\ && s:get_char(0) == '}'
|
||||
" indentation is controlled by 'smartindent', and the first character on
|
||||
" the new line is '}'. If this were typed manually it would reindent to
|
||||
" match the current line. Let's reproduce that behavior.
|
||||
let sw = &sw == 0 ? &ts : &sw
|
||||
let shifts = indent('.') / sw
|
||||
let spaces = indent('.') - (shifts * sw)
|
||||
let val .= "^\<C-D>".repeat("\<C-T>", shifts).repeat(' ', spaces)
|
||||
endif
|
||||
" Expand:
|
||||
" XXX zv prevents breaking expansion with syntax folding enabled by
|
||||
" InsertLeave.
|
||||
let val .= "\<Esc>zvO"
|
||||
return val
|
||||
else
|
||||
return "\<CR>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ExpandSpace() "{{{
|
||||
if s:is_forbidden("\<Space>")
|
||||
return "\<Space>"
|
||||
endif
|
||||
let escaped = s:cursor_idx() >= 2
|
||||
\ && s:get_char(-2) == '\'
|
||||
let expand_inside_quotes = s:get('expand_inside_quotes')
|
||||
\ && s:is_empty_quotes()
|
||||
\ && !escaped
|
||||
if s:is_empty_matchpair() || expand_inside_quotes
|
||||
" Expand:
|
||||
return "\<Space>\<Space>" . s:joinUndo() . "\<Left>"
|
||||
else
|
||||
return "\<Space>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#BS() " {{{
|
||||
if s:is_forbidden("")
|
||||
let extra = ''
|
||||
elseif &bs !~ 'start\|2'
|
||||
let extra = ''
|
||||
elseif delimitMate#WithinEmptyPair()
|
||||
let extra = "\<Del>"
|
||||
elseif s:is_space_expansion()
|
||||
let extra = "\<Del>"
|
||||
elseif s:is_cr_expansion()
|
||||
let extra = repeat("\<Del>",
|
||||
\ len(matchstr(getline(line('.') + 1), '^\s*\S')))
|
||||
else
|
||||
let extra = ''
|
||||
endif
|
||||
return "\<BS>" . extra
|
||||
endfunction " }}} delimitMate#BS()
|
||||
|
||||
function! delimitMate#Test() "{{{
|
||||
%d _
|
||||
" Check for script options:
|
||||
let result = [
|
||||
\ 'delimitMate Report',
|
||||
\ '==================',
|
||||
\ '',
|
||||
\ '* Options: ( ) default, (g) global, (b) buffer',
|
||||
\ '']
|
||||
for option in sort(keys(s:options[bufnr('%')]))
|
||||
if s:exists(option, 'b')
|
||||
let scope = '(b)'
|
||||
elseif s:exists(option, 'g')
|
||||
let scope = '(g)'
|
||||
else
|
||||
let scope = '( )'
|
||||
endif
|
||||
call add(result,
|
||||
\ scope . ' delimitMate_' . option
|
||||
\ . ' = '
|
||||
\ . string(s:get(option)))
|
||||
endfor
|
||||
call add(result, '')
|
||||
|
||||
let option = 'delimitMate_excluded_ft'
|
||||
call add(result,
|
||||
\(exists('g:'.option) ? '(g) ' : '( ) g:') . option . ' = '
|
||||
\. string(get(g:, option, '')))
|
||||
|
||||
call add(result, '--------------------')
|
||||
call add(result, '')
|
||||
|
||||
" Check if mappings were set.
|
||||
let left_delims = s:get('autoclose') ? s:get('left_delims') : []
|
||||
let special_keys = ['<BS>', '<S-BS>', '<S-Tab>', '<C-G>g']
|
||||
if s:get('expand_cr')
|
||||
call add(special_keys, '<CR>')
|
||||
endif
|
||||
if s:get('expand_space')
|
||||
call add(special_keys, '<Space>')
|
||||
endif
|
||||
let maps =
|
||||
\ s:get('right_delims')
|
||||
\ + left_delims
|
||||
\ + s:get('quotes_list')
|
||||
\ + s:get('apostrophes_list')
|
||||
\ + special_keys
|
||||
|
||||
call add(result, '* Mappings:')
|
||||
call add(result, '')
|
||||
for map in maps
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
call extend(result, split(output, '\n'))
|
||||
endfor
|
||||
|
||||
call add(result, '--------------------')
|
||||
call add(result, '')
|
||||
call add(result, '* Showcase:')
|
||||
call add(result, '')
|
||||
call setline(1, result)
|
||||
call s:test_mappings(s:get('left_delims'), 1)
|
||||
call s:test_mappings(s:get('quotes_list'), 0)
|
||||
|
||||
let result = []
|
||||
redir => setoptions
|
||||
echo " * Vim configuration:\<NL>"
|
||||
filetype
|
||||
echo ""
|
||||
set
|
||||
version
|
||||
redir END
|
||||
call extend(result, split(setoptions,"\n"))
|
||||
call add(result, '--------------------')
|
||||
setlocal nowrap
|
||||
call append('$', result)
|
||||
call feedkeys("\<Esc>\<Esc>", 'n')
|
||||
endfunction "}}}
|
||||
|
||||
function! s:test_mappings(list, is_matchpair) "{{{
|
||||
let prefix = "normal Go0\<C-D>"
|
||||
let last = "|"
|
||||
let open = s:get('autoclose') ? 'Open: ' : 'Open & close: '
|
||||
for s in a:list
|
||||
if a:is_matchpair
|
||||
let pair = s:get('right_delims')[index(s:get('left_delims'), s)]
|
||||
else
|
||||
let pair = s
|
||||
endif
|
||||
if !s:get('autoclose')
|
||||
let s .= pair
|
||||
endif
|
||||
exec prefix . open . s . last
|
||||
exec prefix . "Delete: " . s . "\<BS>" . last
|
||||
exec prefix . "Exit: " . s . pair . last
|
||||
if s:get('expand_space')
|
||||
\ && (a:is_matchpair || s:get('expand_inside_quotes'))
|
||||
exec prefix . "Space: " . s . " " . last
|
||||
exec prefix . "Delete space: " . s . " \<BS>" . last
|
||||
endif
|
||||
if s:get('expand_cr')
|
||||
\ && (a:is_matchpair || s:get('expand_inside_quotes'))
|
||||
exec prefix . "Car return: " . s . "\<CR>" . last
|
||||
exec prefix . "Delete car return: " . s . "\<CR>0\<C-D>\<BS>" . last
|
||||
endif
|
||||
call append('$', '')
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:joinUndo() "{{{
|
||||
if v:version < 704
|
||||
\ || ( v:version == 704 && !has('patch849') )
|
||||
return ''
|
||||
endif
|
||||
return "\<C-G>U"
|
||||
endfunction "}}}
|
||||
|
||||
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
||||
4
basic_vimrc
Normal file
4
basic_vimrc
Normal file
@@ -0,0 +1,4 @@
|
||||
so ./test/_setup.vim
|
||||
let delimitMate_expand_cr = 1
|
||||
filetype indent plugin on
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,635 +1,403 @@
|
||||
" ============================================================================
|
||||
" File: delimitMate.vim
|
||||
" Version: 2.0
|
||||
" Description: This plugin tries to emulate the auto-completion of delimiters
|
||||
" that TextMate provides.
|
||||
" File: plugin/delimitMate.vim
|
||||
" Version: 2.7
|
||||
" Modified: 2013-07-15
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
" Credits: Some of the code is modified or just copied from the following:
|
||||
"
|
||||
" - Ian McCracken
|
||||
" Post titled: Vim, Part II: Matching Pairs:
|
||||
" http://concisionandconcinnity.blogspot.com/
|
||||
"
|
||||
" - Aristotle Pagaltzis
|
||||
" From the comments on the previous blog post and from:
|
||||
" http://gist.github.com/144619
|
||||
"
|
||||
" - Vim Scripts:
|
||||
" http://www.vim.org/scripts/
|
||||
" ============================================================================
|
||||
|
||||
" Initialization: {{{
|
||||
if exists("g:loaded_delimitMate") "{{{
|
||||
" User doesn't want this plugin, let's get out!
|
||||
finish
|
||||
|
||||
if exists("g:loaded_delimitMate") || &cp
|
||||
" User doesn't want this plugin or compatible is set, let's get out!
|
||||
finish
|
||||
endif
|
||||
let g:loaded_delimitMate = 1
|
||||
|
||||
if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing")
|
||||
" Don't define the functions if they already exist: just do the work
|
||||
" (unless we are testing):
|
||||
call s:DelimitMateDo()
|
||||
finish
|
||||
endif
|
||||
let save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if v:version < 700
|
||||
echoerr "delimitMate: this plugin requires vim >= 7!"
|
||||
finish
|
||||
echoerr "delimitMate: this plugin requires vim >= 7!"
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:loaded_delimitMate = 1 " }}}
|
||||
let delimitMate_version = '2.0'
|
||||
let s:loaded_delimitMate = 1
|
||||
let delimitMate_version = "2.8"
|
||||
|
||||
function! s:Init() "{{{
|
||||
|
||||
let b:loaded_delimitMate = 1
|
||||
|
||||
" delimitMate_autoclose {{{
|
||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
||||
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 {{{
|
||||
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
|
||||
if s:ValidMatchpairs(&matchpairs) == 1
|
||||
let s:matchpairs_temp = &matchpairs
|
||||
else
|
||||
echoerr "delimitMate: There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
|
||||
finish
|
||||
endif
|
||||
elseif exists("b:delimitMate_matchpairs")
|
||||
if s:ValidMatchpairs(b:delimitMate_matchpairs) || b:delimitMate_matchpairs == ""
|
||||
let s:matchpairs_temp = b:delimitMate_matchpairs
|
||||
else
|
||||
echoerr "delimitMate: Invalid format in 'b:delimitMate_matchpairs', falling back to matchpairs. Fix the error and use the command :DelimitMateReload to try again."
|
||||
if s:ValidMatchpairs(&matchpairs) == 1
|
||||
let s:matchpairs_temp = &matchpairs
|
||||
else
|
||||
echoerr "delimitMate: There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
|
||||
let s:matchpairs_temp = ""
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if s:ValidMatchpairs(g:delimitMate_matchpairs) || g:delimitMate_matchpairs == ""
|
||||
let s:matchpairs_temp = g:delimitMate_matchpairs
|
||||
else
|
||||
echoerr "delimitMate: Invalid format in 'g:delimitMate_matchpairs', falling back to matchpairs. Fix the error and use the command :DelimitMateReload to try again."
|
||||
if s:ValidMatchpairs(&matchpairs) == 1
|
||||
let s:matchpairs_temp = &matchpairs
|
||||
else
|
||||
echoerr "delimitMate: There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
|
||||
let s:matchpairs_temp = ""
|
||||
endif
|
||||
endif
|
||||
|
||||
endif " }}}
|
||||
|
||||
" delimitMate_quotes {{{
|
||||
if exists("b:delimitMate_quotes")
|
||||
if b:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || b:delimitMate_quotes == ""
|
||||
let s:quotes = split(b:delimitMate_quotes)
|
||||
else
|
||||
let s:quotes = split("\" ' `")
|
||||
echoerr "delimitMate: There is a problem with the format of 'b:delimitMate_quotes', it should be a string of single characters separated by spaces. Falling back to default values."
|
||||
endif
|
||||
elseif exists("g:delimitMate_quotes")
|
||||
if g:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || g:delimitMate_quotes == ""
|
||||
let s:quotes = split(g:delimitMate_quotes)
|
||||
else
|
||||
let s:quotes = split("\" ' `")
|
||||
echoerr "delimitMate: There is a problem with the format of 'g:delimitMate_quotes', it should be a string of single characters separated by spaces. Falling back to default values."
|
||||
endif
|
||||
else
|
||||
let s:quotes = split("\" ' `")
|
||||
endif
|
||||
let b:delimitMate_quotes_list = s:quotes " }}}
|
||||
|
||||
" delimitMate_visual_leader {{{
|
||||
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
|
||||
let b:delimitMate_visual_leader = exists('b:maplocalleader') ? b:maplocalleader :
|
||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
||||
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
|
||||
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
|
||||
else
|
||||
" Nothing to do.
|
||||
endif " }}}
|
||||
|
||||
" delimitMate_expand_space {{{
|
||||
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
||||
let b:delimitMate_expand_space = 0
|
||||
elseif !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
||||
let b:delimitMate_expand_space = g:delimitMate_expand_space
|
||||
else
|
||||
" Nothing to do.
|
||||
endif " }}}
|
||||
|
||||
" delimitMate_expand_cr {{{
|
||||
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
|
||||
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
|
||||
let b:delimitMate_apostrophes_list = s:apostrophes " }}}
|
||||
|
||||
" delimitMate_tab2exit {{{
|
||||
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
|
||||
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, ',')
|
||||
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
|
||||
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
|
||||
let s:VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
||||
|
||||
call s:UnMap()
|
||||
if b:delimitMate_autoclose
|
||||
call s:AutoClose()
|
||||
else
|
||||
call s:NoAutoClose()
|
||||
endif
|
||||
call s:VisualMaps()
|
||||
call s:ExtraMappings()
|
||||
|
||||
endfunction "}}} Init()
|
||||
"}}}
|
||||
|
||||
" Utilities: {{{
|
||||
function! s:ValidMatchpairs(str) "{{{
|
||||
if a:str !~ '^.:.\(,.:.\)*$'
|
||||
return 0
|
||||
endif
|
||||
for pair in split(a:str,',')
|
||||
if strpart(pair, 0, 1) == strpart(pair, 2, 1) || strlen(pair) != 3
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endfunction "}}}
|
||||
" Functions: {{{
|
||||
|
||||
function! DelimitMate_ShouldJump() "{{{
|
||||
let char = getline('.')[col('.') - 1]
|
||||
for pair in b:delimitMate_matchpairs_list
|
||||
if char == split( pair, ':' )[1]
|
||||
" Same character on the rigth, jump over it.
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
for quote in b:delimitMate_quotes_list
|
||||
if char == quote
|
||||
" Same character on the rigth, jump over it.
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:IsBlockVisual() " {{{
|
||||
if visualmode() == "<C-V>"
|
||||
return 1
|
||||
endif
|
||||
" Store unnamed register values for later use in s:RestoreRegister().
|
||||
let s:save_reg = getreg('"')
|
||||
let s:save_reg_mode = getregtype('"')
|
||||
|
||||
if len(getline('.')) == 0
|
||||
" This for proper wrap of empty lines.
|
||||
let @" = "\n"
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}}
|
||||
|
||||
function! s:IsEmptyPair(str) "{{{
|
||||
for pair in b:delimitMate_matchpairs_list
|
||||
if a:str == join( split( pair, ':' ),'' )
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
for quote in b:delimitMate_quotes_list
|
||||
if a:str == quote . quote
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! DelimitMate_WithinEmptyPair() "{{{
|
||||
let cur = strpart( getline('.'), col('.')-2, 2 )
|
||||
return s:IsEmptyPair( cur )
|
||||
endfunction "}}}
|
||||
|
||||
function! s:WriteBefore(str) "{{{
|
||||
let len = len(a:str)
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if col < 0
|
||||
call setline('.',line[(col+len+1):])
|
||||
else
|
||||
call setline('.',line[:(col)].line[(col+len+1):])
|
||||
endif
|
||||
return a:str
|
||||
endfunction " }}}
|
||||
|
||||
function! s:WriteAfter(str) "{{{
|
||||
let len = len(a:str)
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if (col) < 0
|
||||
call setline('.',a:str.line)
|
||||
else
|
||||
call setline('.',line[:(col)].a:str.line[(col+len):])
|
||||
endif
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! s:RestoreRegister() " {{{
|
||||
" Restore unnamed register values store in s:IsBlockVisual().
|
||||
call setreg('"', s:save_reg, s:save_reg_mode)
|
||||
echo ""
|
||||
endfunction " }}}
|
||||
" }}}
|
||||
|
||||
" Doers: {{{
|
||||
function! s:JumpIn(char) " {{{
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if (col) < 0
|
||||
call setline('.',a:char.line)
|
||||
function! s:option_init(name, default) "{{{
|
||||
let opt_name = "delimitMate_" . a:name
|
||||
" Find value to use.
|
||||
if !has_key(b:, opt_name) && !has_key(g:, opt_name)
|
||||
let value = a:default
|
||||
elseif has_key(b:, opt_name)
|
||||
let value = b:[opt_name]
|
||||
else
|
||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||
let value = g:[opt_name]
|
||||
endif
|
||||
return ''
|
||||
call s:set(a:name, value)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:init() "{{{
|
||||
" Initialize variables:
|
||||
" autoclose
|
||||
call s:option_init("autoclose", 1)
|
||||
" matchpairs
|
||||
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||
call s:option_init("matchpairs_list", map(split(s:get('matchpairs', ''), '.:.\zs,\ze.:.'), 'split(v:val, ''^.\zs:\ze.$'')'))
|
||||
let pairs = s:get('matchpairs_list', [])
|
||||
if len(filter(pairs, 'v:val[0] ==# v:val[1]'))
|
||||
echohl ErrorMsg
|
||||
echom 'delimitMate: each member of a pair in delimitMate_matchpairs must be different from each other.'
|
||||
echom 'delimitMate: invalid pairs: ' . join(map(pairs, 'join(v:val, ":")'), ', ')
|
||||
echohl Normal
|
||||
return 0
|
||||
endif
|
||||
call s:option_init("left_delims", map(copy(s:get('matchpairs_list', [])), 'v:val[0]'))
|
||||
call s:option_init("right_delims", map(copy(s:get('matchpairs_list', [])), 'v:val[1]'))
|
||||
" quotes
|
||||
call s:option_init("quotes", "\" ' `")
|
||||
call s:option_init("quotes_list",split(s:get('quotes', ''), '\s\+'))
|
||||
" nesting_quotes
|
||||
call s:option_init("nesting_quotes", [])
|
||||
" excluded_regions
|
||||
call s:option_init("excluded_regions", "Comment")
|
||||
call s:option_init("excluded_regions_list", split(s:get('excluded_regions', ''), ',\s*'))
|
||||
let enabled = len(s:get('excluded_regions_list', [])) > 0
|
||||
call s:option_init("excluded_regions_enabled", enabled)
|
||||
" expand_space
|
||||
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||
unlet b:delimitMate_expand_space
|
||||
let b:delimitMate_expand_space = 1
|
||||
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 s:option_init("expand_space", 0)
|
||||
" 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') && &backspace != 2) &&
|
||||
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
||||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
||||
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
|
||||
endif
|
||||
call s:option_init("expand_cr", 0)
|
||||
" expand_in_quotes
|
||||
call s:option_init('expand_inside_quotes', 0)
|
||||
" jump_expansion
|
||||
call s:option_init("jump_expansion", 0)
|
||||
" smart_matchpairs
|
||||
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|[£$]\|[^[:punct:][:space:]]\)')
|
||||
" smart_quotes
|
||||
" XXX: backward compatibility. Ugly, should go the way of the dodo soon.
|
||||
let quotes = escape(join(s:get('quotes_list', []), ''), '\-^[]')
|
||||
let default_smart_quotes = '\%(\w\|[^[:punct:][:space:]' . quotes . ']\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]' . quotes . ']\)'
|
||||
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) == type(0)
|
||||
if g:delimitMate_smart_quotes
|
||||
unlet g:delimitMate_smart_quotes
|
||||
else
|
||||
unlet g:delimitMate_smart_quotes
|
||||
let g:delimitMate_smart_quotes = ''
|
||||
endif
|
||||
endif
|
||||
if exists('b:delimitMate_smart_quotes') && type(b:delimitMate_smart_quotes) == type(0)
|
||||
if b:delimitMate_smart_quotes
|
||||
unlet b:delimitMate_smart_quotes
|
||||
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) && g:delimitMate_smart_quotes
|
||||
let b:delimitMate_smart_quotes = default_smart_quotes
|
||||
endif
|
||||
else
|
||||
unlet b:delimitMate_smart_quotes
|
||||
let b:delimitMate_smart_quotes = ''
|
||||
endif
|
||||
endif
|
||||
call s:option_init("smart_quotes", default_smart_quotes)
|
||||
" apostrophes
|
||||
call s:option_init("apostrophes", "")
|
||||
call s:option_init("apostrophes_list", split(s:get('apostrophes', ''), ":\s*"))
|
||||
" tab2exit
|
||||
call s:option_init("tab2exit", 1)
|
||||
" balance_matchpairs
|
||||
call s:option_init("balance_matchpairs", 0)
|
||||
" eol marker
|
||||
call s:option_init("insert_eol_marker", 1)
|
||||
call s:option_init("eol_marker", "")
|
||||
" Everything is fine.
|
||||
return 1
|
||||
endfunction "}}} Init()
|
||||
|
||||
function! s:get(name, default) "{{{
|
||||
let bufoptions = delimitMate#Get()
|
||||
return get(bufoptions, a:name, a:default)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:set(...) " {{{
|
||||
return call('delimitMate#Set', a:000)
|
||||
endfunction " }}}
|
||||
|
||||
function! s:JumpOut(char) "{{{
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if line[col+1] == a:char
|
||||
call setline('.',line[:(col)].line[(col+2):])
|
||||
endif
|
||||
return a:char
|
||||
endfunction " }}}
|
||||
function! s:Map() "{{{
|
||||
" Set mappings:
|
||||
try
|
||||
let save_keymap = &keymap
|
||||
let save_iminsert = &iminsert
|
||||
let save_imsearch = &imsearch
|
||||
let save_cpo = &cpo
|
||||
set keymap=
|
||||
set cpo&vim
|
||||
silent! doautocmd <nomodeline> User delimitMate_map
|
||||
if s:get('autoclose', 1)
|
||||
call s:AutoClose()
|
||||
else
|
||||
call s:NoAutoClose()
|
||||
endif
|
||||
call s:ExtraMappings()
|
||||
finally
|
||||
let &cpo = save_cpo
|
||||
let &keymap = save_keymap
|
||||
let &iminsert = save_iminsert
|
||||
let &imsearch = save_imsearch
|
||||
endtry
|
||||
|
||||
function! DelimitMate_JumpAny() " {{{
|
||||
let nchar = getline('.')[col('.')-1]
|
||||
return nchar . "\<Del>"
|
||||
endfunction " DelimitMate_JumpAny() }}}
|
||||
let b:delimitMate_enabled = 1
|
||||
endfunction "}}} Map()
|
||||
|
||||
function! s:SkipDelim(char) "{{{
|
||||
let cur = strpart( getline('.'), col('.')-2, 3 )
|
||||
if cur[0] == "\\"
|
||||
" Escaped character
|
||||
return a:char
|
||||
elseif cur[1] == a:char
|
||||
" Exit pair
|
||||
return s:WriteBefore(a:char)
|
||||
"elseif cur[1] == ' ' && cur[2] == a:char
|
||||
"" I'm leaving this in case someone likes it. Jump an space and delimiter.
|
||||
"return "\<Right>\<Right>"
|
||||
elseif s:IsEmptyPair( cur[0] . a:char )
|
||||
" Add closing delimiter and jump back to the middle.
|
||||
return s:WriteAfter(a:char)
|
||||
else
|
||||
" Nothing special here, return the same character.
|
||||
return a:char
|
||||
endif
|
||||
function! s:Unmap() " {{{
|
||||
let imaps =
|
||||
\ s:get('right_delims', []) +
|
||||
\ s:get('left_delims', []) +
|
||||
\ s:get('quotes_list', []) +
|
||||
\ s:get('apostrophes_list', []) +
|
||||
\ ['<BS>', '<C-h>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<C-Left>', '<C-Right>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
|
||||
|
||||
for map in imaps
|
||||
if maparg(map, "i") =~# '^<Plug>delimitMate'
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
exec 'silent! iunmap <buffer> ' . map
|
||||
endif
|
||||
endfor
|
||||
silent! doautocmd <nomodeline> User delimitMate_unmap
|
||||
let b:delimitMate_enabled = 0
|
||||
endfunction " }}} s:Unmap()
|
||||
|
||||
function! s:test() "{{{
|
||||
if &modified
|
||||
let confirm = input("Modified buffer, type \"yes\" to write and proceed "
|
||||
\ . "with test: ") ==? 'yes'
|
||||
if !confirm
|
||||
return
|
||||
endif
|
||||
endif
|
||||
call delimitMate#Test()
|
||||
g/\%^$/d
|
||||
0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:QuoteDelim(char) "{{{
|
||||
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 s:WriteBefore(a:char)
|
||||
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.
|
||||
return s:WriteAfter(a:char)
|
||||
else
|
||||
" Insert a pair and jump to the middle.
|
||||
call s:WriteAfter(a:char)
|
||||
return a:char
|
||||
endif
|
||||
function! s:setup(...) "{{{
|
||||
let swap = a:0 && a:1 == 2
|
||||
let enable = a:0 && a:1
|
||||
let disable = a:0 && !a:1
|
||||
" First, remove all magic, if needed:
|
||||
if get(b:, 'delimitMate_enabled', 0)
|
||||
call s:Unmap()
|
||||
" Switch
|
||||
if swap
|
||||
echo "delimitMate is disabled."
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if disable
|
||||
" Just disable the mappings.
|
||||
return
|
||||
endif
|
||||
if !a:0
|
||||
" Check if this file type is excluded:
|
||||
if exists("g:delimitMate_excluded_ft") &&
|
||||
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||
" Finish here:
|
||||
return 1
|
||||
endif
|
||||
" Check if user tried to disable using b:loaded_delimitMate
|
||||
if exists("b:loaded_delimitMate")
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
" Initialize settings:
|
||||
if ! s:init()
|
||||
" Something went wrong.
|
||||
return
|
||||
endif
|
||||
if enable || swap || !get(g:, 'delimitMate_offByDefault', 0)
|
||||
" Now, add magic:
|
||||
call s:Map()
|
||||
if a:0
|
||||
echo "delimitMate is enabled."
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:MapMsg(msg) "{{{
|
||||
redraw
|
||||
echomsg a:msg
|
||||
return ""
|
||||
function! s:TriggerAbb() "{{{
|
||||
if v:version < 703
|
||||
\ || ( v:version == 703 && !has('patch489') )
|
||||
\ || pumvisible()
|
||||
return ''
|
||||
endif
|
||||
return "\<C-]>"
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" Mappings: {{{
|
||||
function! s:NoAutoClose() "{{{
|
||||
" inoremap <buffer> ) <C-R>=<SID>SkipDelim('\)')<CR>
|
||||
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||
endfor
|
||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||
for delim in s:get('right_delims', []) + s:get('quotes_list', [])
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=<SID>TriggerAbb().delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:AutoClose() "{{{
|
||||
" Add matching pair and jump to the midle:
|
||||
" inoremap <buffer> ( ()<Left>
|
||||
let i = 0
|
||||
while i < len(b:delimitMate_matchpairs_list)
|
||||
let ld = b:delimitMate_left_delims[i]
|
||||
let rd = b:delimitMate_right_delims[i]
|
||||
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=<SID>JumpIn("' . rd . '")<CR>'
|
||||
let i += 1
|
||||
endwhile
|
||||
" Add matching pair and jump to the midle:
|
||||
" inoremap <silent> <buffer> ( ()<Left>
|
||||
let i = 0
|
||||
while i < len(s:get('matchpairs_list', []))
|
||||
let ld = s:get('left_delims', [])[i] == '|' ? '<bar>' : s:get('left_delims', [])[i]
|
||||
let rd = s:get('right_delims', [])[i] == '|' ? '<bar>' : s:get('right_delims', [])[i]
|
||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . ld
|
||||
\. ' <SID>TriggerAbb().delimitMate#ParenDelim("' . escape(rd, '|') . '")'
|
||||
exec 'silent! imap <unique> <buffer> '.ld
|
||||
\.' <Plug>delimitMate'.ld
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||
" inoremap <buffer> " <C-R>=<SID>QuoteDelim("\"")<CR>
|
||||
for delim in b:delimitMate_quotes_list
|
||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>QuoteDelim("\' . delim . '")<CR>'
|
||||
endfor
|
||||
" Exit from inside the matching pair:
|
||||
for delim in s:get('right_delims', [])
|
||||
let delim = delim == '|' ? '<bar>' : delim
|
||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||
\. ' <SID>TriggerAbb().delimitMate#JumpOut("\' . delim . '")'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim
|
||||
\. ' <Plug>delimitMate'. delim
|
||||
endfor
|
||||
|
||||
" Exit from inside the matching pair:
|
||||
for delim in b:delimitMate_right_delims
|
||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=<SID>JumpOut("\' . delim . '")<CR>'
|
||||
endfor
|
||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||
for delim in s:get('quotes_list', [])
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||
\. ' <SID>TriggerAbb()."<C-R>=delimitMate#QuoteDelim(\"\\\' . delim . '\")<CR>"'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim
|
||||
\. ' <Plug>delimitMate' . delim
|
||||
endfor
|
||||
|
||||
" Try to fix the use of apostrophes (de-activated by default):
|
||||
" inoremap <buffer> n't n't
|
||||
for map in b:delimitMate_apostrophes_list
|
||||
exec "inoremap <buffer> " . map . " " . map
|
||||
endfor
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
function! s:VisualMaps() " {{{
|
||||
let vleader = b:delimitMate_visual_leader
|
||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
||||
let i = 0
|
||||
while i < len(b:delimitMate_matchpairs_list)
|
||||
" Map left delimiter:
|
||||
let ld = b:delimitMate_left_delims[i]
|
||||
let rd = b:delimitMate_right_delims[i]
|
||||
exec 'vnoremap <buffer> <expr> ' . vleader . ld . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . ld . '\<C-R>\"' . rd . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||
|
||||
" Map right delimiter:
|
||||
exec 'vnoremap <buffer> <expr> ' . vleader . rd . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . ld . '\<C-R>\"' . rd . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
" Wrap the selection with matching quotes, but do nothing if blockwise visual mode is active:
|
||||
for quote in b:delimitMate_quotes_list
|
||||
" vnoremap <buffer> <expr> \' <SID>IsBlockVisual() ? <SID>MapMsg("Message") : "s'\<C-R>\"'\<Esc>:call <SID>RestoreRegister()<CR>"
|
||||
exec 'vnoremap <buffer> <expr> ' . vleader . quote . ' <SID>IsBlockVisual() ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') .'\<C-R>\"' . escape(quote,'"') . '\<Esc>:call <SID>RestoreRegister()<CR>"'
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! DelimitMate_ExpandReturn() "{{{
|
||||
" Expand:
|
||||
return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
||||
endfunction "}}}
|
||||
|
||||
function! DelimitMate_ExpandSpace() "{{{
|
||||
" Expand:
|
||||
return s:WriteAfter(' ') . "\<Space>"
|
||||
" Try to fix the use of apostrophes (kept for backward compatibility):
|
||||
" inoremap <silent> <buffer> n't n't
|
||||
for map in s:get('apostrophes_list', [])
|
||||
exec "inoremap <silent> " . map . " " . map
|
||||
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:ExtraMappings() "{{{
|
||||
" If pair is empty, delete both delimiters:
|
||||
inoremap <buffer> <expr> <BS> DelimitMate_WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
|
||||
|
||||
" If pair is empty, delete closing delimiter:
|
||||
inoremap <buffer> <expr> <S-BS> DelimitMate_WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||
|
||||
" Expand return if inside an empty pair:
|
||||
if b:delimitMate_expand_cr != 0
|
||||
inoremap <buffer> <expr> <CR> DelimitMate_WithinEmptyPair() ?
|
||||
\ DelimitMate_ExpandReturn() : "\<CR>"
|
||||
endif
|
||||
|
||||
" Expand space if inside an empty pair:
|
||||
if b:delimitMate_expand_space != 0
|
||||
inoremap <buffer> <expr> <Space> DelimitMate_WithinEmptyPair() ?
|
||||
\ DelimitMate_ExpandSpace() : "\<Space>"
|
||||
endif
|
||||
|
||||
" Jump out ot any empty pair:
|
||||
if b:delimitMate_tab2exit
|
||||
inoremap <buffer> <expr> <S-Tab> DelimitMate_ShouldJump() ? DelimitMate_JumpAny() : "\<S-Tab>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" Tools: {{{
|
||||
function! s:TestMappings() "{{{
|
||||
if b:delimitMate_autoclose
|
||||
exec "normal i* AUTOCLOSE:\<CR>"
|
||||
for i in range(len(b:delimitMate_left_delims))
|
||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
|
||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
|
||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
|
||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||
endfor
|
||||
for i in range(len(b:delimitMate_quotes_list))
|
||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
||||
exec "normal A\<CR>Delete: "
|
||||
exec "normal A". b:delimitMate_quotes_list[i]
|
||||
exec "normal a\<BS>|"
|
||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||
endfor
|
||||
else
|
||||
exec "normal i* NO AUTOCLOSE:\<CR>"
|
||||
for i in range(len(b:delimitMate_left_delims))
|
||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
|
||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
|
||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
|
||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||
endfor
|
||||
for i in range(len(b:delimitMate_quotes_list))
|
||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
||||
exec "normal A\<CR>Delete: " . b:delimitMate_quotes_list[i] . b: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 A\<CR>Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |"
|
||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
|
||||
endfor
|
||||
endif
|
||||
exec "normal \<Esc>i"
|
||||
" If pair is empty, delete both delimiters:
|
||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||
if !hasmapto('<Plug>delimitMateBS','i')
|
||||
if empty(maparg('<BS>', 'i'))
|
||||
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||
endif
|
||||
if empty(maparg('<C-H>', 'i'))
|
||||
silent! imap <unique> <buffer> <C-h> <Plug>delimitMateBS
|
||||
endif
|
||||
endif
|
||||
" If pair is empty, delete closing delimiter:
|
||||
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||
if !hasmapto('<Plug>delimitMateS-BS','i') && maparg('<S-BS>', 'i') == ''
|
||||
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||
endif
|
||||
" Expand return if inside an empty pair:
|
||||
inoremap <expr><silent> <Plug>delimitMateCR <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||
if s:get('expand_cr', 0) && !hasmapto('<Plug>delimitMateCR', 'i') && maparg('<CR>', 'i') == ''
|
||||
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||
endif
|
||||
" Expand space if inside an empty pair:
|
||||
inoremap <expr><silent> <Plug>delimitMateSpace <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandSpace()\<CR>"
|
||||
if s:get('expand_space', 0) && !hasmapto('<Plug>delimitMateSpace', 'i') && maparg('<Space>', 'i') == ''
|
||||
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||
endif
|
||||
" Jump over any delimiter:
|
||||
inoremap <expr><silent> <Plug>delimitMateS-Tab <SID>TriggerAbb()."\<C-R>=delimitMate#JumpAny()\<CR>"
|
||||
if s:get('tab2exit', 0) && !hasmapto('<Plug>delimitMateS-Tab', 'i') && maparg('<S-Tab>', 'i') == ''
|
||||
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||
endif
|
||||
" Jump over next delimiters
|
||||
inoremap <expr><buffer> <Plug>delimitMateJumpMany <SID>TriggerAbb()."\<C-R>=delimitMate#JumpMany()\<CR>"
|
||||
if !hasmapto('<Plug>delimitMateJumpMany', 'i') && maparg("<C-G>g", 'i') == ''
|
||||
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:SwitchAutoclose() "{{{
|
||||
if !exists("g:delimitMate_autoclose")
|
||||
let g:delimitMate_autoclose = 1
|
||||
elseif g:delimitMate_autoclose == 1
|
||||
let g:delimitMate_autoclose = 0
|
||||
else
|
||||
let g:delimitMate_autoclose = 1
|
||||
endif
|
||||
DelimitMateReload
|
||||
endfunction "}}}
|
||||
|
||||
function! s:UnMap() " {{{
|
||||
" No Autoclose Mappings:
|
||||
for char in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||
if maparg(char,"i") =~? 'SkipDelim'
|
||||
exec 'silent! iunmap <buffer> ' . char
|
||||
"echomsg 'iunmap <buffer> ' . char
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Autoclose Mappings:
|
||||
let i = 0
|
||||
let l = len(b:delimitMate_matchpairs_list)
|
||||
while i < l
|
||||
if maparg(b:delimitMate_left_delims[i],"i") =~? 'JumpIn'
|
||||
exec 'silent! iunmap <buffer> ' . b:delimitMate_left_delims[i]
|
||||
"echomsg 'iunmap <buffer> ' . b:delimitMate_left_delims[i]
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
for char in b:delimitMate_quotes_list
|
||||
if maparg(char, "i") =~? 'QuoteDelim'
|
||||
exec 'silent! iunmap <buffer> ' . char
|
||||
"echomsg 'iunmap <buffer> ' . char
|
||||
endif
|
||||
endfor
|
||||
for char in b:delimitMate_right_delims
|
||||
if maparg(char, "i") =~? 'JumpOut'
|
||||
exec 'silent! iunmap <buffer> ' . char
|
||||
"echomsg 'iunmap <buffer> ' . char
|
||||
endif
|
||||
endfor
|
||||
for map in b:delimitMate_apostrophes_list
|
||||
exec "silent! iunmap <buffer> " . map
|
||||
endfor
|
||||
|
||||
" Visual Mappings:
|
||||
for char in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes_list
|
||||
if maparg(b:delimitMate_visual_leader . char,"v") =~? 'IsBlock'
|
||||
exec 'silent! vunmap <buffer> ' . b:delimitMate_visual_leader . char
|
||||
"echomsg 'vunmap <buffer> ' . b:delimitMate_visual_leader . char
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Expansion Mappings:
|
||||
if maparg('<BS>', "i") =~? 'WithinEmptyPair'
|
||||
silent! iunmap <buffer> <BS>
|
||||
"echomsg "silent! iunmap <buffer> <BS>"
|
||||
endif
|
||||
if maparg('<S-BS>', "i") =~? 'WithinEmptyPair'
|
||||
silent! iunmap <buffer> <BS>
|
||||
"echomsg "silent! iunmap <buffer> <BS>"
|
||||
endif
|
||||
if maparg('<CR>',"i") =~? 'DelimitMate_ExpandReturn'
|
||||
silent! iunmap <buffer> <CR>
|
||||
"echomsg "silent! iunmap <buffer> <CR>"
|
||||
endif
|
||||
if maparg('<Space>',"i") =~? 'DelimitMate_ExpandSpace'
|
||||
silent! iunmap <buffer> <Space>
|
||||
"echomsg "silent! iunmap <buffer> <Space>"
|
||||
endif
|
||||
if maparg('<S-Tab>', "i") =~? 'ShouldJump'
|
||||
silent! iunmap <buffer> <S-Tab>
|
||||
"echomsg "silent! iunmap <buffer> <S-Tab>"
|
||||
endif
|
||||
endfunction " }}} s:ExtraMappings()
|
||||
|
||||
function! s:TestMappingsDo() "{{{
|
||||
"DelimitMateReload
|
||||
if !exists("g:delimitMate_testing")
|
||||
"call s:DelimitMateDo()
|
||||
call s:TestMappings()
|
||||
else
|
||||
call s:SwitchAutoclose()
|
||||
call s:TestMappings()
|
||||
exec "normal i\<CR>"
|
||||
call s:SwitchAutoclose()
|
||||
call s:TestMappings()
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:DelimitMateDo() "{{{
|
||||
if exists("g:delimitMate_excluded_ft")
|
||||
" Check if this file type is excluded:
|
||||
for ft in split(g:delimitMate_excluded_ft,',')
|
||||
if ft ==? &filetype
|
||||
if !exists("b:delimitMate_quotes_list")
|
||||
return 1
|
||||
endif
|
||||
"echomsg "excluded"
|
||||
call s:UnMap()
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
try
|
||||
"echomsg "included"
|
||||
let save_cpo = &cpo
|
||||
set cpo&vim
|
||||
call s:Init()
|
||||
finally
|
||||
let &cpo = save_cpo
|
||||
endtry
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" Commands: {{{
|
||||
call s:DelimitMateDo()
|
||||
|
||||
" Let me refresh without re-loading the buffer:
|
||||
command! DelimitMateReload call s:DelimitMateDo()
|
||||
|
||||
command! -bar DelimitMateReload call s:setup(1)
|
||||
" Quick test:
|
||||
command! DelimitMateTest call s:TestMappingsDo()
|
||||
command! -bar DelimitMateTest call s:test()
|
||||
" Switch On/Off:
|
||||
command! -bar DelimitMateSwitch call s:setup(2)
|
||||
" Enable mappings:
|
||||
command! -bar DelimitMateOn call s:setup(1)
|
||||
" Disable mappings:
|
||||
command! -bar DelimitMateOff call s:setup(0)
|
||||
|
||||
" Run on file type events.
|
||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
||||
autocmd FileType * call <SID>DelimitMateDo()
|
||||
|
||||
" Run on new buffers.
|
||||
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
|
||||
|
||||
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
|
||||
"}}}
|
||||
|
||||
" Autocommands: {{{
|
||||
|
||||
augroup delimitMate
|
||||
au!
|
||||
" Run on file type change.
|
||||
au FileType * call <SID>setup()
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
|
||||
|
||||
" Run on new buffers.
|
||||
au BufNewFile,BufRead,BufEnter,CmdwinEnter *
|
||||
\ if !exists('b:delimitMate_was_here') |
|
||||
\ call <SID>setup() |
|
||||
\ let b:delimitMate_was_here = 1 |
|
||||
\ endif
|
||||
augroup END
|
||||
|
||||
"}}}
|
||||
|
||||
" This is for the default buffer when it does not have a filetype.
|
||||
call s:setup()
|
||||
|
||||
let &cpo = save_cpo
|
||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
||||
" vim:foldmethod=marker:foldcolumn=4
|
||||
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
||||
|
||||
9
test/Makefile
Normal file
9
test/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
all: build/runVimTests
|
||||
build/runVimTests/bin/runVimTests.sh -0 .
|
||||
|
||||
build/runVimTests: build/VimTAP
|
||||
git clone https://github.com/inkarkat/runVimTests $@
|
||||
|
||||
# Use VimTAP as directory name, as used with runVimTestsSetup.vim.
|
||||
build/VimTAP:
|
||||
git clone https://github.com/inkarkat/vimtap $@
|
||||
18
test/README.md
Normal file
18
test/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Automatic test setup
|
||||
You can use `make` (or `make test` from the top level directory) to run the
|
||||
tests.
|
||||
|
||||
# Manual test setup instructions
|
||||
The plugins [runVimTests](http://www.vim.org/scripts/script.php?script_id=2565)
|
||||
and [VimTAP](http://www.vim.org/scripts/script.php?script_id=2213) are needed
|
||||
to run these tests.
|
||||
|
||||
Besides the `_setup.vim` configuration file present in this repo you need to
|
||||
create a global one and place it in the same dir where the runVimTests
|
||||
executable is located. Assuming the executable is at '~/bin/runVimTests' this
|
||||
global configuration file should be '~/bin/runVimTestsSetup.vim' and should
|
||||
have something like the following lines inside of it:
|
||||
|
||||
" Prepend tests repos to &rtp
|
||||
let &runtimepath = '/path/to/runVimTests_dir,' . &rtp
|
||||
let &runtimepath = '/path/to/vimTAP_dir,' . &rtp
|
||||
12
test/_setup.vim
Normal file
12
test/_setup.vim
Normal file
@@ -0,0 +1,12 @@
|
||||
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
|
||||
set bs=2
|
||||
ru plugin/delimitMate.vim
|
||||
let runVimTests = expand('<sfile>:p:h').'/build/runVimTests'
|
||||
if isdirectory(runVimTests)
|
||||
let &rtp = runVimTests . ',' . &rtp
|
||||
endif
|
||||
let vimTAP = expand('<sfile>:p:h').'/build/VimTAP'
|
||||
if isdirectory(vimTAP)
|
||||
let &rtp = vimTAP . ',' . &rtp
|
||||
endif
|
||||
|
||||
51
test/autoclose_matchpairs.txt
Normal file
51
test/autoclose_matchpairs.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
let g:delimitMate_autoclose = 1
|
||||
"(x" "(x)"
|
||||
"(\<BS>x" "x"
|
||||
"()x" "()x"
|
||||
"((\<C-G>gx" "(())x"
|
||||
"(x\<Esc>u" ""
|
||||
"@(x" "@(x)"
|
||||
"@#\<Left>(x" "@(x)#"
|
||||
"(\<S-Tab>x" "()x"
|
||||
let g:delimitMate_autoclose = 0
|
||||
"(x" "(x"
|
||||
"()x" "(x)"
|
||||
"())x" "()x"
|
||||
"()\<BS>x" "x"
|
||||
"@()x" "@(x)"
|
||||
"@#\<Left>()x" "@(x)#"
|
||||
let g:delimitMate_expand_space = 1
|
||||
let g:delimitMate_autoclose = 1
|
||||
"(\<Space>x" "( x )"
|
||||
"(\<Space>\<BS>x" "(x)"
|
||||
let g:delimitMate_autoclose = 0
|
||||
"()\<Space>\<BS>x" "(x)"
|
||||
let g:delimitMate_autoclose = 1
|
||||
# Handle backspace gracefully.
|
||||
set backspace=
|
||||
"(\<Esc>a\<BS>x" "(x)"
|
||||
set bs=2
|
||||
# closing parens removes characters. #133
|
||||
"(a\<Esc>i)" "()a)"
|
||||
|
||||
# Add semicolon next to the closing paren. Issue #77.
|
||||
new
|
||||
let b:delimitMate_eol_marker = ';'
|
||||
"abc(x" "abc(x);"
|
||||
%d
|
||||
# BS should behave accordingly.
|
||||
"abc(\<BS>" "abc;"
|
||||
# Expand iabbreviations
|
||||
unlet b:delimitMate_eol_marker
|
||||
iabb def ghi
|
||||
"def(" "ghi()"
|
||||
iunabb def
|
||||
|
||||
"abc а\<Left>(" "abc (а"
|
||||
"abc ñ\<Left>(" "abc (ñ"
|
||||
"abc $\<Left>(" "abc ($"
|
||||
"abc £\<Left>(" "abc (£"
|
||||
"abc d\<Left>(" "abc (d"
|
||||
"abc \<C-V>(\<Left>(" "abc (("
|
||||
"abc .\<Left>(" "abc ()."
|
||||
"abc \<Left>(" "abc () "
|
||||
42
test/autoclose_matchpairs.vim
Normal file
42
test/autoclose_matchpairs.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!,,::'
|
||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||
call vimtest#StartTap()
|
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||
let itemsnumber = len(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'))
|
||||
call vimtap#Plan(testsnumber * itemsnumber)
|
||||
let tcount = 1
|
||||
let reload = 1
|
||||
for item in lines
|
||||
if item =~ '^#\|^\s*$'
|
||||
" A comment or empty line.
|
||||
continue
|
||||
endif
|
||||
if item !~ '^"'
|
||||
" A command.
|
||||
exec item
|
||||
call vimtap#Diag(item)
|
||||
let reload = 1
|
||||
continue
|
||||
endif
|
||||
if reload
|
||||
DelimitMateReload
|
||||
call vimtap#Diag('DelimitMateReload')
|
||||
let reload = 0
|
||||
endif
|
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||
for [s:l,s:r] in map(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'), 'split(v:val, ''.\zs:\ze.'')')
|
||||
let input2 = substitute(input, '(', s:l, 'g')
|
||||
let input2 = substitute(input2, ')', s:r, 'g')
|
||||
let output2 = substitute(output, '(', s:l, 'g')
|
||||
let output2 = substitute(output2, ')', s:r, 'g')
|
||||
%d
|
||||
exec 'normal i'.eval(input2)."\<Esc>"
|
||||
let line = getline('.')
|
||||
let passed = line == eval(output2)
|
||||
call vimtap#Is(line, eval(output2), input2)
|
||||
", input2 . ' => ' . string(line) .
|
||||
" \ (passed ? ' =' : ' !') . '= ' . string(eval(output2)))
|
||||
let tcount += 1
|
||||
endfor
|
||||
endfor
|
||||
call vimtest#Quit()
|
||||
73
test/autoclose_quotes.txt
Normal file
73
test/autoclose_quotes.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
let g:delimitMate_autoclose = 1
|
||||
"'x" "'x'"
|
||||
"'x\<Esc>u" ""
|
||||
"''x" "''x"
|
||||
"'\<BS>x" "x"
|
||||
"'\<C-G>gx" "''x"
|
||||
# This will fail for double quote.
|
||||
"'\"x" "'\"x\"'"
|
||||
"@'x" "@'x'"
|
||||
"@#\<Left>'x" "@'x'#"
|
||||
"'\<S-Tab>x" "''x"
|
||||
"abc'" "abc'"
|
||||
"abc\\'x" "abc\\'x"
|
||||
"u'Привет'" "u'Привет'"
|
||||
"u'string'" "u'string'"
|
||||
let g:delimitMate_autoclose = 0
|
||||
"'x" "'x"
|
||||
"''x" "'x'"
|
||||
"'''x" "''x"
|
||||
"''\<BS>x" "x"
|
||||
"@''x" "@'x'"
|
||||
"@#\<Left>''x" "@'x'#"
|
||||
let g:delimitMate_expand_space = 1
|
||||
let g:delimitMate_autoclose = 1
|
||||
"'\<Space>x" "' x'"
|
||||
let g:delimitMate_expand_inside_quotes = 1
|
||||
"'\<Space>x" "' x '"
|
||||
"'\<Space>\<BS>x" "'x'"
|
||||
"abc\\''\<Space>x" "abc\\' x'"
|
||||
let g:delimitMate_autoclose = 0
|
||||
"''\<Space>\<BS>x" "'x'"
|
||||
let g:delimitMate_autoclose = 1
|
||||
# Handle backspace gracefully.
|
||||
set backspace=
|
||||
"'\<Esc>a\<BS>x" "'x'"
|
||||
set backspace=2
|
||||
set cpo=ces$
|
||||
"'x" "'x'"
|
||||
# Make sure smart quote works beyond first column.
|
||||
" 'x" " 'x'"
|
||||
# smart quote, check fo char on the right.
|
||||
"a\<space>b\<left>'" "a 'b"
|
||||
# Make sure we jump over a quote on the right. #89.
|
||||
"('test'x" "('test'x)"
|
||||
# Duplicate whole line when inserting quote at bol #105
|
||||
"}\<Home>'" "''}"
|
||||
"'\<Del>abc '" "'abc '"
|
||||
"''abc '" "''abc ''"
|
||||
# Nesting quotes:
|
||||
let g:delimitMate_nesting_quotes = split(g:delimitMate_quotes, '\s\+')
|
||||
"'''x" "'''x'''"
|
||||
"''''x" "''''x''''"
|
||||
"''x" "''x"
|
||||
"'x" "'x'"
|
||||
unlet g:delimitMate_nesting_quotes
|
||||
# expand iabbreviations
|
||||
iabb def ghi
|
||||
"def'" "ghi'"
|
||||
let g:delimitMate_smart_quotes = '\w\%#\_.'
|
||||
"xyz'x" "xyz'x"
|
||||
"xyz 'x" "xyz 'x'"
|
||||
let g:delimitMate_smart_quotes = '\s\%#\_.'
|
||||
"abc'x" "abc'x'"
|
||||
"abc 'x" "abc 'x"
|
||||
# let's try the negated form
|
||||
let g:delimitMate_smart_quotes = '!\w\%#\_.'
|
||||
"cba'x" "cba'x'"
|
||||
"cba 'x" "cba 'x"
|
||||
let g:delimitMate_smart_quotes = '!\s\%#\_.'
|
||||
"zyx'x" "zyx'x"
|
||||
"zyx 'x" "zyx 'x'"
|
||||
unlet g:delimitMate_smart_quotes
|
||||
"'\<CR>\<BS>" "''"
|
||||
47
test/autoclose_quotes.vim
Normal file
47
test/autoclose_quotes.vim
Normal file
@@ -0,0 +1,47 @@
|
||||
"let g:delimitMate_quotes = '" '' ` ” « |'
|
||||
let g:delimitMate_quotes = '" '' ` « |'
|
||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||
call vimtest#StartTap()
|
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||
let itemsnumber = len(split(g:delimitMate_quotes, ' '))
|
||||
call vimtap#Plan(testsnumber * itemsnumber)
|
||||
let reload = 1
|
||||
let tcount = 1
|
||||
let linenr = 0
|
||||
for item in lines
|
||||
let linenr += 1
|
||||
if item =~ '^#\|^\s*$'
|
||||
" A comment or empty line.
|
||||
continue
|
||||
endif
|
||||
if item !~ '^"'
|
||||
" A command.
|
||||
exec item
|
||||
call vimtap#Diag(item)
|
||||
let reload = 1
|
||||
continue
|
||||
endif
|
||||
if reload
|
||||
DelimitMateReload
|
||||
call vimtap#Diag('DelimitMateReload')
|
||||
let reload = 0
|
||||
endif
|
||||
let quotes = split(g:delimitMate_quotes, '\s')
|
||||
for quote in quotes
|
||||
if vimtap#Skip(1, tcount != 26, "This test is invalid for double quote.")
|
||||
let tcount += 1
|
||||
continue
|
||||
endif
|
||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||
let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||
let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||
%d
|
||||
exec 'normal i'.eval(input_q)."\<Esc>"
|
||||
if quote == '”'
|
||||
call vimtap#Todo(1)
|
||||
endif
|
||||
call vimtap#Is(getline('.'), eval(output_q), 'Line '.linenr.': '.eval(substitute(input_q, '\\<', '<','g')))
|
||||
let tcount += 1
|
||||
endfor
|
||||
endfor
|
||||
call vimtest#Quit()
|
||||
44
test/eol_marker.vim
Normal file
44
test/eol_marker.vim
Normal file
@@ -0,0 +1,44 @@
|
||||
let g:delimitMate_expand_cr = 1
|
||||
let g:delimitMate_eol_marker = ';'
|
||||
call vimtest#StartTap()
|
||||
call vimtap#Plan(8)
|
||||
" NOTE: Do not forget to update the plan ^
|
||||
let g:delimitMate_insert_eol_marker = 0
|
||||
DelimitMateReload
|
||||
normal i(
|
||||
call vimtap#Is(getline(1), '()', 'value = 1, case 1')
|
||||
%d _
|
||||
exec "normal i(\<CR>x"
|
||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||
\ '^(\n\s*x\n)$', ' "normal i(\<CR>x", Value = 2, case 2')
|
||||
let g:delimitMate_insert_eol_marker = 1
|
||||
DelimitMateReload
|
||||
%d _
|
||||
normal i(
|
||||
call vimtap#Is(getline(1), '();', '"normal i(", value = 1, case 1')
|
||||
%d _
|
||||
exec "normal i(\<CR>x"
|
||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||
%d _
|
||||
let g:delimitMate_insert_eol_marker = 2
|
||||
DelimitMateReload
|
||||
normal i(
|
||||
call vimtap#Is(getline(1), '()', '"normal i(", Value = 2, case 1')
|
||||
%d _
|
||||
exec "normal i(\<CR>x"
|
||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||
|
||||
%d _
|
||||
exec "normal i{(\<CR>x"
|
||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 3')
|
||||
|
||||
%d _
|
||||
exec "normal i;\<Esc>I{(\<CR>x"
|
||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 4')
|
||||
|
||||
" End: quit vim.
|
||||
call vimtest#Quit()
|
||||
96
test/expand_cr.txt
Normal file
96
test/expand_cr.txt
Normal file
@@ -0,0 +1,96 @@
|
||||
#
|
||||
%d
|
||||
filetype indent on
|
||||
set bs=2 et sts=4 sw=4 ft=javascript
|
||||
call setline(1, '$(document).ready(function() {})')
|
||||
DelimitMateReload
|
||||
exec "normal 31|i\<CR>x\<Esc>"
|
||||
================================================================================
|
||||
$(document).ready(function() {
|
||||
x
|
||||
})
|
||||
--------------------------------------------------------------------------------
|
||||
# Issue #95
|
||||
new
|
||||
let b:delimitMate_jump_expansion = 1
|
||||
DelimitMateReload
|
||||
exec "normal i(\<CR>test)x"
|
||||
================================================================================
|
||||
(
|
||||
test
|
||||
)x
|
||||
--------------------------------------------------------------------------------
|
||||
# Remove CR expansion on BS
|
||||
%d
|
||||
exec "normal i(\<CR>\<BS>x"
|
||||
================================================================================
|
||||
(x)
|
||||
--------------------------------------------------------------------------------
|
||||
# Consider indentation with BS inside an empty CR expansion.
|
||||
%d
|
||||
exec "normal i( \<CR>\<BS>\<BS>x"
|
||||
================================================================================
|
||||
(x)
|
||||
--------------------------------------------------------------------------------
|
||||
# Conflict with indentation settings (cindent). Issue #95
|
||||
se cindent
|
||||
call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}'])
|
||||
call cursor(3, 8)
|
||||
normal a}x
|
||||
================================================================================
|
||||
sub foo {
|
||||
while (1) {
|
||||
|
||||
}x
|
||||
}
|
||||
--------------------------------------------------------------------------------
|
||||
%d
|
||||
call setline(1, '"{bracketed}')
|
||||
normal A"x
|
||||
================================================================================
|
||||
"{bracketed}"x
|
||||
--------------------------------------------------------------------------------
|
||||
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
||||
# with :normal
|
||||
new
|
||||
autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
|
||||
autocmd InsertLeave * let &foldmethod = w:fdm
|
||||
set foldmethod=marker
|
||||
set foldmarker={,}
|
||||
set foldlevel=0
|
||||
set backspace=2
|
||||
exec "normal iabc {\<CR>x"
|
||||
================================================================================
|
||||
abc {
|
||||
x
|
||||
}
|
||||
--------------------------------------------------------------------------------
|
||||
# expand_cr != 2
|
||||
%d_
|
||||
call setline(1, 'abc(def)')
|
||||
exec "normal $i\<CR>x"
|
||||
================================================================================
|
||||
abc(def
|
||||
x)
|
||||
--------------------------------------------------------------------------------
|
||||
# expand_cr == 2
|
||||
%d_
|
||||
let delimitMate_expand_cr = 2
|
||||
DelimitMateReload
|
||||
call setline(1, 'abc(def)')
|
||||
exec "normal $i\<CR>x"
|
||||
================================================================================
|
||||
abc(def
|
||||
x
|
||||
)
|
||||
--------------------------------------------------------------------------------
|
||||
# Play nice with smartindent
|
||||
%d_
|
||||
set all&
|
||||
set smartindent
|
||||
exec "normal $i{\<CR>x"
|
||||
================================================================================
|
||||
{
|
||||
x
|
||||
}
|
||||
--------------------------------------------------------------------------------
|
||||
55
test/expand_cr.vim
Normal file
55
test/expand_cr.vim
Normal file
@@ -0,0 +1,55 @@
|
||||
let g:delimitMate_expand_cr = 1
|
||||
"DelimitMateReload
|
||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||
call vimtest#StartTap()
|
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
|
||||
call vimtap#Plan(testsnumber)
|
||||
let tcount = 1
|
||||
let expect = 0
|
||||
let evaluate = 0
|
||||
let commands = []
|
||||
let header = ''
|
||||
for item in lines
|
||||
if item =~ '^=\{80}$'
|
||||
let expect = 1
|
||||
let expected = []
|
||||
continue
|
||||
endif
|
||||
|
||||
if item =~ '^#' && expect == 0
|
||||
" A comment.
|
||||
let header = empty(header) ? item[1:] : 'Lines should match.'
|
||||
continue
|
||||
endif
|
||||
if item =~ '^\s*$' && expect == 0
|
||||
" An empty line.
|
||||
continue
|
||||
endif
|
||||
if ! expect
|
||||
" A command.
|
||||
call add(commands, item)
|
||||
exec item
|
||||
"call vimtap#Diag(item)
|
||||
continue
|
||||
endif
|
||||
if item =~ '^-\{80}$'
|
||||
let expect = 0
|
||||
endif
|
||||
if expect
|
||||
call add(expected, item)
|
||||
continue
|
||||
endif
|
||||
let lines = getline(1, line('$'))
|
||||
let passed = lines == expected
|
||||
echom string(lines)
|
||||
echom string(expected)
|
||||
call vimtap#Is(lines, expected, header)
|
||||
echom string(commands)
|
||||
for cmd in commands
|
||||
call vimtap#Diag(cmd)
|
||||
endfor
|
||||
let commands = []
|
||||
let header = ''
|
||||
let tcount += 1
|
||||
endfor
|
||||
call vimtest#Quit()
|
||||
8
test/expand_space.txt
Normal file
8
test/expand_space.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
# Issue #95
|
||||
new
|
||||
let b:delimitMate_jump_expansion = 1
|
||||
DelimitMateReload
|
||||
exec "normal i( test)x"
|
||||
================================================================================
|
||||
( test )x
|
||||
--------------------------------------------------------------------------------
|
||||
42
test/expand_space.vim
Normal file
42
test/expand_space.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
let g:delimitMate_expand_space = 1
|
||||
"DelimitMateReload
|
||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||
call vimtest#StartTap()
|
||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
|
||||
call vimtap#Plan(testsnumber)
|
||||
let tcount = 1
|
||||
let expect = 0
|
||||
let evaluate = 0
|
||||
for item in lines
|
||||
if item =~ '^=\{80}$'
|
||||
let expect = 1
|
||||
let expected = []
|
||||
continue
|
||||
endif
|
||||
|
||||
if item =~ '^#\|^\s*$' && expect == 0
|
||||
" A comment or empty line.
|
||||
continue
|
||||
endif
|
||||
if ! expect
|
||||
" A command.
|
||||
exec item
|
||||
call vimtap#Diag(item)
|
||||
continue
|
||||
endif
|
||||
if item =~ '^-\{80}$'
|
||||
let expect = 0
|
||||
endif
|
||||
if expect
|
||||
call add(expected, item)
|
||||
continue
|
||||
endif
|
||||
let lines = getline(1, line('$'))
|
||||
let passed = lines == expected
|
||||
echom string(lines)
|
||||
echom string(expected)
|
||||
call vimtap#Ok(passed, string(expected) .
|
||||
\ (passed ? ' =' : ' !') . '= ' . string(lines))
|
||||
let tcount += 1
|
||||
endfor
|
||||
call vimtest#Quit()
|
||||
8
test/first_buffer_no_ft.vim
Normal file
8
test/first_buffer_no_ft.vim
Normal file
@@ -0,0 +1,8 @@
|
||||
let g:delimitMate_expand_cr = 1
|
||||
let g:delimitMate_eol_marker = ';'
|
||||
call vimtest#StartTap()
|
||||
call vimtap#Plan(1)
|
||||
call vimtap#Like(maparg('(', 'i'), '<Plug>delimitMate(', 'Mappings defined for the first buffer without filetype set.')
|
||||
call vimtest#Quit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user