61 Commits
2.7 ... rewrite

Author SHA1 Message Date
Israel Chauca Fuentes
22e6272b1a Migrate testing to tcltest + expect 2017-04-12 15:58:49 -04:00
Israel Chauca Fuentes
c4d51a21b3 Refactor pairs handling 2017-04-01 18:14:12 -04:00
Israel Chauca Fuentes
9ec998e87a Rewrite s:keys4right() 2017-03-20 22:49:37 -04:00
Israel Chauca Fuentes
0246f25de8 Some cleanup 2017-03-15 03:11:38 -04:00
Israel Chauca Fuentes
1eafd59b9c Quick fixes 2017-02-21 22:11:52 -05:00
Israel Chauca Fuentes
4eaeef01bf Fix problem with jumping over an existing closing delimiter. 2017-02-21 22:11:27 -05:00
Israel Chauca Fuentes
fb60f3cc9f Try to avoid breaking redo. 2017-02-21 22:09:40 -05:00
Israel Chauca Fuentes
e362f5a69d Add jump_over. Close #220. 2017-02-14 14:59:19 -05:00
Israel Chauca Fuentes
c97a824ed4 Do not jump over next delimiter when unbalanced pairs. Close #229. 2017-02-14 14:59:18 -05:00
Israel Chauca Fuentes
37122299b7 Add license. Close #247. 2017-02-14 14:59:17 -05:00
Israel Chauca Fuentes
d882e342f7 Add :DMDebug 2017-02-14 14:59:08 -05:00
Israel Chauca Fuentes
b1ff7f7942 Simplify expand_cr a bit and add some to do tests 2017-02-13 12:12:12 -05:00
Israel Chauca Fuentes
e48ea9f852 Allow jumping over quote on the right if in ignored syntax group 2017-02-12 23:48:13 -05:00
Israel Chauca Fuentes
cb6866f1c3 Improve smart rules 2017-02-11 22:38:51 -05:00
Israel Chauca Fuentes
8204ab4cb8 Better handling of syntax regions 2017-02-11 22:38:13 -05:00
Israel Chauca Fuentes
6f038350de Reorder some tests and add modelines everywhere 2017-02-11 20:07:40 -05:00
Israel Chauca Fuentes
0f6581c6f3 Add insert_eol_marker 2017-02-11 19:13:09 -05:00
Israel Chauca Fuentes
7752546515 Add jump_expansion 2017-02-11 17:55:03 -05:00
Israel Chauca Fuentes
7809c5e171 Add expand_cr 2017-02-11 11:11:17 -05:00
Israel Chauca Fuentes
b6cc751cc9 Rename some things. 2017-02-10 22:59:22 -05:00
Israel Chauca Fuentes
24cffe07b3 Consider that double quotes start comments in viml 2017-02-10 21:13:45 -05:00
Israel Chauca Fuentes
6fddbc5568 Add jump_expansion 2017-02-10 19:55:02 -05:00
Israel Chauca Fuentes
015e0efe53 Add expand_inside_quotes and fix a nesting problem. 2017-02-10 14:25:52 -05:00
Israel Chauca Fuentes
03a0e5d8b3 Simplify the format of the tests. 2017-02-10 00:32:17 -05:00
Israel Chauca Fuentes
d970ecc4ca Prevent recursive nesting of quotes in tests. 2017-02-10 00:30:23 -05:00
Israel Chauca Fuentes
353fb9a718 Sort things a bit. 2017-02-10 00:29:30 -05:00
Israel Chauca Fuentes
4d0060f22b Add support for quotes and a couple of other things. 2017-02-09 12:59:33 -05:00
Israel Chauca Fuentes
65016ebe37 Implement balance_pairs 2017-02-07 00:52:01 -05:00
Israel Chauca Fuentes
85d76972e6 Implement smart pairs. 2017-02-06 00:28:48 -05:00
Israel Chauca Fuentes
c4b5877958 Allow abbreviations to expand. 2017-02-06 00:25:44 -05:00
Israel Chauca Fuentes
2335c4ae27 Simplify makefiles. 2017-02-04 20:19:16 -05:00
Israel Chauca Fuentes
6f1a9d00af Implement autoclosingpairs. 2017-02-04 20:12:21 -05:00
Israel Chauca Fuentes
b99ecfa2e3 Simplify tests. 2017-01-23 20:40:55 -05:00
Israel Chauca Fuentes
50d97fd76e Simplify pattern 2015-09-11 09:18:12 -04:00
Israel Chauca Fuentes
8bc47fd1c4 Merge pull request #227 from wellle/fix-repeat-and-undo
Fix repeat and undo
2015-09-07 14:58:42 -04:00
Christian Wellenbrock
bc97837c71 Don't break undo sequence when moving in insert mode
Since Vim version 7.4.849 [1] we can move in insert mode without
breaking the undo sequence by inserting <C-G>U before the movement key.

Add s:joinUndo which returns "\<C-G>U" if available.
Use s:joinUndo before doing any <Left> or <Right> movements in insert
mode to keep a single undo point which can be repeated and undone
with a single command.

[1] https://github.com/vim/vim/releases/tag/v7.4.849
2015-09-06 15:42:30 +02:00
Israel Chauca Fuentes
d24ad6b301 Merge pull request #210 from codebeige/fix_expand_cr_for_excluded_ft
Prevent errors inside excluded filetype
2015-05-18 13:24:02 -04:00
Israel Chauca Fuentes
81de76fe52 Update help. 2015-05-17 19:42:50 -04:00
Israel Chauca Fuentes
5945fdfd14 Consider more characters in smart_matchpairs default value. 2015-05-17 19:34:11 -04:00
Israel Chauca Fuentes
9a77c3aee6 Merge branch 'RGBD-fix-maparg-typo' 2015-05-01 22:35:56 -04:00
Oleg Zubchenko
342a04b427 fix maparg typo 2015-04-27 21:11:57 +03:00
Tibor Claassen
03e94587ae Add a guard clause to disable expansion for excluded filetypes 2015-03-28 15:48:40 +02:00
Israel Chauca Fuentes
c78a6e6d93 Allow using commas and colons in matchpairs. Fix #208. 2015-02-12 09:09:48 -05:00
Israel Chauca Fuentes
470c053a3b Better handling of insert_eol_marker. Should fix #195. 2015-01-17 14:03:48 -05:00
Israel Chauca Fuentes
254a89d67c Call s:setup() directly in the plugin. Should fix #202.
- Move 'call s:setup()' out of the autocmd.
- Add a test for the first buffer without filetype set.
2015-01-15 11:21:09 -05:00
Israel Chauca Fuentes
e7b4dedb84 Add option delimitMate_insert_eol_marker. Closes #195. 2015-01-08 17:14:27 -05:00
Israel Chauca Fuentes
21a3ade90c Use s:get() and s:set() instead of the abbreviated forms. 2015-01-06 08:50:17 -05:00
Israel Chauca Fuentes
8e30e70bcd Refactor reporting code. 2015-01-05 02:16:09 -05:00
Israel Chauca Fuentes
ac792c01b6 Indent with spaces. 2015-01-04 20:25:50 -05:00
Israel Chauca Fuentes
c23ef684e3 Add :DelimitMateOn, :DelimitMateOff & remove s:DelimitMateSwitch(). 2015-01-04 20:13:11 -05:00
Israel Chauca Fuentes
b63924f2b2 Update doc. 2015-01-04 20:09:00 -05:00
Israel Chauca Fuentes
07b7cc969f Merge pull request #201 from kballard/mappings-user-event
Add 2 User events when mapping and unmapping
2015-01-02 20:32:18 -05:00
Israel Chauca Fuentes
13e52d42ae Do not consider quotes for smart_matchpairs. Closes #200. 2015-01-02 12:08:16 -05:00
Israel Chauca Fuentes
aa9d737763 Rename functions. 2015-01-02 12:07:31 -05:00
Daniel Hahler
bf2b68edab Remove call to s:option_init("excluded_ft"): it is a global setting only 2015-01-01 14:58:41 -05:00
Israel Chauca Fuentes
fe9022433d Use :unlet only when necessary. 2015-01-01 09:41:32 -05:00
Israel Chauca Fuentes
6f7e6413ce Fix doco. 2014-12-30 21:02:44 -05:00
Kevin Ballard
a9a37854da Minor documentation tweaks
Fix a typo in a hyperlink, and change the sample code for
delimitMate#JumpAny() to use an <expr> mapping instead of <C-R>=.
2014-12-29 19:33:24 -08:00
Kevin Ballard
0739792d01 Add 2 User events when mapping and unmapping
delimitMate has some nice logic for doing per-filetype mappings, but
this logic can't be used when users provide mappings directly. To remedy
this, add two User events `delimitMate_map` and `delimitMate_unmap` that
are fired at the appropriate times. Users can use these events to define
per-filetype mappings just as delimitMate does.
2014-12-29 19:33:15 -08:00
Kevin Ballard
6f4f1b06d3 Be more conservative about unmapping
Restrict unmapping to check for '^<Plug>delimitMate' (case sensitive)
instead of 'delimitMate' (case insensitive). This should make it less
likely to accidentally trigger on custom user keybinds that reference
delimitMate.
2014-12-29 18:37:51 -08:00
Israel Chauca Fuentes
0049b07a1c Fix Makefile and gitignore. 2014-12-03 17:06:37 -05:00
24 changed files with 1312 additions and 1566 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
*.sw?
*.un?
*.vba
*.vmb
*.zip
*.gz
vimball.txt

21
LICENSE.txt Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Israel Chauca
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,82 +1,15 @@
PLUGIN = $(wildcard plugin/*.vim)
SOURCES = $(PLUGIN)
LIB = $(wildcard autoload/*.vim)
SOURCES += $(LIB)
DOC = $(wildcard doc/*.txt)
SOURCES += $(DOC)
#NAME = $(shell basename "$$PWD")
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)
.DEFAULT: test
.PHONY: version clean distclean undo release test install uninstall
test_files := $(wildcard test/*.test)
short_targets := $(patsubst test/%,%,$(test_files))
all: zip gzip
dist: version all
vimball: $(FILENAME).vmb
zip: $(FILENAME).zip $(FILENAME).vmb.zip
gzip: $(FILENAME).tar.gz $(FILENAME).vmb.gz
clean:
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
distclean: clean
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile)'
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile)*'
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)
.PHONY: monitor test $(test_files) $(short_targets)
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;
monitor:
$(MAKE) -C test monitor
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
$(test_files) $(short_targets):
$(MAKE) -C test $(patsubst test/%,%,$@)

File diff suppressed because it is too large Load Diff

View File

@@ -34,10 +34,11 @@
4. Commands________________________________|delimitMateCommands|
5. Mappings________________________________|delimitMateMappings|
6. Functions_______________________________|delimitMateFunctions|
7. TODO list_______________________________|delimitMateTodo|
8. Maintainer______________________________|delimitMateMaintainer|
9. Credits_________________________________|delimitMateCredits|
10. History_________________________________|delimitMateHistory|
7. Autocommands____________________________|delimitMateAutocmds|
8. TODO list_______________________________|delimitMateTodo|
9. Maintainer______________________________|delimitMateMaintainer|
10. Credits_________________________________|delimitMateCredits|
11. History_________________________________|delimitMateHistory|
==============================================================================
1.- INTRODUCTION *delimitMateIntro*
@@ -60,7 +61,7 @@ the go.
2. CUSTOMIZATION *delimitMateOptions*
You can create your own mappings for some features using the global functions.
Read |DelimitMateFunctions| for more info.
Read |delimitMateFunctions| for more info.
------------------------------------------------------------------------------
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
@@ -265,7 +266,7 @@ e.g.: >
*'delimitMate_smart_matchpairs'*
*'b:delimitMate_smart_matchpairs'*
Values: Regexp ~
Default: '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)' ~
Default: '^\%(\w\|\!\|[£$]\|[^[:space:][:punct:]]\)' ~
This regex is matched against the text to the right of cursor, if it's not
empty and there is a match delimitMate will not autoclose the pair. At the
@@ -308,6 +309,21 @@ only if you don't want any of the features it provides on those file types.
e.g.: >
let delimitMate_excluded_ft = "mail,txt"
<
------------------------------------------------------------------------------
*'delimitMate_insert_eol_marker'*
Values: Integer ~
Default: 1 ~
Whether to insert the eol marker (EM) or not. The EM is inserted following
rules:
0 -> never
1 -> when inserting any matchpair
2 -> when expanding car return in matchpair
e.g.: >
au FileType c,perl let b:delimitMate_insert_eol_marker = 2
<
------------------------------------------------------------------------------
*'delimitMate_eol_marker'*
Values: String. ~
@@ -547,6 +563,16 @@ know about it.
Re-sets all the mappings used for this script, use it if any option has been
changed or if the filetype option hasn't been set yet.
------------------------------------------------------------------------------
:DelimitMateOn *:DelimitMateOn*
Enable delimitMate mappings.
------------------------------------------------------------------------------
:DelimitMateOff *:DelimitMateOff*
Disable delimitMate mappings.
------------------------------------------------------------------------------
:DelimitMateSwitch *:DelimitMateSwitch*
@@ -669,7 +695,7 @@ Returns 1 if the cursor is inside an empty pair, 0 otherwise.
e.g.: >
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
\ "<Plug>delimitMateCR" :
\ "external_mapping"
<
@@ -686,17 +712,50 @@ This function returns a mapping that will make the cursor jump to the right
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.
>
inoremap <C-Tab> <C-R>=delimitMate#JumpAny()<CR>
inoremap <expr> <C-Tab> delimitMate#JumpAny()
<
==============================================================================
7. AUTOCOMMANDS *delimitMateAutocmds*
delimitMate emits 2 |User| autocommands to make it easier for users to
leverage delimitMate's support for per-filetype customization.
------------------------------------------------------------------------------
delimitMate_map *delimitMate_map*
This |User| event is emittted just prior to delimitMate defining its
buffer-local key mappings. You can use this command to define your own
mappings that are disabled when delimitMate is turned off or excludes the
current filetype.
>
au User delimitMate_map call s:delimitMate_map()
function s:delimitMate_map()
imap <buffer><expr> <C-Tab> delimitMate#JumpAny()
endfunction
<
------------------------------------------------------------------------------
delimitMate_unmap *delimitMate_unmap*
This |User| event is emitted just after delimitMate clears its buffer-local
key mappings. You can use this command to clear your own mappings that you set
in response to |delimitMate_map|.
>
au User delimitMate_unmap call s:delimitMate_unmap()
function s:delimitMate_unmap()
silent! iunmap <buffer> <C-Tab>
endfunction
<
Note: This event may be emitted before |delimitMate_map|, and may be emitted
multiple times in a row without any intervening |delimitMate_map| events.
==============================================================================
7. TODO LIST *delimitMateTodo*
8. TODO LIST *delimitMateTodo*
- Automatic set-up by file type.
- Make block-wise visual wrapping work on un-even regions.
==============================================================================
8. MAINTAINER *delimitMateMaintainer*
9. MAINTAINER *delimitMateMaintainer*
Hi there! My name is Israel Chauca F. and I can be reached at:
mailto:israelchauca@gmail.com
@@ -705,7 +764,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
be very pleased to read them.
==============================================================================
9. CREDITS *delimitMateCredits*
10. CREDITS *delimitMateCredits*
Contributors: ~
@@ -741,12 +800,14 @@ copied from the following sources:
This script was inspired by the auto-completion of delimiters on TextMate.
==============================================================================
10. HISTORY *delimitMateHistory*
11. HISTORY *delimitMateHistory*
Version Date Release notes ~
|---------|------------|-----------------------------------------------------|
2.7 2013-07-15 * Current release:
- Lots of bug fixes.
2.8 2013-07-15 * Current release:
- Add :DelimitMateOn & :DelimitMateOff.
|---------|------------|-----------------------------------------------------|
2.7 2013-07-15 * - Lots of bug fixes.
- Add delimitMate_offByDefault.
- Add delimitMate_eol_marker.
- Reduce the number of mappings.

View File

@@ -1,399 +1,22 @@
" 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".
" ============================================================================
" Initialization: {{{
if exists("g:loaded_delimitMate") || &cp
" User doesn't want this plugin or compatible is set, let's get out!
finish
if exists("g:loaded_delimitMate") || &cp || !exists('##InsertCharPre')
finish
endif
let g:loaded_delimitMate = 1
let save_cpo = &cpo
set cpo&vim
if v:version < 700
echoerr "delimitMate: this plugin requires vim >= 7!"
finish
endif
let s:loaded_delimitMate = 1
let delimitMate_version = "2.7"
function! s:option_init(name, default) "{{{
let b = exists("b:delimitMate_" . a:name)
let g = exists("g:delimitMate_" . a:name)
" Find value to use.
if !b && !g
let value = a:default
elseif b
exec "let value = b:delimitMate_" . a:name
else
exec "let value = g:delimitMate_" . a:name
endif
call s:s(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:g('matchpairs'), ','), 'split(v:val, '':'')'))
let pairs = s:g('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:g('matchpairs_list')), 'v:val[0]'))
call s:option_init("right_delims", map(copy(s:g('matchpairs_list')), 'v:val[1]'))
" quotes
call s:option_init("quotes", "\" ' `")
call s:option_init("quotes_list",split(s:g('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:g('excluded_regions'), ',\s*'))
let enabled = len(s:g('excluded_regions_list')) > 0
call s:option_init("excluded_regions_enabled", enabled)
" excluded filetypes
call s:option_init("excluded_ft", "")
" 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\|\!\|£\|\$\|_\|["'']\s*\S\)')
" smart_quotes
" XXX: backward compatibility. Ugly, should go the way of the dodo soon.
let quotes = escape(join(s:g('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:g('apostrophes'), ":\s*"))
" tab2exit
call s:option_init("tab2exit", 1)
" balance_matchpairs
call s:option_init("balance_matchpairs", 0)
" eol marker
call s:option_init("eol_marker", "")
" Everything is fine.
return 1
endfunction "}}} Init()
"}}}
" Functions: {{{
function! s:g(...) " {{{
return call('delimitMate#Get', a:000)
endfunction " }}}
function! s:s(...) " {{{
return call('delimitMate#Set', a:000)
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
if s:g('autoclose')
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
let b:delimitMate_enabled = 1
endfunction "}}} Map()
function! s:Unmap() " {{{
let imaps =
\ s:g('right_delims', []) +
\ s:g('left_delims', []) +
\ s:g('quotes_list', []) +
\ s:g('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") =~? 'delimitMate'
if map == '|'
let map = '<Bar>'
endif
exec 'silent! iunmap <buffer> ' . map
endif
endfor
let b:delimitMate_enabled = 0
endfunction " }}} s:Unmap()
function! s:TestMappingsDo() "{{{
if &modified
let confirm = input("Modified buffer, type \"yes\" to write and proceed "
\ . "with test: ") ==? 'yes'
if !confirm
return
endif
endif
call delimitMate#TestMappings()
g/\%^$/d
0
endfunction "}}}
function! s:DelimitMateDo(...) "{{{
" First, remove all magic, if needed:
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
call s:Unmap()
endif
" 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
" Initialize settings:
if ! s:init()
" Something went wrong.
return
endif
" Now, add magic:
if !exists("g:delimitMate_offByDefault") || !g:delimitMate_offByDefault
call s:Map()
endif
if a:0 > 0
echo "delimitMate has been reset."
endif
endfunction "}}}
function! s:DelimitMateSwitch() "{{{
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
call s:Unmap()
echo "delimitMate has been disabled."
else
call s:Unmap()
call s:init()
call s:Map()
echo "delimitMate has been enabled."
endif
endfunction "}}}
"}}}
" Mappers: {{{
function! s:TriggerAbb() "{{{
if v:version < 703
\ || ( v:version == 703 && !has('patch489') )
\ || pumvisible()
return ''
endif
return "\<C-]>"
endfunction "}}}
function! s:NoAutoClose() "{{{
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
for delim in s:g('right_delims') + s:g('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 <silent> <buffer> ( ()<Left>
let i = 0
while i < len(s:g('matchpairs_list'))
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i]
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('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
" Exit from inside the matching pair:
for delim in s:g('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
" 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:g('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 (kept for backward compatibility):
" inoremap <silent> <buffer> n't n't
for map in s:g('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 <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
if !hasmapto('<Plug>delimitMateBS','i')
if maparg('<BS>'. 'i') == ''
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
endif
if 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:g('expand_cr') && !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:g('expand_space') && !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:g('tab2exit') && !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 "}}}
"}}}
" Commands: {{{
call s:DelimitMateDo()
" Let me refresh without re-loading the buffer:
command! -bar DelimitMateReload call s:DelimitMateDo(1)
" Quick test:
command! -bar DelimitMateTest call s:TestMappingsDo()
" Switch On/Off:
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
"}}}
" Autocommands: {{{
command! -bar -bang DelimitMateSwitch call delimitMate#ex_cmd(<bang>0, 'switch' )
command! -bar -bang DelimitMateOn call delimitMate#ex_cmd(<bang>0, 'enable' )
command! -bar -bang DelimitMateOff call delimitMate#ex_cmd(<bang>0, 'disable')
augroup delimitMate
au!
" Run on file type change.
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
autocmd FileType * call <SID>DelimitMateDo()
" Run on new buffers.
autocmd BufNewFile,BufRead,BufEnter *
\ if !exists('b:delimitMate_was_here') |
\ call <SID>DelimitMateDo() |
\ let b:delimitMate_was_here = 1 |
\ endif
au!
au InsertCharPre * call delimitMate#InsertCharPre(v:char)
au TextChangedI * call delimitMate#TextChangedI()
au InsertEnter * call delimitMate#InsertEnter()
au CursorMovedI * call delimitMate#CursorMovedI()
augroup END
"}}}
let &cpo = save_cpo
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
" vim: sw=2 et

View File

@@ -1,9 +1,14 @@
all: build/runVimTests
build/runVimTests/bin/runVimTests.sh -0 .
test_files := $(wildcard *.test)
build/runVimTests: build/VimTAP
git clone https://github.com/inkarkat/runVimTests $@
.PHONY: all monitor $(test_files)
# Use VimTAP as directory name, as used with runVimTestsSetup.vim.
build/VimTAP:
git clone https://github.com/inkarkat/vimtap $@
all:
time tclsh all.tcl
$(test_files):
time tclsh $@
printf "\a"
monitor:
fswatch -o ../autoload/*.vim ../plugin/*.vim *.test \
| xargs -n1 -I\{\} time tclsh all.tcl || printf "\a"

View File

@@ -1,12 +1,11 @@
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
set bs=2
set hidden
set noshowmode
set whichwrap=[]
set noswapfile
let &hl = join(map(split(&hl, ','), 'substitute(v:val, '':.\+'', ''n'', ''g'')'), ',')
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
let g:delimitMate_pairs = ['()','{}','[]','<>','¿?','¡!',',:']
let g:delimitMate_quotes = ['"', "'", '`', '«', '|']
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
au VimEnter * echom 'Start test'

18
test/all.tcl Normal file
View File

@@ -0,0 +1,18 @@
package require tcltest 2
namespace import -force ::tcltest::*
configure {*}$argv -testdir [file dir [info script]]
# Hook to determine if any of the tests failed. Then we can exit with
# proper exit code: 0=all passed, 1=one or more failed
proc tcltest::cleanupTestsHook {} {
variable numTests
upvar 2 testFileFailures crashed
set ::exitCode [expr {$numTests(Failed) > 0}]
if {[info exists crashed]} {
set ::exitCode [expr {$::exitCode || [llength $crashed]}]
}
}
runAllTests
puts "\a"
exit $exitCode

View File

@@ -1,41 +0,0 @@
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()"

View File

@@ -1,42 +0,0 @@
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, ','))
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, ','), 'split(v:val, ":")')
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()

View File

@@ -1,73 +0,0 @@
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>" "''"

View File

@@ -1,47 +0,0 @@
"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()

49
test/eol_marker.test Normal file
View File

@@ -0,0 +1,49 @@
# singleTest name desc setup input result vimCmds? skipScript?
#
# - desc can be empty and input would be used.
# - vimCmds is a list of ex commands.
# - skipScript will be evaluated in the scope of the function "single" and it
# should return a keywowd such as toDo, badTest or other as listed in the
# docs for tcltest. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
# Get some help:
source helper.tcl
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
lappend vimCmds {let g:delimitMate_insert_eol_marker = 0}
single ins_eol_marker_0-1 {} "" "i(" "()" ${vimCmds}
single ins_eol_marker_0-2 {} "" "i(\rx" "(\nx\n)" ${vimCmds}
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
lappend vimCmds {let g:delimitMate_insert_eol_marker = 1}
single ins_eol_marker_1-1 {} "" "i(" "();" ${vimCmds}
single ins_eol_marker_1-2 {} " a" "0i(" "() a" ${vimCmds}
single ins_eol_marker_1-3 {} "" "i(\rx" "(\nx\n);" ${vimCmds}
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {let g:delimitMate_eol_marker = ';'}
lappend vimCmds {let g:delimitMate_insert_eol_marker = 2}
single ins_eol_marker_2-1 {} "" "i(" "()" ${vimCmds}
single ins_eol_marker_2-2 {} "" "i(\rx" "(\nx\n);" ${vimCmds}
# Issue #195
single issue_195-1 {} "" "i{(\rx" "{(\nx\n)}" ${vimCmds}
# Issue #195
single issue_195-2 {} ";" "I{(\rx" "{(\nx\n)};" ${vimCmds}
################################################################
# This gives nice statistics and cleans up the mess left behind.
cleanupTests
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

92
test/expand_cr.test Normal file
View File

@@ -0,0 +1,92 @@
# singleTest name desc setup input result vimCmds? skipScript?
#
# - desc can be empty and input would be used.
# - vimCmds is a list of ex commands.
# - skipScript will be evaluated in the scope of the function "single" and it
# should return a keywowd such as toDo, badTest or other as listed in the
# docs for tcltest. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
# Get some help:
source helper.tcl
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
#"let g:delimitMate_eol_marker = ';'
lappend vimCmds {filetype indent on}
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
single javascript-1 {} "\$(document).ready(function() {})" "f{a\rx" \
"\$(document).ready(function() {\n x\n})" ${vimCmds}
# Issue #95
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
set skipScript {string cat toDo}
single issue_95 {} "" "i(\rtest)x" "(\ntest\n)x" ${vimCmds} ${skipScript}
# Remove CR expansion on BS
set skipScript {string cat toDo}
single bs {} "" "i(\r\bx" "(x)" ${vimCmds} ${skipScript}
# Consider indentation with BS inside an empty CR expansion.
single bs_indentation {} "" "i( \r\b\bx" "(x)" ${vimCmds}
# Conflict with indentation settings (cindent). Issue #95
lappend vimCmds {se cindent}
single issue_95 {} "sub foo {\n while (1) {\n\n }\n}" "3Gi\bx" \
"sub foo {\n while (1) {x}\n}" ${vimCmds}
single nested_expansion-1 {} "sub foo {\n while (1) {\n bar\n }\n}" \
"3GA}x" "sub foo {\n while (1) {\n bar\n }x\n}" ${vimCmds}
single nested_expansion-2 {} "sub foo {\n while (1) {\n bar\n }\n}" \
"3GA{x" "sub foo {\n while (1) {\n bar{x}\n }\n}" ${vimCmds}
single bracketed {} "\"{bracketed}" "\033A\"x" "\"{bracketed}\"x" ${vimCmds}
# Syntax folding enabled by autocmd breaks expansion.
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {se cindent}
lappend vimCmds {set bs=2 et sts=4 sw=4}
lappend vimCmds {autocmd InsertEnter <buffer> let w:fdm=&foldmethod \
| setl foldmethod=manual}
lappend vimCmds {autocmd InsertLeave <buffer> let &foldmethod = w:fdm}
lappend vimCmds {set foldmethod=marker}
lappend vimCmds {set foldmarker={,}}
lappend vimCmds {set foldlevel=0}
lappend vimCmds {set backspace=2}
single folding {} "" "iabc {\rx" "abc {\n x\n}" ${vimCmds}
# expand_cr != 2}
set vimCmds [list {let g:delimitMate_expand_cr = 1}]
lappend vimCmds {se cindent}
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
single axpand_cr_no_2 {} "abc(def)" "\$i\rx" "abc(def\n x)" ${vimCmds}
# expand_cr == 2
set vimCmds [list {let g:delimitMate_expand_cr = 2}]
lappend vimCmds {se cindent}
lappend vimCmds {set bs=2 et sts=4 sw=4 ft=javascript}
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
single expand_cr_2 {} "abc(def)" "\$i\rx" "abc(def\n x\n )" ${vimCmds}
# Play nice with smartindent
set vimCmds [list {let g:delimitMate_expand_cr = 2}]
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
lappend vimCmds {set smartindent}
single smartindent-1 {} "" "i{\rx" "{\n x\n}" ${vimCmds}
single quotes-1 {} "" "i\" x" {" x"} ${vimCmds}
single quotes-2 {} "" "i\"\rx" "\"\nx\"" ${vimCmds}
lappend vimCmds {let g:delimitMate_expand_inside_quotes = 1}
single quotes-3 {} "" "i\"\nx" "\"\nx\n\"" ${vimCmds}
################################################################
# This gives nice statistics and cleans up the mess left behind.
cleanupTests
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

View File

@@ -1,96 +0,0 @@
#
%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
}
--------------------------------------------------------------------------------

View File

@@ -1,55 +0,0 @@
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()

48
test/expand_space.test Normal file
View File

@@ -0,0 +1,48 @@
# singleTest name desc setup input result vimCmds? skipScript?
#
# - desc can be empty and input would be used.
# - vimCmds is a list of ex commands.
# - skipScript will be evaluated in the scope of the function "single" and it
# should return a keywowd such as toDo, badTest or other as listed in the
# docs for tcltest. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
# Get some help:
source helper.tcl
set vimCmds [list {let g:delimitMate_expand_space = 1}]
lappend vimCmds {let g:delimitMate_autoclose = 1}
pairs pairs-1 {} "" "i( x" "( x )" ${vimCmds}
pairs pairs-2 {} "( )" "la\bx" "(x)" ${vimCmds}
pairs pairs-3 {} "" "iabc x" "abc x" ${vimCmds}
quotes quotes-1 {} "" "i' x" "' x'" ${vimCmds}
lappend vimCmds {let g:delimitMate_expand_inside_quotes = 1}
quotes quotes-2 {} "" "i' x" "' x '" ${vimCmds}
quotes quotes-3 {} "" "i' \bx" "'x'" ${vimCmds}
set skipScript {string cat quoteBug}
lappend vimCmds {let g:delimitMate_autoclose = 0}
quotes quotes-4 {} "abc\\" "A'' x" "abc\\'' x '" ${vimCmds} ${skipScript}
# Issue #95
lappend vimCmds {let b:delimitMate_jump_expansion = 1}
set skipScript {string cat toDo}
pairs issue_95 {} "" "i( test)x" "( test )x" ${vimCmds} ${skipScript}
pairs pairs-4 {} "" "i() \bx" "(x)" ${vimCmds}
quotes quotes-5 {} "" "i'' \bx" "'x'" ${vimCmds}
################################################################
# This gives nice statistics and cleans up the mess left behind.
cleanupTests
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

View File

@@ -1,8 +0,0 @@
# Issue #95
new
let b:delimitMate_jump_expansion = 1
DelimitMateReload
exec "normal i( test)x"
================================================================================
( test )x
--------------------------------------------------------------------------------

View File

@@ -1,42 +0,0 @@
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()

125
test/helper.tcl Normal file
View File

@@ -0,0 +1,125 @@
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import -force ::tcltest::*
}
configure -verbose {body error skip}
#configure -verbose {start msec pass body error skip}
set charMap [list \
"\"" "\\\"" \
"\$" "\\$" \
"\[" "\\\[" \
"\]" "\\\]" \
"\\" "\\\\" \
"{" "\\{" \
"}" "\\}" \
]
# In order to skip a test pass a script that, when evaluated, returns emptyTest
# for tests that can not pass, or knownBug for ToDo features. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
proc single {name desc setup input result \
{vimCmds {}} \
{constr {}} \
} {
set fnamePrefix "test_${name}"
global charMap
makeFile ${setup} "${fnamePrefix}.in"
makeFile {} "${fnamePrefix}.out"
makeFile [join ${vimCmds} "\n"] "${fnamePrefix}.vim"
set input [string map ${charMap} ${input}]
#puts [lindex ${vimCmds} 0]
set optCharMap [list {[} {\[} {]} {\]}]
set vimArgs [lmap option ${vimCmds} \
{string cat " -c \"[string map $charMap ${option}]\""}]
set body [string cat "
exec -- ./test.exp \"${fnamePrefix}\" \"${input}\"
return \[viewFile \"${fnamePrefix}.out\"\]
" ]
#puts ${body}
if {[string length ${desc}] eq 0} {
set desc ${input}
}
if {[string length ${constr}] ne 0} {
#puts ${constr}
set constr [eval ${constr}]
#puts ${constr}
}
set name "${name}: \"${setup}\", \"${desc}\" ->"
#puts $desc
#puts $name
test ${name} \
${desc} \
-body ${body} \
-constraints ${constr} \
-result ${result}
}
proc multi {items evalScript name desc setup input result \
{vimCmds {}} \
{constr {}} \
} {
global charMap
set minor 0
foreach item $items {
incr minor
eval ${evalScript}
foreach var {desc setup input result} {
set "the_${var}" [string map ${aCharMap} [expr "$${var}"]]
}
set the_name "${name}.${minor}"
single \
${the_name} \
${the_desc} \
${the_setup} \
${the_input} \
${the_result} \
${vimCmds} \
${constr} \
}
}
proc quotes {name desc setup input result \
{vimCmds {}} \
{constr {}} \
} {
set quotes [list {'} \" {`} {«} {|}]
set mapScript {set aCharMap [list "'" ${item}]}
multi \
${quotes} \
${mapScript} \
${name} \
${desc} \
${setup} \
${input} \
${result} \
${vimCmds} \
${constr} \
}
proc pairs {name desc setup input result \
{vimCmds {}} \
{constr {}} \
} {
set pairs [list () \{\} \[\] <> ¿? ¡! ,:]
set mapScript {
set left [string index ${item} 0]
set right [string index ${item} 1]
set aCharMap [list ( ${left} ) ${right}]
}
multi \
${pairs} \
${mapScript} \
${name} \
${desc} \
${setup} \
${input} \
${result} \
${vimCmds} \
${constr} \
}
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

153
test/pairs.test Normal file
View File

@@ -0,0 +1,153 @@
# singleTest name desc setup input result vimCmds? skipScript?
#
# - desc can be empty and input would be used.
# - vimCmds is a list of ex commands.
# - skipScript will be evaluated in the scope of the function "single" and it
# should return a keywowd such as toDo, badTest or other as listed in the
# docs for tcltest. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
# Get some help:
source helper.tcl
set vimCmds [list ]
pairs autoclose-1 {} {} "i(" "()"
pairs autoclose-2 {} {()} "a\b" ""
pairs autoclose-3 {} "()" "a)x" "()x"
set skipScript {string cat {toDo}}
single jump_all {} "" "((<magic>x" "(())x" {} ${skipScript}
pairs undo {} "" "i(x\033u" ""
pairs autoclose-4 {} "" "i@(x" "@(x)"
pairs autoclose-5 {} "@#" "a(x" "@(x)#"
pairs autoclose-6 {} "\\" "a(x" "\\(x"
pairs autoclose-7 {} "(\\)" "la)x" "(\\)x)"
pairs autoclose-8 {} {"abc"} "ifoo(" "foo(\"abc\""
set vimCmds [list {let g:delimitMate_autoclose = 0}]
pairs noautoclose-1 {} "" "i(x" "(x" ${vimCmds}
pairs noautoclose-2 {} "" "i()x" "(x)" ${vimCmds}
pairs noautoclose-3 {} "" "i())x" "()x" ${vimCmds}
pairs noautoclose-4 {} "" "i()\bx" "x" ${vimCmds}
pairs noautoclose-5 {} "" "i@()x" "@(x)" ${vimCmds}
pairs noautoclose-6 {} "@#" "a()x" "@(x)#" ${vimCmds}
#" Handle backspace gracefully.
set vimCmds [list {set backspace=}]
pairs bad_bs {} "" "i(\033a\bx" "(x)" ${vimCmds}
set vimCmds [list ]
# closing parens removes characters. #133
pairs autoclose-9 {} "(a)" "a)" "()a)" ${vimCmds}
# Expand iabbreviations
set vimCmds [list {iabb def ghi}]
# Not sure how to make it work on the test
pairs iabbr {} "" "idef(" "ghi()" ${vimCmds}
set vimCmds [list ]
pairs autoclose-10 {} {abc а} {$i(} {abc (а} ${vimCmds}
pairs autoclose-11 {} "abc ñ" "\$i(" "abc (ñ" ${vimCmds}
pairs autoclose-12 {} "abc \$" "\$i(" "abc (\$" ${vimCmds}
pairs autoclose-13 {} "abc £" "\$i(" "abc (£" ${vimCmds}
pairs autoclose-14 {} "abc d" "\$i(" "abc (d" ${vimCmds}
pairs autoclose-15 {} "abc ." "\$i(" "abc ()." ${vimCmds}
pairs autoclose-16 {} "abc " "\$i(" "abc () " ${vimCmds}
pairs autoclose-17 {} "abc (" "\$i(" "abc ((" ${vimCmds}
# Play nice with undo.
pairs undo {} "" "ia\007u(c)b\033u" "a" ${vimCmds}
# TODO: way to jump over one or several closing chars
set skipScript {string cat {toDo}}
single jump_to {} "()" "a\<magic>x" "()x" ${vimCmds} ${skipScript}
single jump_to {} "{()}" "la\\<magic>x" "{()}x" ${vimCmds} ${skipScript}
set vimCmds [list {let g:delimitMate_balance_pairs = 0}]
pairs no_balance_pairs-1 {} "ab cd)" "la(x" "ab(x) cd)" ${vimCmds}
# Issue #229
pairs issue_229-1 {} "((ab cd)" "\$i)x" "((ab cd)x" ${vimCmds}
set vimCmds [list ]
set vimCmds [list {let g:delimitMate_balance_pairs = 1}]
pairs issue_229-2 {} "ab cd)" "la(x" "ab(x cd)" ${vimCmds}
# Issue #229
pairs issue_229-3 {} "((ab cd)" "\$i)x" "((ab cd)x)" ${vimCmds}
# Issue #220
set vimCmds [list {let g:delimitMate_jump_next = 0}]
pairs issue_220-1 {} "()" "a)" "())" ${vimCmds}
# Issues #207 and #223
set vimCmds [list {let g:delimitMate_jump_long = 1}]
pairs jump_long-1 {} "{\[(foobar)\]}" "fbi)x" "{\[(foobar)x\]}" ${vimCmds}
# Issues #207 and #223
set skipScript {expr "[string first {[[foobar]]} \"${setup}\"] > -1 \
? {badTest} : {}"}
single jump_long-2 {} "{\[(foobar)\]}" "fbi\]x" "{\[(foobar)\]x}" ${vimCmds} ${skipScript}
# Issues #207 and #223
set skipScript {string cat {toDo}}
set vimCmds [list {let g:delimitMate_jump_all = 1}]
single issues_207_223 {} "{\[(foobar)\]}" "fbi<magic>x" "{\[(foobar)\]}x" \
${vimCmds} ${skipScript}
set vimCmds [list {let g:delimitMate_jump_back = 1}]
pairs jump_back {} "" "i()x" "()x" ${vimCmds}
# Disable on syntax groups
set vimCmds [list {syntax on}]
lappend vimCmds {set ft=vim}
lappend vimCmds {let g:delimitMate_excluded_regions = ['String']}
pairs ignore_syntax {} {echo " "} "f\"la(" {echo " ( "} ${vimCmds}
#" Issue #160
set vimCmds [list {filetype indent plugin on}]
lappend vimCmds {set ft=php}
set skipScript {string cat {toDo}}
single issue_160 {} "<?php incl" "A\x18\x0F\x19" "<?php include()" \
${vimCmds} ${skipScript}
set vimCmds [list ]
# Play nice with redo
pairs redo {} "abc " "Afoo(x\033." "abc foo(x)foo(x)" ${vimCmds}
pairs smart {} {""} "0a(x" {"(x"}
pairs smart {} {""} "0a()x" {"(x)"}
################################################################
# This gives nice statistics and cleans up the mess left behind.
cleanupTests
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

107
test/quotes.test Normal file
View File

@@ -0,0 +1,107 @@
# singleTest name desc setup input result vimCmds? skipScript?
#
# - desc can be empty and input would be used.
# - vimCmds is a list of ex commands.
# - skipScript will be evaluated in the scope of the function "single" and it
# should return a keywowd such as toDo, badTest or other as listed in the
# docs for tcltest. e.g.:
# {expr "[string first {i'} \"${input}\"] > -1 ? {emptyTest} : {}"}
# see tcltest documentation for other values.
# Get some help:
source helper.tcl
quotes autoclose-1 {} {} "i'x" "'x'"
quotes autoclose-2 {} {} "i'x\033u" {}
quotes autoclose-3 {} {} {i''x} {''x}
quotes autoclose-4 {} {''} "a\bx" {x}
set skipScript {expr "[string first {i\"} \"${input}\"] > -1 ? {badTest} : {}"}
quotes autoclose-5 {} "" "i'x\"" "'x\"'" {} ${skipScript}
quotes autoclose-6 {} {} "i@'x" "@'x'"
quotes autoclose-7 {} {@#} "a'x" "@'x'#"
#quotes autoclose-8 {} {} "'\<S-Tab>x" "''x"
single autoclose-8 {} {abc'} "A'" "abc'" {} {string cat toDo}
quotes autoclose-9 {} "abc\\" "A'x" {abc\'x}
quotes autoclose-10 {} {} "au'Привет'" "u'Привет'"
quotes autoclose-11 {} {} "au'string'" "u'string'"
set vimCmds [list {let g:delimitMate_autoclose = 0}]
quotes noautoclose-1 {} {} "a'x" "'x" ${vimCmds}
quotes noautoclose-2 {} {} "a''x" "'x'" ${vimCmds}
quotes noautoclose-3 {} {} "a'''x" "''x" ${vimCmds}
quotes noautoclose-4 {} {} "a''\bx" "x" ${vimCmds}
quotes noautoclose-5 {} {} "a@''x" "@'x'" ${vimCmds}
quotes noautoclose-6 {} "@#" "a''x" "@'x'#" ${vimCmds}
set vimCmds [list {let g:delimitMate_autoclose = 1}]
# Handle backspace gracefully.
lappend vimCmds {set backspace=}
quotes badBS-1 {} {} "a'\033a\bx" "'x'" ${vimCmds}
set vimCmds [list {set cpo=ces$}]
quotes cpo {} {} "a'x" "'x'" ${vimCmds}
# Make sure smart quote works beyond first column.
quotes beyond_first_column {} { } "a'x" " 'x'"
# smart quote, check fo char on the right.
quotes smart_quote-1 {} "a b" "la'" "a 'b"
# Make sure we jump over a quote on the right. #89.
quotes autoclose-12 {} {} "a('test'x" "('test'x)"
# Duplicate whole line when inserting quote at bol #105
quotes autoclose-13 {} "}" "i'" "''}"
quotes autoclose-14 {} "'abc " "A'" "'abc '"
quotes autoclose-15 {} "''abc " "A'" "''abc ''"
# Nesting quotes:
set vimCmds [list {let g:delimitMate_nesting_quotes = delimitMate#option('quotes')}]
quotes nesting-1 {} "''" "A'x" "'''x'''" ${vimCmds}
quotes nesting-2 {} "'''" "A'x" "''''x''''" ${vimCmds}
quotes nesting-3 {} {} "i''x" "''x" ${vimCmds}
quotes nesting-4 {} {} "i'x" "'x'" ${vimCmds}
set vimCmds [list]
# expand iabbreviations
set vimCmds [list {iabb def ghi}]
single iabbr {} {} {idef"} {ghi"} ${vimCmds}
set vimCmds [list]
quotes autoclose-16 {} {} "i'\n\b" "''"
# Double quote starts a comment in viml
set vimCmds [list {set ft=vim}]
single vim_comment {} {} {i"} {"} ${vimCmds}
#" Allow quote to exit from string when disabled by syntax group.
set vimCmds [list {syntax on}]
quotes disabled_syntax {} "'abc'" "\$i'x" "'abc'x" ${vimCmds}
# --------
# This gives nice statistics and cleans up the mess left behind.
cleanupTests
# vim: set filetype=tcl et sw=2 sts=0 ts=8:

20
test/test.exp Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env expect -f
set testName [lindex $argv 0]
set filein "${testName}.in"
set fileout "${testName}.out"
set input [lindex $argv 1]
set timeout 2
spawn env TERM=dumb vim -N -i NONE -u _setup.vim -S "${testName}.vim" -- ${filein}
match_max 100000
expect -exact "Start test"
foreach char [split ${input} {}] {
send -- "${char}"
sleep .01
}
send -- " "
sleep .01
send -- ":w! ${fileout}\r"
send -- ":qa!\r"
expect eof