387 Commits
1.0 ... 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
Israel Chauca Fuentes
fe1983cfa1 Consider ´quotes in smart_quotes`. Close #182.
[:punct:] does not always match the same set of characters.
2014-12-02 11:07:22 -05:00
Israel Chauca Fuentes
a4ac44a84f Add test plugins to the &rtp if they are present. 2014-12-01 00:23:37 -05:00
Israel Chauca Fuentes
4c13ed6aee Make s:g() return default optional values. Close #186. 2014-11-30 11:40:19 -05:00
Israel Chauca Fuentes
eafd832c04 Fix indentation in test. 2014-11-29 16:08:43 -05:00
Israel Chauca Fuentes
e13872fdb2 Fix indentation in test. 2014-11-29 16:08:00 -05:00
Israel Chauca Fuentes
9a9b9edb9a Merge pull request #183 from blueyed/makefile-for-tests
Makefile for tests
2014-11-29 15:32:43 -05:00
Israel Chauca Fuentes
0f353bd2b3 Add test for smartindent and expand_cr. 2014-11-28 12:11:28 -05:00
Israel Chauca Fuentes
c1b832bbf8 Merge pull request #180 from kballard/fix_expand_cr_smartindent
Fix expand_cr behavior with 'smartindent'
2014-11-27 02:45:59 -05:00
Israel Chauca Fuentes
073957f0a1 Add expand_inside_quotes to report and fix doc. Closes #179. 2014-11-27 02:11:12 -05:00
Israel Chauca Fuentes
c678061b79 Fix '<CR><BS>. Closes #178. 2014-11-27 01:48:34 -05:00
Israel Chauca Fuentes
12c7d85ff6 Add a basic vimrc to help with tests. 2014-11-26 19:24:38 -05:00
Israel Chauca Fuentes
66834e7209 Allow custom regex for smart_quotes. Close #164.
- Use search() to match on the current line and remove most of the old
  code in IsSmartQuote().
- Allow using ! to negate the pattern.
- Add tests.
- s:s() :unlet variables before setting them.
2014-11-26 15:03:00 -05:00
Daniel Hahler
21072cf13e gitignore: test/build and test output/generated files 2014-06-15 15:14:40 +02:00
Daniel Hahler
d952f6c721 test: call new Makefile from test subdir 2014-06-15 15:14:40 +02:00
Daniel Hahler
0efe44bc70 Rename README to README.md 2014-06-15 15:14:40 +02:00
Daniel Hahler
631d72465a Add a Makefile to provide make test 2014-06-15 15:14:40 +02:00
Kevin Ballard
4024181af2 Fix expand_cr behavior with 'smartindent'
When indentation is controlled by 'smartindent', the expand_cr behavior
doesn't end up producing the same results that you would get without
delimitMate. The following behavior results instead:

Before: {|}
After: {
		|
	}

The expected behavior is to produce the following:

Before: {|}
After: {
	|
}

To that end, detect when indentation is controlled by 'smartindent' and
adjust the indentation of the close line to match.
2014-06-03 18:26:42 -07:00
Israel Chauca Fuentes
38487bbec8 Merge pull request #169 from blueyed/hack-jumpout-del-and-reinsert
JumpOut: delete and insert char instead of jumping over.
2014-02-19 20:40:27 -05:00
Israel Chauca Fuentes
c74a48ccd8 Merge pull request #167 from blueyed/makefile-detect-sed
Detect $SED dynamically, but do not force `gsed`
2014-02-14 02:41:58 -05:00
Daniel Hahler
df1f32f772 JumpOut: delete and insert char instead of jumping over
Ref: https://github.com/Raimondi/delimitMate/issues/168
2014-02-11 23:55:25 +01:00
Daniel Hahler
f2b9b3a0c2 Detect $SED dynamically, but do not force gsed 2014-02-06 02:24:43 +01:00
Daniel Hahler
1c45f7bbde ParenDelim: improve smart_matchpairs handling
* move the check up
* only handle it when smart_matchpairs is configured (default)
2014-02-06 02:20:29 +01:00
Israel Chauca Fuentes
a1f21e8ef5 Merge pull request #162 from blueyed/handle-dotted-filetype
Fix &ft check in QuoteDelim: handle dotted filetypes
2014-02-02 21:05:39 -08:00
Israel Chauca Fuentes
eba94168ce Merge pull request #161 from blueyed/doc-typo
minor: fix doc typo
2014-02-02 21:03:22 -08:00
Daniel Hahler
06c1f31632 Fix &ft check in QuoteDelim: handle dotted filetypes
From `:h 'filetype'`:

		When a dot appears in the value then this separates two filetype
		names.  Example:
			/* vim: set filetype=c.doxygen : */ ~

I am using `ft=pentadactyl.vim` for my Pentadactyl/Vimperator
configuration files.
2014-01-29 11:23:20 +01:00
Daniel Hahler
9826c667e0 minor: fix doc typo 2014-01-29 11:19:50 +01:00
Israel Chauca Fuentes
35280c1444 Merge pull request #158 from peter50216/patch-1
Run DelimitMateDo() when loading plugin.
2014-01-07 13:07:19 -08:00
peter50216
82160a5de6 run DelimitMateDo() when loading plugin.
Current setting would make this plugin's mapping added last, and cause conflict with https://github.com/tpope/vim-endwise. See https://github.com/tpope/vim-endwise/pull/13.
2014-01-07 12:00:54 +08:00
Israel Chauca Fuentes
07d9fa9ddc Check delimitMate_matchpairs’ syntax. Also some formatting. 2014-01-04 18:14:03 -05:00
Israel Chauca Fuentes
54853a954c Consider | for matchpairs. Also some minor formatting. Fix #155. 2014-01-04 16:43:45 -05:00
Israel Chauca Fuentes
f00f6b6cf2 Simplify TriggerAbb(). 2013-12-25 02:28:46 -05:00
Israel Chauca Fuentes
d280d23a83 Do not try to expand iabbreviations when popup menu on. Should fix #154. 2013-12-25 02:09:41 -05:00
Israel Chauca Fuentes
821e0019fb Consider popup menu when expanding. Close #154. 2013-12-24 13:20:39 -05:00
Israel Chauca Fuentes
5ef40e0234 Do not expand cr and space inside quotes by default. Close #153.
- Add delimitMate_expand_inside_quotes.
- Add tests.
2013-12-24 02:48:35 -05:00
Israel Chauca Fuentes
399e18d669 Merge pull request #152 from Gray-Wind/master
Fix logical issue
2013-12-21 06:45:22 -08:00
Ilya Kolo
92fba35d27 Fix logical issue 2013-12-21 14:31:40 +04:00
Israel Chauca Fuentes
0528bdac15 Only try to expand abbreviations when supported. Close #151. 2013-12-20 18:21:34 -05:00
Israel Chauca Fuentes
5db098e953 Better testing for quotes. 2013-12-19 00:26:58 -05:00
Israel Chauca Fuentes
b45536fe8d Fix expanding abbreviations. Close #145. 2013-12-18 23:55:02 -05:00
Israel Chauca Fuentes
3dde5cc8cb Do not use <C-R>= for matchpairs. Close #150, close #143. 2013-12-18 23:05:30 -05:00
Israel Chauca Fuentes
5787ec4f59 Add explanation about delimitMate_jump_expansion. Close #137. 2013-12-18 12:52:57 -05:00
Israel Chauca Fuentes
2dc880bf1c Merge pull request #147 from mganjoo/master
Add C-h synonym for delimitMateBS
2013-12-18 09:14:10 -08:00
Israel Chauca Fuentes
440f38858f Merge pull request #149 from thiderman/comments
Modify QuoteDelim() to be smart about vim comments
2013-12-15 15:47:18 -08:00
Lowe Thiderman
f7f895c211 Modify QuoteDelim() to be smart about vim comments
Add simple check into QuoteDelim() that checks if the user is about to start
a comment in vim files. If that's the case, don't balance it.
2013-12-15 22:24:20 +01:00
Milind Ganjoo
654dc14e6e Add C-h synonym for delimitMateBS (can't add one for S-BS though) 2013-10-26 17:13:26 -07:00
Israel Chauca Fuentes
543be33b13 Better handling of nested quotes. Closes #134. 2013-07-22 20:52:05 -04:00
Israel Chauca Fuentes
7345bfddef Update readme. 2013-07-22 13:35:59 -04:00
Israel Chauca Fuentes
16a35eefab Update version and doc. 2013-07-22 13:29:36 -04:00
Israel Chauca Fuentes
74ab16ea5b Rewrite makefile. 2013-07-22 13:28:52 -04:00
Israel Chauca Fuentes
2adbf5a8d7 Remove old test script. 2013-07-14 03:34:20 -04:00
Israel Chauca Fuentes
e4a02eb998 Do not modify the line when checking for syntax groups. 2013-07-14 01:31:30 -04:00
Israel Chauca Fuentes
ad11ab2210 Fix tests. 2013-07-14 01:30:05 -04:00
Israel Chauca Fuentes
6b0d448f6a Don't use a char buffer anymore. 2013-07-14 01:29:53 -04:00
Israel Chauca Fuentes
32c9db8f37 Simplify command. 2013-07-13 23:01:02 -04:00
Israel Chauca Fuentes
a77423a46f Remove superfluous unmapping. 2013-07-13 22:59:58 -04:00
Israel Chauca Fuentes
57fd02b2e0 Fix tests. 2013-07-13 22:58:42 -04:00
Israel Chauca Fuentes
14faba1c62 Don't use setline() for left-side matchpair. 2013-07-13 21:57:21 -04:00
Israel Chauca Fuentes
8ab087c95c Don't use setline() with quotes. 2013-07-13 21:27:38 -04:00
Israel Chauca Fuentes
61d62e8920 small fix. 2013-07-13 19:54:23 -04:00
Israel Chauca Fuentes
7ce61655a7 Do not remove caracters when inserting a closing paren. Close #133. 2013-07-09 14:10:28 -04:00
Israel Chauca Fuentes
8d133d4726 Set bs to 2 on tests. 2013-06-27 21:51:28 -04:00
Israel Chauca Fuentes
7caa6092b7 Fix <S-Tab> mapping. Close #132. 2013-06-27 21:35:37 -04:00
Israel Chauca Fuentes
d98d8c0a0d Fix :DelimitMateTest. 2013-06-27 20:59:04 -04:00
Israel Chauca Fuentes
e2d63e38f6 Store internal values in s:options. Close #79. 2013-06-22 00:20:45 -04:00
Israel Chauca Fuentes
579e3520a4 Use setter/getter everywhere (well, almost everywhere). 2013-06-21 23:49:48 -04:00
Israel Chauca Fuentes
90d07a68be Update options list. 2013-06-21 22:42:41 -04:00
Israel Chauca Fuentes
2cb3f4d5e6 Use getter func. 2013-06-21 22:42:15 -04:00
Israel Chauca Fuentes
3a23e89cb5 Jump out of space expansion. Never meant to disable it. Closes #129. 2013-06-21 21:49:07 -04:00
Israel Chauca Fuentes
70e1ac1462 Smart quotes consider balanced quotes on current line. Closes #94. 2013-06-19 00:43:42 -04:00
Israel Chauca Fuentes
d4ba528935 Add eol marker finished. Closes #102. Add s:g(). 2013-06-19 00:06:10 -04:00
Israel Chauca Fuentes
8a8aad183f Fix tests, BS in expansions and close #105. 2013-06-18 18:52:26 -04:00
Israel Chauca Fuentes
cfc6654855 Make jumping over space and CR expansions optional and off by default.
- Closes #130.
- Closes #110.
- As suggested in #95.
2013-06-18 16:02:48 -04:00
Israel Chauca Fuentes
f2efe4331b Merge pull request #128 from matthias-guenther/master
Markdown file ending for README
2013-05-12 13:53:31 -07:00
Matthias Günther
dfa7e9b730 Markdown ending for README 2013-05-11 22:21:28 +02:00
Israel Chauca Fuentes
765bdd80dc Fix typo. 2013-04-10 11:04:15 -04:00
Israel Chauca Fuentes
739d2f9bd4 Call #Finish() only when necessary for <BS>. As mentioned in #124. 2013-03-27 18:33:58 -04:00
Israel Chauca Fuentes
eb7738e4aa Call #Finish() only when necessary. Closes #124. 2013-03-27 16:50:53 -04:00
Israel Chauca Fuentes
32f5d8df07 Do not map over <Esc>. Closes #118. 2013-02-12 10:37:42 -05:00
Israel Chauca Fuentes
7b5887c324 Do not create bogus imap. closes #113 , closes #87. 2013-02-08 20:43:32 -05:00
Israel Chauca Fuentes
0326b7c14a Flush buffer on scrolling. 2012-07-20 15:51:19 -04:00
Israel Chauca Fuentes
1dfe26a538 Fix CR expansion & syn fold enabled by InsertLeave
Benamin Fritz reported the following:

Without the "zv", if the user has syntax folding on, when the mapping
invokes <Esc> the pair of braces which were just separated by a <CR>
could become folded, so that the trailing "o" opens a new line AFTER
the pair.
2012-06-08 16:56:34 -04:00
Israel Chauca Fuentes
9c1564a22f Merge pull request #99 from jamessan/master
Fix spelling mistake in README
2012-05-30 18:51:46 -07:00
James McCoy
028964cf7d README: Fix spelling mistake 2012-05-30 21:43:35 -04:00
Israel Chauca Fuentes
5a84c1a746 Update :DelimitMateTest for eol_marker. 2012-04-15 20:16:44 -04:00
Israel Chauca Fuentes
0f9563969d Update doc about #77. 2012-04-15 01:47:19 -04:00
Israel Chauca Fuentes
d3ffebab74 Replace for loop with map(). Should finish with #77. 2012-04-15 01:34:56 -04:00
Israel Chauca Fuentes
ece6c39a65 Add eol marker only if inserted on the same 'insert session'. 2012-04-15 01:02:28 -04:00
Israel Chauca Fuentes
ad151d3e55 Fix readme. 2012-04-14 19:36:51 -04:00
Israel Chauca Fuentes
b65d719353 Add string next to the closing matchpair when at the eol. Closes #77. 2012-04-14 19:36:51 -04:00
Israel Chauca Fuentes
a42dff4ad8 Merge pull request #97 from grota/master
fix for #96
2012-04-08 08:57:51 -07:00
Giuseppe Rota
4a7d5a6e54 screwup in map checks 2012-04-08 13:37:11 +02:00
Israel Chauca Fuentes
50a0df0be4 Merge pull request #96 from grota/master
Avoid mapping in ExtraMappings when there's already a map.
2012-04-07 20:19:24 -07:00
Giuseppe Rota
cecebf6e86 Avoid mapping in ExtraMappings when there's already a map. 2012-04-07 13:17:34 +02:00
Israel Chauca Fuentes
ad4430706e Fix conflict with cindent. Comment on #95. 2012-04-01 17:59:40 -04:00
Israel Chauca Fuentes
93d4a373fb Correct test for CR expansions. 2012-03-31 17:00:51 -04:00
Israel Chauca Fuentes
a9f51531d9 Consider indentation with BS on empty expanded CR. 2012-03-31 16:56:31 -04:00
Israel Chauca Fuentes
6bb98110b4 Consider space and CR expansions when jumping over. Closes #95. 2012-03-31 13:33:24 -04:00
Israel Chauca Fuentes
0b34aea202 Always jump over the quote on the right. Closes #89. 2012-03-04 00:11:40 -05:00
Israel Chauca Fuentes
f1e92d05d5 Make smart quote work beyond the first column. Closes #89. 2012-03-03 16:09:08 -05:00
Israel Chauca Fuentes
8ec2bcb89a Merge pull request #88 from Glench/patch-2
Fix grammar in README
2012-02-29 16:32:52 -08:00
Glen Chiacchieri
beb87ef41f Fix grammar in README 2012-02-29 19:26:07 -05:00
Israel Chauca Fuentes
26a6def62f Add an option to prevent mapping to ^[OC.
Might be useful in #87.
2012-02-28 18:27:13 -05:00
Israel Chauca Fuentes
0fb597ef36 Make :DelimitMateTest more verbose.
- Add the output of :version.
- Print all mapping regardless of value.
- Ask before overwriting a modified buffer.
2012-02-25 17:45:28 -05:00
Israel Chauca Fuentes
fe5dd9a61a Fix typo in doc. Closes #85. 2012-02-24 20:48:05 -05:00
Israel Chauca Fuentes
bb9b0edcc5 Simplify CR expansion mapping. Add Test for it. 2012-02-24 20:32:42 -05:00
Israel Chauca Fuentes
f3176a664c Merge branch 'master' of https://github.com/gyim/delimitMate 2012-02-23 20:46:02 -05:00
Akos Gyimesi
1cbbe90a09 Allow CR expansion for arbitrary line suffix. 2012-02-23 21:35:40 +01:00
Israel Chauca Fuentes
a9174f65ba Merge pull request #83 from gyim/master
Add mapping for default MacVim movements
2012-02-23 12:01:28 -08:00
Akos Gyimesi
2af2dd2350 Add mapping for default MacVim movements 2012-02-23 20:58:42 +01:00
Israel Chauca Fuentes
9c77b8434a Use default cpo values while creating mappings. Closes #72. 2012-02-22 23:14:01 -05:00
Israel Chauca Fuentes
646794cbda Remove "apostrophe" feature. Closes #81. 2012-02-16 14:53:01 -05:00
Israel Chauca Fuentes
93fdcf92e1 Update README. 2012-02-16 02:30:35 -05:00
Israel Chauca Fuentes
fbbd9514c5 Add real README. 2012-02-16 02:28:10 -05:00
Israel Chauca Fuentes
be5c41b3c1 Add test files. 2012-02-16 01:59:28 -05:00
Israel Chauca Fuentes
b853ee9f35 Handle backspace option gracefully. Quick test for #64. 2012-02-15 22:05:48 -05:00
Israel Chauca Fuentes
eb2625c4a7 Consider non ascii chars for smart quote. 2012-02-15 15:38:11 -05:00
Israel Chauca Fuentes
e17f6cd23c Consider non ascii chars for smart quote. Close #73. 2012-02-15 14:52:53 -05:00
Israel Chauca Fuentes
54acd56b48 Fix space expansion. Closes #68. 2012-02-15 14:25:36 -05:00
Israel Chauca Fuentes
9bdd4b078a Merge pull request #80 from Glench/patch-1
Fix typo in readme.
2012-02-14 17:16:22 -08:00
Israel Chauca Fuentes
f5748da36c Fix issues with quotes. 2012-02-14 18:39:48 -05:00
Israel Chauca Fuentes
eade67b409 Remove noise. 2012-02-12 13:33:04 -05:00
Glen Chiacchieri
b3f62f79c2 Fix typo in readme.
This was bothering me way too much.
2012-02-12 13:25:37 -05:00
Israel Chauca Fuentes
9d133d5b69 Fix flushing of char buffer. 2012-02-09 21:28:53 -05:00
Israel Chauca Fuentes
9f003b5bf5 Add CursorIdx() multibyte aware col(). 2012-02-08 22:44:39 -05:00
Israel Chauca Fuentes
e688e20151 Optimize IsSpaceExpansion. 2012-02-08 03:50:43 -05:00
Israel Chauca Fuentes
8749708115 Optimize IsEmptyPair. 2012-02-08 03:41:11 -05:00
Israel Chauca Fuentes
5cc5d8d9b3 Replace GeetChar*Cursor with GetCharFromCursor. 2012-02-08 03:07:49 -05:00
Israel Chauca Fuentes
98b4119746 Attempt to fix CR expansion. 2012-02-08 01:08:10 -05:00
Israel Chauca Fuentes
c889905e47 Fix duplicated closing paren with <S-Tab>.
Code from @albertosantini. Closes #69.
2012-02-08 00:22:18 -05:00
Israel Chauca Fuentes
db54dadb46 Remove unused var. 2012-02-08 00:22:04 -05:00
Israel Chauca Fuentes
604260f56e Use GetChar*Cursor() instead of byte indexes. 2012-02-08 00:02:58 -05:00
Israel Chauca Fuentes
581a3ebc17 Modify b:_l_delimitMate_matchpairs_list. 2012-02-07 22:32:17 -05:00
Israel Chauca Fuentes
cc1acaba96 Allow multibyte chars with <BS>. Closes #78.
- Add delimitMate#GetCharUnderCursor()
- Add delimitMate#GetCharBeforeCursor()
- Simplify delimitMate#Del()
2012-02-07 22:11:53 -05:00
Israel Chauca Fuentes
7b781ab6b6 Merge branch 'master' of https://github.com/MSch/delimitMate 2012-02-07 18:46:04 -05:00
Israel Chauca Fuentes
233eb52a97 Merge pull request #67 from tmhedberg/master
Option to disable delimitMate in all buffers by default
2012-02-05 21:19:50 -08:00
Martin Schürrer
aff9743269 Also work with <C-Left> and <C-Right> 2011-12-18 12:22:16 +01:00
Taylor Hedberg
ce1d05fac5 [fix] Broken undo after <CR> expanded 2011-11-03 12:47:21 -04:00
Taylor Hedberg
6dad313734 Documentation for delimitMate_offByDefault 2011-08-25 12:42:32 -04:00
Taylor Hedberg
5263e25548 delimitMate_offByDefault option to disable delimitMate by default 2011-08-25 12:36:15 -04:00
Israel Chauca Fuentes
39b8298390 Typo on doc. "brake->break" now all of them. 2011-07-04 16:51:48 -05:00
Israel Chauca Fuentes
57b80ea78a Typo on doc. "brake->break" 2011-07-04 16:50:02 -05:00
Israel Chauca Fuentes
a5b7141fc4 Set and restore &cpo in the right place. 2011-04-17 15:49:27 -05:00
Israel Chauca Fuentes
9efb01da68 UPdate README. 2011-01-14 23:31:20 -06:00
Israel Chauca Fuentes
860c45ab2a Limit autocmd effects. 2011-01-14 22:13:00 -06:00
Israel Chauca Fuentes
8686edfc63 Update version. 2011-01-14 20:59:53 -06:00
Israel Chauca Fuentes
5e7a7c4738 Update change log. 2011-01-14 20:57:56 -06:00
Israel Chauca Fuentes
928cc1146a Fix behaviour of b:loaded_delimitMate. 2011-01-14 20:49:28 -06:00
Israel Chauca Fuentes
d420afdacd Trivial formatting. 2011-01-14 20:37:40 -06:00
Israel Chauca Fuentes
f6015300a0 Modify smart_matchpairs regex. 2011-01-14 20:37:04 -06:00
Israel Chauca Fuentes
e183064744 Update change log. 2011-01-14 20:36:29 -06:00
Israel Chauca Fuentes
40849c94ef Update documentation. 2011-01-14 20:29:22 -06:00
Israel Chauca Fuentes
4c1424f9bd Reorder stuff. 2010-12-11 05:23:59 -06:00
Israel Chauca Fuentes
0783f97fc0 Modify :DelimitMateTest output. 2010-12-11 05:23:27 -06:00
Israel Chauca Fuentes
e551885c24 Prevent indenting from propagating on the report. 2010-12-11 00:16:31 -06:00
Israel Chauca Fuentes
4891a04258 Fix double space. 2010-12-11 00:10:21 -06:00
Israel Chauca Fuentes
ad77a9a75e Append output of :set to report. 2010-12-11 00:08:35 -06:00
Israel Chauca Fuentes
5bf35a6b31 Delete empty <CR> expansion with indentation. 2010-12-11 00:07:59 -06:00
Israel Chauca Fuentes
49044099dd Change format of report. 2010-12-11 00:07:19 -06:00
Israel Chauca Fuentes
7c423067a8 UPdate to delimitMateTests#Main(). 2010-12-10 23:26:21 -06:00
Israel Chauca Fuentes
d08fa765b9 Update doc. 2010-12-10 23:25:10 -06:00
Israel Chauca Fuentes
f47bcd8e3f Reorder mappings. 2010-12-08 21:56:47 -06:00
Israel Chauca Fuentes
873e79ec37 Allow jumping over contiguous delimiters. Closes #44. 2010-12-08 03:34:45 -06:00
Israel Chauca Fuentes
589b2ae85a Merge branch 'master' into jump_over 2010-12-07 17:05:00 -06:00
Israel Chauca Fuentes
f9f2b5f177 Don't leave mappings around.
Some mappings weren't being unmapped on filetype change because options
were initialized before the call to Unmap().
2010-12-07 16:59:09 -06:00
Israel Chauca Fuentes
4157dc8a88 Make jumping back optional. 2010-12-06 22:08:59 -06:00
Israel Chauca Fuentes
d0fc1456b7 Use \# to insert closing pair in smart_matchpairs. 2010-11-17 23:17:25 -06:00
Israel Chauca Fuentes
86f70a7d9c Use regex for smart_matchpairs.
If the text in the line to the right of the cursor matches
smart_matchpairs, do not auto close.

To match the opening paren, insert a escaped bang (\!) in the pattern.
2010-11-17 17:53:33 -06:00
Israel Chauca Fuentes
f7b53f045d Fix typo. 2010-11-09 03:19:44 -06:00
Israel Chauca Fuentes
f3d140e363 Update credits section. 2010-11-09 01:12:26 -06:00
Israel Chauca Fuentes
93a1770f37 Doc update. 2010-11-08 09:47:51 -06:00
Israel Chauca Fuentes
859a732509 Merge git://github.com/ervandew/delimitMate into temporal
Conflicts:
	autoload/delimitMate.vim
2010-11-08 09:22:20 -06:00
Israel Chauca Fuentes
eb778be64b Update OptionsList(). 2010-11-06 22:47:05 -05:00
Israel Chauca Fuentes
2b2ae65182 Eliminate some noise from DelimitMateTest. 2010-11-06 22:43:03 -05:00
Israel Chauca Fuentes
e1b52d3676 Some formating. 2010-11-06 22:41:31 -05:00
Israel Chauca Fuentes
ff4745b191 More flexible test for 'backspace' values. 2010-11-06 22:38:13 -05:00
Israel Chauca Fuentes
2ba694830d Use '\w' instead of '[[:alnum:]]' in smart_quotes. 2010-11-06 22:35:40 -05:00
Israel Chauca Fuentes
12c5c96ca2 Add smart_matchpairs
This option will prevent delimitMate from inserting the closing
delimiter when there is a keyword character on the right of the cursor.
2010-11-06 20:05:40 -05:00
ervandew
a97af1fb97 add option to disable closing delims if open delim added before an alphanumeric 2010-11-06 17:15:23 -07:00
Israel Chauca Fuentes
5bf6a1e30c Fix DelimitMateTest. 2010-10-09 17:23:32 -05:00
Israel Chauca Fuentes
f8883cb700 Release 2.5.1. 2010-09-30 18:55:35 -05:00
Israel Chauca Fuentes
f72ffe3c12 b:vars take precedence over g:vars in report. 2010-09-30 18:50:52 -05:00
Israel Chauca Fuentes
d2e896fbe1 Nicer report. 2010-09-29 14:33:14 -05:00
Israel Chauca Fuentes
a0b1799270 Remove Visual Wrapping. Closes #38. 2010-09-27 15:27:45 -05:00
Israel Chauca Fuentes
1d423ab2b9 Release 2.5. 2010-09-22 21:49:19 -05:00
Israel Chauca Fuentes
7f5df4bf6e Update documentation. 2010-09-20 16:46:36 -05:00
Israel Chauca Fuentes
9f1fdc418d Version and doc update. 2010-09-20 01:47:01 -05:00
Israel Chauca Fuentes
64cf4beb8a Formating. 2010-09-20 00:55:30 -05:00
Israel Chauca Fuentes
119174b7dd Add -bar to commands. 2010-09-20 00:53:12 -05:00
Israel Chauca Fuentes
b3a7728299 Use <Plug> and conditional mappings for delimiters. 2010-08-24 10:15:31 -05:00
Israel Chauca Fuentes
2266a19900 Rename mappings. 2010-08-24 09:04:57 -05:00
Israel Chauca Fuentes
1b587bee9a Better :DelimitMateReport. 2010-08-24 08:29:10 -05:00
Israel Chauca Fuentes
31b289adfe TestMappings handles "|". Closes #37. 2010-08-21 12:33:27 -05:00
Israel Chauca Fuentes
efadb34c84 Allow "|" to be used in mappings. 2010-08-21 11:29:29 -05:00
Israel Chauca Fuentes
58d63b4e5b Fix use of multibyte chars. 2010-08-14 21:10:04 -05:00
Israel Chauca Fuentes
0441a03bb9 Don't use #Finish() until completion has been used. 2010-08-14 20:34:25 -05:00
Israel Chauca Fuentes
90cb449ada Prevent calling autoload on entering Insert mode. 2010-08-14 15:28:15 -05:00
Israel Chauca Fuentes
a678d7baab Move mapping and init funcs to plugin/. 2010-08-14 13:48:52 -05:00
Israel Chauca Fuentes
2911bf33c9 Force visual mappings to be silent. Closes #33. 2010-08-14 13:31:45 -05:00
Israel Chauca Fuentes
221daf6e6a Temporarily revert two last commits. 2010-08-14 13:24:32 -05:00
Israel Chauca Fuentes
8f5a45f9e7 Force visual mappings to be silent. Closes #33. 2010-08-10 12:55:12 -05:00
Israel Chauca Fuentes
6f5fd80e0e Move functions, autoload isn't loaded at startup 2010-08-10 12:51:57 -05:00
Israel Chauca Fuentes
1caeda0799 Consider pop-up menu on mappings. Closes #32 2010-08-09 14:48:41 -05:00
Israel Chauca Fuentes
3fb33b8e47 Add :verbose imap map to Test. 2010-08-08 10:13:24 -05:00
Israel Chauca Fuentes
e6288a7313 Ammend test function to check for mappings. 2010-08-07 17:02:29 -05:00
Israel Chauca Fuentes
7dd7edff64 Mappings made conditional.
All mappings use <Plug> and are not set if there is an existent mapping with the same lhs string or that contains the <Plug> mapping on the rhs.
2010-08-07 15:16:38 -05:00
Israel Chauca Fuentes
4b94c38f95 Release 2.4.1. 2010-07-31 13:01:42 -05:00
Israel Chauca Fuentes
217adb3d8e Update change log. 2010-07-31 10:58:55 -05:00
Israel Chauca Fuentes
e63e373ae1 Reorder doc of options. 2010-07-31 00:48:50 -05:00
Israel Chauca Fuentes
9c11c5cc82 Fix 'smart_quotes' doc. 2010-07-31 00:22:26 -05:00
Israel Chauca Fuentes
8b24f0fd9f Add doc on 'smart_quotes' and delimitMateBalance. 2010-07-30 23:56:21 -05:00
Israel Chauca Fuentes
701e14f72f Rename unbalanced_paren to balance_matchpairs. 2010-07-30 23:54:20 -05:00
Israel Chauca Fuentes
c9c1464075 Silence some noise related to 'backspace'. 2010-07-30 23:51:20 -05:00
Israel Chauca Fuentes
e831d89acf Reset buffer with <Home> and <End>. Closes #27. 2010-07-30 02:59:43 -05:00
Israel Chauca Fuentes
133c125f93 Makefile change. 2010-07-30 02:58:12 -05:00
Israel Chauca Fuentes
b9cea6312a Release 2.4 2010-07-29 18:20:13 -05:00
Israel Chauca Fuentes
1b37d60840 Behave nicely with iminsert and imsearch. Thanks to nailxx@github.com. 2010-07-20 13:27:28 -05:00
Israel Chauca Fuentes
a70aa5285e Doc fix. Missing quotes. 2010-07-20 13:23:41 -05:00
Israel Chauca Fuentes
2eba04961d Added note about abbreviations not being expanded. # 26 2010-07-15 19:20:09 -05:00
Israel Chauca Fuentes
3519f82f79 \<Right\> doesn\'t work under terminal. #25 2010-07-15 04:10:38 -05:00
Israel Chauca Fuentes
e9491e473c Reorder some logic. 2010-07-15 04:07:56 -05:00
Israel Chauca Fuentes
9e3075cff5 Changelog update. 2010-07-03 14:43:20 -05:00
Israel Chauca Fuentes
7c9ba95565 Doc update. 2010-06-28 19:08:27 -05:00
Israel Chauca Fuentes
3ae285424c Expand smart quotes to consider [:alnum:] to the right. 2010-06-28 15:20:32 -05:00
Israel Chauca Fuentes
fa1d3b3d6a Add option to allow nesting quotes. #24 2010-06-28 13:18:04 -05:00
Israel Chauca Fuentes
63f8c2af4f Add note to the docs about <S-BS> not working on terminal. 2010-06-26 13:29:16 -05:00
Israel Chauca Fuentes
29eb98d79d Sort results from Tests#Main(). 2010-06-25 15:18:45 -05:00
Israel Chauca Fuentes
5b004ca49d Comment formatting. 2010-06-25 15:17:51 -05:00
Israel Chauca Fuentes
34df78f8ab Fix vars scope. 2010-06-25 15:17:17 -05:00
Israel Chauca Fuentes
e234e45846 #23 and vars with wrong values. 2010-06-25 15:16:25 -05:00
Israel Chauca Fuentes
081ec279ed Rename internal vars to hide them from completion. 2010-06-25 15:10:50 -05:00
Israel Chauca Fuentes
4399fa327f Doc corrections. 2010-06-23 12:53:58 -05:00
Israel Chauca Fuentes
ceaa6e01ed Deleted IsBlockVisual(). 2010-06-23 12:53:16 -05:00
Israel Chauca Fuentes
235f0dcbfb Fixed duplicate <silent>. 2010-06-23 12:52:18 -05:00
Israel Chauca Fuentes
fadd7fefbc Merge http://github.com/Lokaltog/delimitMate
Conflicts:
	autoload/delimitMate.vim
2010-06-22 21:25:05 -05:00
Israel Chauca Fuentes
193b6027c2 Fix #23. 2010-06-22 21:01:03 -05:00
Kim Silkebækken
a76439a641 Make all mappings silent
This change speeds up vim significantly in a terminal, and prevents the
annoying flickering of commands while typing.
2010-06-20 02:06:23 +02:00
Israel Chauca Fuentes
89cc598217 Update README. 2010-06-16 02:18:52 -05:00
Israel Chauca Fuentes
28ce6213fc Cosmetic changes. 2010-06-16 01:54:58 -05:00
Israel Chauca Fuentes
6d1f48c1bf Fix TestMappings(). 2010-06-16 01:54:40 -05:00
Israel Chauca Fuentes
0e20bcaff8 Use "fork" to open new gvim when testing. 2010-06-16 01:51:53 -05:00
Israel Chauca Fuentes
aae61ad8ba Use 'nomore'. 2010-06-16 01:50:33 -05:00
Israel Chauca Fuentes
4dac6ce6ac Fix TestMappings(). 2010-06-16 01:47:42 -05:00
Israel Chauca Fuentes
875a9e450b Silence some noise on UnMap(). 2010-06-16 01:45:40 -05:00
Israel Chauca Fuentes
48d2e3b9d1 Check for 'backspace' when <CR> expansion is enabled. 2010-06-16 01:44:11 -05:00
Israel Chauca Fuentes
5626a633d5 Escape \\ on options. 2010-06-16 01:40:55 -05:00
Israel Chauca Fuentes
3652ba24e3 Split Init() and simplify the set-up process. 2010-06-16 01:37:08 -05:00
Israel Chauca Fuentes
740fc90ae7 Expansion documentation and intialization fixed. 2010-06-12 22:50:14 -05:00
Israel Chauca Fuentes
e0de2dbf39 Use internal b:vars to read from user options. 2010-06-12 22:15:26 -05:00
Israel Chauca Fuentes
efcf9eb341 Formatting. 2010-06-12 12:28:50 -05:00
Israel Chauca Fuentes
2545fa5967 Reset autocmds on re-loading. 2010-06-12 12:26:30 -05:00
Israel Chauca Fuentes
c91674eed2 Doc update. 2010-06-09 19:10:29 -05:00
Israel Chauca Fuentes
542728671e Fix issue #21. 2010-06-09 12:32:57 -05:00
Israel Chauca Fuentes
d1621b6672 Block-wise visual wrapping works with limitations. 2010-06-09 03:20:11 -05:00
Israel Chauca Fuentes
6d1cc1187b Fixed issue #18 for non xterm terminals. 2010-06-08 21:54:22 -05:00
Israel Chauca Fuentes
377c3a37e1 Do not close on unbalanced parens. 2010-06-08 00:48:34 -05:00
Israel Chauca Fuentes
d03324135c Rename and reorder some function, update doc. 2010-06-07 00:54:55 -05:00
Israel Chauca Fuentes
edeaff4730 Missing quote. 2010-06-06 13:51:31 -05:00
Israel Chauca Fuentes
c85fee6eb5 README update. 2010-06-06 13:28:47 -05:00
Israel Chauca Fuentes
0ccb143a12 Doc and version update. 2010-06-06 13:22:14 -05:00
Israel Chauca Fuentes
941beed3b3 Extend detection of version string in Makefile. 2010-06-06 13:16:55 -05:00
Israel Chauca Fuentes
739a3e606c Fix: extra space inserted after <Space> expansion. 2010-06-06 02:51:30 -05:00
Israel Chauca Fuentes
61cc934b68 Give some feedback for commands. 2010-06-06 02:35:15 -05:00
Israel Chauca Fuentes
7aec4532f9 Change log update and minor doc edits. 2010-06-06 00:41:09 -05:00
Israel Chauca Fuentes
6f22aab0b8 Minor changes. 2010-06-06 00:01:23 -05:00
Israel Chauca Fuentes
592cf2fea1 Fix arrow keys on terminal, #18. 2010-06-02 22:34:01 -05:00
Israel Chauca Fuentes
3d818560eb README update. 2010-05-24 22:16:23 -05:00
Israel Chauca Fuentes
da66a3f7c9 Syntax awareness. 2010-05-24 22:11:23 -05:00
Israel Chauca Fuentes
e5ce5b0967 Fix: automatic indent was broken when expanding <CR>. 2010-05-23 14:29:50 -05:00
Israel Chauca Fuentes
03342b8d22 Makefile update. 2010-05-16 23:59:48 -05:00
Israel Chauca Fuentes
86c1895ceb Small corrections. 2010-05-16 22:55:17 -05:00
Israel Chauca Fuentes
fd4fb482fe Little updates. 2010-05-16 22:19:11 -05:00
Israel Chauca Fuentes
0fbbc0f808 Makefile rewrite. 2010-05-16 22:11:09 -05:00
Israel Chauca Fuentes
ced80ebb21 Doc corrections. 2010-05-16 18:30:18 -05:00
Israel Chauca Fuentes
7b0d9367b2 README file added. 2010-05-16 18:05:45 -05:00
Israel Chauca Fuentes
37512d7f89 Doc update. 2010-05-15 17:41:06 -05:00
Israel Chauca Fuentes
f8b5bbe555 Doc update about b:vars in vimrc. 2010-05-15 17:29:57 -05:00
Israel Chauca Fuentes
698b3f1e43 Doc correction. 2010-05-14 03:19:46 -05:00
Israel Chauca Fuentes
bdf477de4b Doc update 2010-05-13 20:14:06 -05:00
Israel Chauca Fuentes
b03d5dce36 More changes to Tests.vim. 2010-05-13 18:00:51 -05:00
Israel Chauca Fuentes
03390cfb5f Small changes to Tests.vim. 2010-05-13 15:44:04 -05:00
Israel Chauca Fuentes
45c66a4d07 Fix no autoclose at start of line replaces right char. 2010-05-13 15:27:36 -05:00
Israel Chauca Fuentes
a317b6ead7 A couple of updates. 2010-05-12 20:33:43 -05:00
Israel Chauca Fuentes
ed672dd39b Fix duplicate closing delimiter after <CR> 2010-05-12 19:57:48 -05:00
Israel Chauca Fuentes
72e639ff1a Fix #17 <Left> didn't work. 2010-05-11 13:22:51 -05:00
Israel Chauca Fuentes
95c899f3e2 Fix #16 Finish() didn't reset the char buffer. 2010-05-11 09:58:17 -05:00
Israel Chauca Fuentes
6d4113e3c3 Updated documentation about switch command. 2010-05-11 01:40:15 -05:00
Israel Chauca Fuentes
8d720b8932 Implemented command to switch on/off. 2010-05-11 01:27:40 -05:00
Israel Chauca Fuentes
422420c494 Fix maps testing function. 2010-05-10 12:36:36 -05:00
Israel Chauca Fuentes
2c8b586679 Small fixes and documentation updates. 2010-05-09 15:23:30 -05:00
Israel Chauca Fuentes
e748b461b6 Forgot the Tests file. 2010-05-07 14:18:42 -05:00
Israel Chauca Fuentes
17a061a1fa Moved debugging functions outside script files. 2010-05-07 14:06:58 -05:00
Israel Chauca Fuentes
29d42e0771 Added Visual() and simplified VisualMaps(). 2010-05-07 10:54:20 -05:00
Israel Chauca Fuentes
e818c05e33 Moved and simplified UnMap(). 2010-05-06 02:04:30 -05:00
Israel Chauca Fuentes
29cb16c42e Many fixes. 2010-05-06 01:34:18 -05:00
Israel Chauca Fuentes
d478e75178 Fix Tests() and a couple other fucntions. 2010-05-05 11:55:05 -05:00
Israel Chauca Fuentes
eb03c7058e Added debuging function. 2010-05-04 12:28:10 -05:00
Israel Chauca Fuentes
1e7a5c7f6e Fix: Problem with jumping over pre-existing delims. 2010-05-03 13:21:24 -05:00
Israel Chauca Fuentes
b9bd9e3229 Fixed quotes, for re-do. 2010-05-03 03:35:58 -05:00
Israel Chauca Fuentes
b25906e610 Forgot to save <Del> fix :) 2010-05-03 03:22:41 -05:00
Israel Chauca Fuentes
5ca0eee4cd Fixed <Del> re-do-wise. 2010-05-03 03:21:31 -05:00
Israel Chauca Fuentes
a751498fbc Now re-do-safe, except for <CR> expansion. 2010-05-03 03:04:57 -05:00
Israel Chauca Fuentes
9292c9294a Move functions to autoload/ 2010-05-02 23:19:35 -05:00
Israel Chauca Fuentes
4083c581d6 Fixed issue #13 2010-05-02 21:34:29 -05:00
Israel Chauca Fuentes
86ff123318 Fixed a problem when 'keymap' was set before delimitmate was loaded. 2010-04-08 10:56:51 -05:00
Israel Chauca Fuentes
a8cbf2e429 More support for expansions & syntax groups. 2010-04-07 03:35:40 -05:00
Israel Chauca Fuentes
96d53eaa31 More fixes to the testing function. 2010-04-07 00:28:45 -05:00
Israel Chauca Fuentes
b5292f7c58 Fixed testing function. 2010-04-06 23:22:10 -05:00
Israel Chauca Fuentes
6b80cfefb6 Finished <S-Tab> for expansions. 2010-04-06 14:02:05 -05:00
Israel Chauca Fuentes
7540b37e8f <Space> expansion fixed. 2010-04-06 02:01:41 -05:00
Israel Chauca Fuentes
9c6b615397 Doc update, fix backspace & global functions.
Fixed a problem with MacVim and the Makefile.
2010-04-01 17:53:31 -05:00
Israel Chauca Fuentes
007da2c08a Documentation updated.
Fixed a minor glich with smart quotes.
Added version variable.
2010-04-01 01:47:08 -05:00
Israel Chauca Fuentes
5e8f9eacac Expansion functions are global now.
This could help when creating custom mappings for <CR> and <Space>.
2010-03-29 21:08:59 -05:00
Israel Chauca Fuentes
4c8f55722d Fixed some string to list conversions. 2010-03-29 19:48:31 -05:00
Israel Chauca Fuentes
00da04d835 Replaced all s:vars by b:vars. Fixed test function. 2010-03-29 03:26:19 -05:00
Israel Chauca Fuentes
8ba4a6ddd2 All operations are undo and history safe. 2010-03-26 11:00:28 -05:00
Israel Chauca Fuentes
4f2db7a481 Shift+Tab inside any empty pair will move the cursor out. 2010-03-24 02:55:06 -05:00
Israel Chauca Fuentes
23326b1178 - Shift + Backspace inside an empty pair will delete the closing delimiter. 2010-03-24 01:47:06 -05:00
Israel Chauca Fuentes
2e786b5ca6 Makefile fixed. 2010-03-23 02:02:39 -05:00
Israel Chauca Fuentes
4e63e5fe10 - Single quote after an alphanumeric character is an apostrophe.
- First attempt to behave nicely with an unbalanced quote.
2010-03-23 01:59:40 -05:00
Israel Chauca Fuentes
d3348192b8 Moved files to mirror their place inside the vim folder. 2010-03-02 20:29:04 -06:00
Israel Chauca Fuentes
6f0c91468a == 1.6 ==
Now delimitMate tries to fix the balancing of single quotes when used as apostrophes.
Fixed an error when b:delimitMate_expand_space wasn't set but g:delimitMate_expand_space was.
2009-10-15 23:59:54 -05:00
Israel Chauca Fuentes
75b4f3b520 == 1.5 ==
Fix: delimitMate should work as expected in files passed as arguments to Vim.
2009-10-05 05:48:09 -05:00
Israel Chauca Fuentes
3ce7f7ffcf === 1.4 ===
Fix: Fix: delimitMate is now enabled on new buffers even if they don't have set the file type option or were opened directly from the terminal.
2009-09-27 16:49:03 -05:00
Israel Chauca Fuentes
11b08278fa === 1.3 ===
Now local options can be used along with autocmd for specific file type configurations.
Fixes:
- Unnamed register content is not lost on visual mode.
- Use noremap where appropiate.
- Wrapping a single empty line works as expected.
2009-09-24 02:37:12 -05:00
Israel Chauca Fuentes
e0b8ef45ec - Fix: Recursive right delimiter deletion.
- Fix: Nested empty delimiter pairs would jump to the right instead of inserting the closing delimiter.
- Fix: New buffers didn't have mapping set.
2009-09-07 01:04:38 -05:00
Israel Chauca Fuentes
2fc82a7b7b *** 1.1 Release ***
Fixed problem with mapleader.
2009-08-25 09:51:06 -05:00
21 changed files with 2266 additions and 714 deletions

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
*.sw?
*.un?
*.vba
*.vmb
*.zip
*.gz
vimball.txt
*.orig
tags
test/build
test/*.tap
test/*.msgout

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.

15
Makefile Normal file
View File

@@ -0,0 +1,15 @@
.DEFAULT: test
test_files := $(wildcard test/*.test)
short_targets := $(patsubst test/%,%,$(test_files))
.PHONY: monitor test $(test_files) $(short_targets)
test:
$(MAKE) -C test
monitor:
$(MAKE) -C test monitor
$(test_files) $(short_targets):
$(MAKE) -C test $(patsubst test/%,%,$@)

6
README.md Normal file
View 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.

588
autoload/delimitMate.vim Normal file
View File

@@ -0,0 +1,588 @@
" Script variables {{{1
let s:defaults = {}
let s:defaults.enabled = 1
let s:defaults.pairs = ['()', '[]', '{}']
let s:defaults.quotes = ['"', "'", '`']
let s:defaults.debug = 0
let s:defaults.autoclose = 1
let s:defaults.expand_space = 0
let s:defaults.expand_cr = 0
let s:defaults.jump_expansion = 0
let s:defaults.jump_next = 1
let s:defaults.jump_long = 0
let s:defaults.insert_eol_marker = 0
let s:defaults.eol_marker = ';'
let s:defaults.expand_inside_quotes = 0
let s:defaults.smart_pairs = 1
let s:defaults.smart_pairs_extra = []
let s:defaults.balance_pairs = 0
let s:defaults.nesting_quotes = []
let s:defaults.smart_quotes = 1
let s:defaults.smart_quotes_extra = []
let s:defaults.excluded_regions = []
" Set smart_pairs expressions:
let s:exprs = []
call add(s:exprs, 'next_char =~# "\\w"')
call add(s:exprs, 'next_char =~# "[".escape(v:char,"\\^]")."€£$]"')
call add(s:exprs,
\'next_char =~# "[".escape(join(s:option("quotes"),""),"\\^]")."]"')
call add(s:exprs, 'ahead =~# "^[^[:space:][:punct:]]"')
let s:defaults.smart_pairs_base = s:exprs
" Set smart_quotes expressions:
let s:exprs = []
call add(s:exprs, 'prev_char =~# "\\w"')
call add(s:exprs, 'prev_char =~# "[^[:space:][:punct:]"
\.escape(join(options.quotes, ""), "\\^[]")."]"')
call add(s:exprs, 'next_char =~# "\\w"')
call add(s:exprs, 'char == "\"" && &filetype =~? "\\<vim\\>"
\&& line =~ "^\\s*$"')
call add(s:exprs, 'next_char =~# "[^[:space:][:punct:]"
\. escape(join(options.quotes, ""), "\\^[]")."]"')
" Balance quotes
call add(s:exprs, 'strchars(substitute(substitute(a:info.cur.line,
\"\\\\.", "", "g"), "[^".escape(char, "\\^[]")."]", "", "g")) % 2')
let s:defaults.smart_quotes_base = s:exprs
unlet s:exprs
let s:info = {}
let s:info.char = ''
let s:info.nesting = 0
let s:info.skip_icp = 0
let s:info.is_ignored_syn = 0
let s:info.template = {}
function! s:debug(debug_level, ...) "{{{1
if get(b:, 'delimitMate_debug',
\ get(g:, 'delimitMate_debug',
\ get(s:defaults, 'debug', 0)))
let trail = expand('<sfile>')
let trail = substitute(trail, '\%(\.\.<SNR>\d\+_debug\)\+$', '', '')
let trail = substitute(trail, '<SNR>\d\+_', '', 'g')
let trail = substitute(trail, '\.\.', '.', 'g')
let trail = substitute(trail, '^function\s\+\%(delimitMate\)\?', '', '')
let message = get(a:, 1, '')
echom printf('%s: %s', trail, message)
endif
endfunction
command! -nargs=* -count=3 DMDebug call s:debug(<count>, <args>)
function! s:defaults.consolidate() "{{{1
3DMDebug 'Consolidate options'
let g = filter(copy(g:), 'v:key =~# "^delimitMate_"')
let b = filter(copy(b:), 'v:key =~# "^delimitMate_"')
call extend(g, b, 'force')
let short_options = {}
call map(g, 'extend(short_options,
\{substitute(v:key, "^delimitMate_", "", ""): v:val}, "force")')
call extend(short_options, self, 'keep')
return short_options
endfunction
function! s:info.update() "{{{1
let self.prev = get(self, 'cur', {})
let d = {}
let d.line = getline('.')
let d.col = col('.')
let d.lnum = line('.')
let d.prev_line = line('.') == 1 ? '' : getline(line('.') - 1)
let d.next_line = line('.') == line('$') ? '' : getline(line('.') + 1)
let d.ahead = len(d.line) >= d.col ? d.line[d.col - 1 : ] : ''
let d.behind = d.col >= 2 ? d.line[: d.col - 2] : ''
let d.prev_char = strcharpart(d.behind, strchars(d.behind) - 1, 1)
let d.next_char = strcharpart(d.ahead, 0, 1)
let d.around = d.prev_char . d.next_char
call extend(d, s:info.template, 'keep')
1DMDebug printf('lnum: %s, col: %s, prev_char: %s, next_char: %s',
\ d.lnum, d.col, string(d.prev_char), string(d.next_char))
1DMDebug printf("behind: %s", d.behind)
1DMDebug printf("ahead : %s", d.ahead )
1DMDebug printf("prev_line: %s", d.prev_line)
1DMDebug printf('cur_line : %s', d.line)
1DMDebug printf('next_line: %s', d.next_line)
let self.cur = d
return d
endfunction
function! s:balance_pairs(pair, info, opts) "{{{1
let left = strcharpart(a:pair, 0, 1)
let right = strcharpart(a:pair, 1, 1)
let pat = '[^' . escape(a:pair, '\^[]') . ']'
let behind = substitute(a:info.cur.behind, '\\.', '', 'g')
let behind = matchstr(behind, '['.escape(left, '\^[]').'].*')
let behind = substitute(behind, pat, '', 'g')
let ahead = substitute(a:info.cur.ahead, '\\.', '', 'g')
let ahead = matchstr(ahead, '^.*['.escape(right, '\^[]').']')
let ahead = substitute(ahead, pat, '', 'g')
let lefts = 0
let rights = 0
for char in split(behind, '\zs')
if char ==# left
let lefts += 1
elseif char ==# right
let rights += rights < lefts
endif
endfor
let balance1 = lefts - rights
let lefts = 0
let rights = 0
let balance2 = 0
for char in split(ahead, '\zs')
if char ==# left
let lefts += 1
elseif char ==# right
let rights += 1
endif
if lefts < rights
let balance2 -= 1
let lefts = 0
let rights = 0
endif
endfor
3DMDebug balance1 + balance2
return balance1 + balance2
endfunction
function! s:info.template.is_escaped(...) "{{{1
3DMDebug
let str = a:0 ? a1 : self.behind
return len(matchstr(str, '\\*$')) % 2
endfunction
function! s:option(name) "{{{1
3DMDebug
let opt = get(b:, 'delimitMate_' . a:name,
\ get(g:, 'delimitMate_' . a:name,
\ get(s:defaults, a:name, '')))
3DMDebug printf('%s: %s', a:name, string(opt))
if type(opt) == 3 || type(opt) == 4
return copy(opt)
endif
return opt
endfunction
function! s:synstack(lnum, col) "{{{1
3DMDebug
return map(synstack(a:lnum, a:col), 'synIDattr(v:val, "name")')
\+ [synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')]
endfunction
function! s:any_is_true(expressions, info, options) "{{{1
let char = a:info.char
let info = deepcopy(a:info)
let options = deepcopy(a:options)
let line = info.cur.line
let lnum = info.cur.lnum
let col = info.cur.col
let behind = info.cur.behind
let ahead = info.cur.ahead
let prev_char = info.cur.prev_char
let next_char = info.cur.next_char
let exprs = copy(a:expressions)
call filter(exprs, 'eval(v:val)')
3DMDebug string(exprs)
return !empty(exprs)
endfunction
function! s:rights2jump_pair(char, pair, info, opts, go_next) "{{{1
" TODO consider escaped characters
let go_next = a:go_next
\ && empty(a:info.cur.ahead)
\ && a:info.cur.next_line =~# '^\s*['.escape(a:char, '[]^-\').']'
let line = a:info.cur.ahead
3DMDebug 'ahead: ' . line
let pair_pat = '[' . escape(a:pair, '[]^\-') . ']'
let char_pat = '[' . escape(a:char, '[]^\-') . ']'
let idx = match(line, pair_pat)
let balance = 0
while go_next || idx >= 0 && balance >= 0 && line[idx : ] !~# char_pat
if idx == -1
let idx = strchars(matchstr(a:info.cur.next_line, '^\s*\S'))
break
endif
if line[idx : ] =~# char_pat
let balance -= 1
else
let balance += 1
endif
let idx = match(line, pair_pat, idx + 1)
endwhile
3DMDebug 'idx: ' . idx
return idx + 1
endfunction
if line[idx : ] =~# char_pat
let balance -= 1
else
let balance += 1
endif
let idx = match(line, pair_pat, idx + 1)
endwhile
3DMDebug 'idx: ' . idx
return idx + 1
endfunction
function! s:keys4space(info, opts) "{{{1
2DMDebug string(a:opts)
let empty_pair = !empty(filter(copy(a:opts.pairs),
\'v:val ==# a:info.cur.around'))
if a:opts.expand_space && empty_pair
2DMDebug "expand space inside a pair"
return " \<C-G>U\<Left>"
endif
let empty_quotes = !empty(filter(copy(a:opts.quotes),
\'v:val.v:val ==# a:info.cur.around'))
if a:opts.expand_space && a:opts.expand_inside_quotes && empty_quotes
2DMDebug "expand space inside quotes"
return " \<C-G>U\<Left>"
endif
2DMDebug "do nothing"
return ''
endfunction
function! s:keys4left(char, pair, info, opts) "{{{1
"| cases | criteria | action options | action
"| | balance | auto balance back smart | close back
"|--------|----------|-----------------------------|------------
"| any | any | 0 0 1 1 | 0 0
"| any | any | 0 0 1 0 | 0 0
"| (|)) | -1 | 1 1 1 0 | 0 0
"| (|) | 0 | 1 1 1 0 | 1 1
"| ((|) | 1 | 1 1 1 0 | 1 0
if !a:opts.autoclose
2DMDebug "No autoclose"
return ''
endif
let exprs = a:opts.smart_pairs_base + a:opts.smart_pairs_extra
if a:opts.smart_pairs && s:any_is_true(exprs, a:info, a:opts)
2DMDebug "smart pairs"
return ''
endif
if a:opts.balance_pairs && s:balance_pairs(a:pair, a:info, a:opts) < 0
2DMDebug "balance pairs"
return ''
endif
let eol_marker = a:opts.insert_eol_marker == 1
\&& empty(a:info.cur.ahead) ? a:opts.eol_marker
\ . "\<C-G>U\<Left>" : ''
2DMDebug "add right delimiter"
let jump_back = a:opts.jump_back ? "\<C-G>U\<Left>" : ''
return "\<C-V>" . strcharpart(a:pair, 1, 1) . eol_marker . jump_back
endfunction
function! s:keys4right(char, pair, info, opts) "{{{1
"| cases | criteria | action options | action
"| | next prev close bal | next long bal | jump back
"|--------|---------------------|----------------|-----------
"| (|)) | 1 1 1 -1 | 1 1 0 | 1 0
"| (|) | 1 1 1 0 | 1 1 0 | 1 0
"| ((|) | 1 1 1 1 | 1 1 0 | 1 0
"| x|) | 1 0 1 -1 | 1 1 0 | 1 0
"| (x|) | 1 0 1 0 | 1 1 0 | 1 0
"| ((x|) | 1 0 1 1 | 1 1 1 | 1 0
"| (| | 0 1 0 1 | 0 0 1 | 0 1
"| |x) | 0 0 1 -1 | 0 1 0 | 1 0
"| (x|x)) | 0 0 1 -1 | 0 1 0 | 1 0
"| (x|x) | 0 0 1 0 | 0 1 0 | 1 0
"| ((x|x) | 0 0 1 1 | 0 0 1 | 0 1
"| x| | 0 0 0 0 | 0 0 0 | 0 0
"| (x| | 0 0 0 1 | 0 0 0 | 0 0
let previous = strcharpart(a:pair, 0, 1) ==# a:info.cur.prev_char
let is_cr_exp = a:opts.expand_cr
\ && empty(a:info.cur.ahead)
\ && matchstr(a:info.cur.next_line, '^\s*\zs\S') ==# a:char
let is_space_exp = a:opts.expand_space
\ && matchstr(a:info.cur.ahead, '^\s\zs\S') ==# a:char
let next = a:char ==# a:info.cur.next_char || is_cr_exp || is_space_exp
let balance = s:balance_pairs(a:pair, a:info, a:opts)
\ - is_cr_exp
let next_line = a:opts.jump_expansion && a:opts.expand_cr
let closing = s:rights2jump_pair(a:char, a:pair, a:info, a:opts, next_line)
let jump_opts = a:opts.jump_next + (a:opts.jump_long * 2)
2DMDebug 'is_cr_exp: ' . is_cr_exp
2DMDebug 'is_space_exp: ' . is_space_exp
2DMDebug 'next: ' . next
2DMDebug 'previous: ' . previous
2DMDebug 'closing: ' . closing
2DMDebug 'balance: ' . balance
2DMDebug 'next_line: ' . next_line
2DMDebug 'jump_opts: ' . jump_opts
if next
2DMDebug "next"
if closing && jump_opts && (!a:opts.balance_pairs || balance <= 0)
2DMDebug "cases: '(|)', '(|))' or '((|)'"
2DMDebug "cases: 'x|)', '(x|)' or '((x|)'"
return "\<BS>" . repeat("\<C-G>U\<Right>", closing)
endif
2DMDebug "Nothing to do"
return ''
endif
" !next
if previous
2DMDebug "!next && previous"
if (!a:opts.balance_pairs || balance > 0) && a:opts.jump_back
2DMDebug "case: '(|'"
return "\<C-G>U\<Left>"
endif
2DMDebug "Nothing to do"
return ''
endif
" !next && !previous
if closing
2DMDebug "!next && !previous && closing"
if (!a:opts.balance_pairs || balance <= 0) && jump_opts >= 2
2DMDebug "case: '(x|x))' or '(x|x)'"
return "\<BS>" . repeat("\<C-G>U\<Right>", closing)
elseif (!a:opts.balance_pairs || balance > 0) && a:opts.jump_back
2DMDebug "case: '((x|x)'"
return "\<C-G>U\<Left>"
endif
2DMDebug "Nothing to do"
return ''
endif
2DMDebug "Nothing to do"
return ''
endfunction
function! s:keys4quote(char, info, opts) "{{{1
let quotes_behind = strchars(matchstr(a:info.cur.behind,
\'['.escape(a:char, '\^[]').']*$'))
let quotes_ahead = strchars(matchstr(a:info.cur.ahead,
\'^['.escape(a:char, '\^[]').']*'))
2DMDebug quotes_behind . ' - ' . quotes_ahead
2DMDebug string(a:opts.nesting_quotes)
if a:opts.autoclose && index(a:opts.nesting_quotes, a:char) >= 0
\&& quotes_behind > 1
let add2right = quotes_ahead > quotes_behind + 1
\? 0 : quotes_behind - quotes_ahead + 1
2DMDebug "nesting quotes"
2DMDebug add2right
return repeat(a:char, add2right) . repeat("\<C-G>U\<Left>", add2right)
endif
if a:info.cur.next_char ==# a:char
2DMDebug "jump over quote"
return "\<Del>"
endif
if a:info.is_ignored_syn
return ''
endif
let exprs = a:opts.smart_quotes_base + a:opts.smart_quotes_extra
if a:opts.autoclose && a:opts.smart_quotes
\&& s:any_is_true(exprs, a:info, a:opts)
2DMDebug "smart quotes"
return ''
endif
if !a:opts.autoclose && quotes_behind
2DMDebug "don't autoclose, jump back"
return "\<C-G>U\<Left>"
endif
if !a:opts.autoclose
2DMDebug "don't autoclose"
return ''
endif
2DMDebug "jump back"
return a:char . "\<C-G>U\<Left>"
endfunction
function! s:keys4cr(info, opts) "{{{1
if a:opts.expand_cr
\&& !empty(filter(copy(a:opts.pairs),
\ 'v:val ==# a:info.prev.around'))
\|| (a:opts.expand_cr == 2
\ && !empty(filter(copy(a:opts.pairs),
\ 'strcharpart(v:val, 1, 1) == a:info.cur.next_char')))
" Empty pair
2DMDebug "expand CR inside pair"
let eol_marker = a:opts.insert_eol_marker == 2
\&& strchars(a:info.cur.ahead) == 1 ? a:opts.eol_marker : ''
return "0\<C-D>\<Del>x\<C-G>U\<Left>\<BS>\<CR>" . a:info.cur.next_char
\. "\<Del>" . eol_marker . "\<Up>\<End>\<CR>"
endif
if a:opts.expand_cr && a:opts.expand_inside_quotes
\&& !empty(filter(copy(a:opts.quotes),
\ 'v:val.v:val ==# a:info.prev.around'))
" Empty pair
2DMDebug "expand CR inside quotes"
return "\<Up>\<End>\<CR>"
endif
2DMDebug "do nothing"
return ''
endfunction
" vim: sw=2 et
function! delimitMate#option(name) "{{{1
return s:option(a:name)
endfunction
function! delimitMate#ex_cmd(global, action) "{{{1
1DMDebug 'action: ' . a:action . ', scope: ' . (a:global ? 'g:' : 'b:')
let scope = a:global ? g: : b:
if a:action ==# 'enable'
let scope.delimitMate_enabled = 1
elseif a:action ==# 'disable'
let scope.delimitMate_enabled = 0
elseif a:action ==# 'switch'
let scope.delimitMate_enabled = !s:option('enabled')
endif
endfunction
function! delimitMate#InsertEnter(...) "{{{1
1DMDebug
call s:info.update()
let s:info.skip_icp = 0
endfunction
function! delimitMate#CursorMovedI(...) "{{{1
1DMDebug
call s:info.update()
let s:info.skip_icp = 0
endfunction
function! delimitMate#InsertCharPre(str) "{{{1
1DMDebug
1DMDebug printf('v:char: %s', string(a:str))
if s:info.skip_icp
" iabbrev fires this event for every char and the trigger
1DMDebug "iabbrev expansion running"
return 0
endif
if pumvisible()
1DMDebug "pumvisible"
return 0
endif
if s:info.nesting
1DMDebug "nesting"
let s:info.nesting -= 1
return 0
endif
let s:info.skip_icp = 1
if !s:option('enabled')
1DMDebug "disabled"
return 0
endif
let typeahead = ''
let synstack = join(map(
\synstack(line('.'), col('.')),
\'tolower(synIDattr(v:val, "name"))'), ',')
let s:info.is_ignored_syn = !empty(filter(
\s:option('excluded_regions'),
\'stridx(synstack, tolower(v:val)) >= 0'))
" v:char could be more than one character
for char in split(a:str, '\zs')
1DMDebug 'char: ' . char
let keys = ''
let s:info.char = char
let opts = s:defaults.consolidate()
if s:info.cur.is_escaped()
1DMDebug "escaped"
return
elseif !empty(filter(copy(opts.quotes), 'v:val ==# char'))
1DMDebug "quote"
let keys = s:keys4quote(char, s:info, opts)
let s:info.nesting = strchars(matchstr(keys, '^[^[:cntrl:]]*'))
let s:info.nesting = s:info.nesting < 3 ? 0 : s:info.nesting
elseif s:info.is_ignored_syn
1DMDebug "ignored syn group"
return
elseif char == ' '
1DMDebug "space"
let keys = s:keys4space(s:info, opts)
elseif !empty(filter(copy(opts.pairs),
\'strcharpart(v:val, 0, 1) ==# char'))
1DMDebug "left delimiter"
let pair = get(filter(copy(opts.pairs),
\'strcharpart(v:val, 0, 1) ==# char'), 0, '')
let keys = s:keys4left(char, pair, s:info, opts)
elseif !empty(filter(copy(opts.pairs),
\'strcharpart(v:val, 1, 1) ==# char'))
let pair = get(filter(copy(opts.pairs),
\'strcharpart(v:val, 1, 1) ==# char'), 0, '')
let keys = s:keys4right(char, pair, s:info, opts)
1DMDebug "right delimiter"
else
1DMDebug "just ignore it"
return 0
endif
1DMDebug 'keys: ' . strtrans(keys)
let typeahead .= keys
endfor
if !empty(typeahead)
1DMDebug "feed typeahead: " . strtrans(typeahead)
call feedkeys(typeahead, 'tmi')
endif
endfunction
function! delimitMate#TextChangedI(...) "{{{1
1DMDebug
if pumvisible()
1DMDebug "pumvisible"
return 0
endif
if !s:option('enabled')
1DMDebug "disabled"
return
endif
if s:info.cur.lnum == s:info.prev.lnum + 1
\&& s:info.prev.behind ==# s:info.cur.prev_line
\&& s:info.prev.ahead ==# s:info.cur.ahead
\&& s:info.cur.behind =~ '^\s*$'
" CR
1DMDebug "CR at eol"
return feedkeys(s:keys4cr(s:info, s:defaults.consolidate()), 'tni')
endif
if s:info.cur.lnum == s:info.prev.lnum - 1
\&& s:info.prev.prev_line ==# s:info.cur.line
\&& s:info.prev.next_line ==# s:info.cur.next_line
let pair = filter(s:option('pairs'), 's:info.cur.prev_char
\. matchstr(s:info.cur.next_line, "^\\s*\\zs\\S") ==# v:val')
if s:option('expand_cr') && !empty(pair)
1DMDebug "CR expansion inside pair"
let spaces = strchars(s:info.cur.next_line, '^\s*')
return feedkeys(repeat("\<Del>", spaces), 'nti')
endif
let quote = filter(s:option('quotes'), 's:info.cur.prev_char
\. matchstr(s:info.cur.next_line, "^\\s*\\zs\\S") ==# v:val.v:val')
if s:option('expand_cr') && s:option('expand_inside_quotes')
\&& !empty(quote)
1DMDebug "CR expansion inside quotes"
return feedkeys("\<Del>")
endif
1DMDebug "BS at bol"
return
endif
if s:info.cur.lnum != s:info.prev.lnum
1DMDebug "Cursor changed line"
return
endif
if s:info.prev.col - s:info.cur.col != len(s:info.prev.prev_char)
1DMDebug "zero or several characters were deleted"
return
endif
if len(s:info.prev.line) == len(s:info.cur.line)
1DMDebug "Same line length"
return
endif
1DMDebug s:info.prev.around
let pair = filter(s:option('pairs'), 'v:val ==# (s:info.cur.prev_char
\ . matchstr(s:info.cur.ahead, "^\\s\\zs\\S"))')
let quotes = filter(s:option('quotes'),
\ 'v:val . v:val ==# (s:info.cur.prev_char
\ . matchstr(s:info.cur.ahead, "^\\s\\zs\\S"))')
if s:option('expand_space') && (!empty(pair)
\|| (s:option('expand_inside_quotes') && !empty(quotes)))
1DMDebug "Space expansion inside pair"
return feedkeys("\<Del>", 'tni')
endif
let pair = filter(s:option('pairs'), 'v:val ==# s:info.prev.around')
let quote = filter(s:option('quotes'),
\'v:val . v:val ==# s:info.prev.around')
if !empty(pair) || !empty(quote)
1DMDebug "BS inside empty pair or quotes"
let keys = "\<Del>"
return feedkeys(keys, 'tni')
endif
1DMDebug "Everything else"
return
endfunction

4
basic_vimrc Normal file
View File

@@ -0,0 +1,4 @@
so ./test/_setup.vim
let delimitMate_expand_cr = 1
filetype indent plugin on

View File

@@ -1,343 +0,0 @@
*delimitMate.txt* Trying to keep those beasts at bay!
REFERENCE MANUAL *
==============================================================================
0.- CONTENTS *delimitMate-contents*
1. Introduction____________________________|delimitMate|
2. Functionality___________________________|delimitMateFunctionality|
2.1 Automatic closing & exiting________|delimitMateAutoClose|
2.2 Expansion of space and CR__________|delimitMateExpansion|
2.3 Deletion of empty pairs____________|delimitMateBackspace|
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
3. Customization___________________________|delimitMateOptions|
3.1 Option summary_____________________|delimitMateOptionSummary|
3.2 Options details____________________|delimitMateOptionDetails|
4. Public commands_________________________|delimitMatePublicCommands|
5. TODO list_______________________________|delimitMateTodo|
6. Maintainer______________________________|delimitMateMaintainer|
7. Credits_________________________________|delimitMateCredits|
==============================================================================
1.- INTRODUCTION *delimitMate*
The delimitMate plugin tries to provide some not so dumb help in the work with
delimiters (brackets, quotes, etc.), with some optional auto-completions and
expansions.
When automatic closing is enabled, if an opening delimiter is inserted
delimitMate inserts the closing pair and places the cursor between them. When
automatic closing is disabled, no closing delimiters is inserted by
delimitMate, but if a pair of delimiters is typed, the cursor is placed in the
middle. Also, to get out of a pair of delimiters just type the right delimiter
and the cursor will jump to the right.
If the cursor is inside an empty pair of delimiters <Space> and <CR> can be
expanded to follow your coding style, you just need to define a couple of
options with the desired mappings for them.
==============================================================================
2. FUNCTIONALITY PROVIDED *delimitMateFunctionality*
------------------------------------------------------------------------------
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
With automatic closing enabled, if an opening delimiter is inserted the plugin
inserts the closing delimiter and places the cursor between the pair. With
automatic closing disabled, no closing delimiters is inserted by delimitMate,
but when a pair of delimiters is typed, the cursor is placed in the middle.
When the cursor is inside an empty pair or located next to the left of a
closing delimiter, the cursor is placed outside the pair to the right of the
closing delimiter.
Unless |'b:delimitMate_matchpairs'| and |'b:delimitMate_quotes'|is set, this
script uses the values in '&matchpirs' to identify the pairs, and "\" ' ` "
for quotes respectively.
The following table shows the behaviour, this applies to quotes too (the final
position of the cursor is represented by a "|"):
With auto-close: >
Type | You get
====================
( | (|)
|
() | ()|
<
Without auto-close: >
Type | You get
====================
() | (|)
|
()) | ()|
<
------------------------------------------------------------------------------
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
expanded to follow your coding style with |'b:delimitMate_expand_space'| and
|'b:delimitMate_expand_cr'|. e.g. (cursor represented by a "|"):
Expand <Space> to: >
<Space><Space><Left> | You get
====================================
(|) | ( | )
<
Expand <CR> to: >
<CR><CR><Up> | You get
============================
(|) | (
| |
| )
<
------------------------------------------------------------------------------
2.3 DELETION OF EMPTY PAIR *delimitMateBackspace*
If you press backspace inside an empty pair, both delimiters are deleted.
e.g.: >
Before | After
====================================
call expand(|) | call expand|
<
------------------------------------------------------------------------------
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
When visual mode is active this script allows for the selection to be enclosed
with delimiters. But, since brackets have special meaning in visual mode, a
leader (the value of 'mapleader' by default) should precede the delimiter.
This feature doesn't currently work on blockwise visual mode, any suggestions
will be welcome.
e.g. (selection represented between square brackets): >
Selected text | After q"
=============================================
An [absurd] example! | An "absurd" example!
<
==============================================================================
3. CUSTOMIZATION *delimitMateOptions*
------------------------------------------------------------------------------
3.1 OPTIONS SUMMARY *delimitMateOptionSummary*
The behaviour of this script can be customized setting the following options
in your vimrc file.
|'loaded_delimitMate'| Turns off the script.
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
insert the closing delimiter.
|'b:delimitMate_matchpairs'| Tells delimitMate which characters are
matching pairs.
|'b:delimitMate_quotes'| Tells delimitMate which quotes should be
used.
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|'b:delimitMate_expand_cr'| Sets the expansion for <CR> inside an empty
pair of matching delimiters or quotes.
|'b:delimitMate_expand_space'| Sets the expansion for <Space> inside an
empty pair of matching delimiters or quotes.
------------------------------------------------------------------------------
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
Add the shown lines to your vimrc files in order to set the below options.
*'loaded_delimitMate'*
You can turn off this plugin using this line in your vimrc: >
let loaded_delimitMate = 1
<
------------------------------------------------------------------------------
*'delimitMate_autoclose'*
Values: 0 or 1.
Default: 1
If this option is set to 0, delimitMate will not add a closing delimiter
automagically. See |delimitMateAutoClose| for details.
e.g.: >
let delimitMate_autoclose = 0
<
------------------------------------------------------------------------------
*'b:delimitMate_matchpairs'*
Values: A string with |matchpairs| syntax.
Default: &matchpairs
Use this option to tell delimitMate which characters should be considered
matching pairs. Read |delimitMateAutoClose| for details.
e.g: >
let delimitMate = "(:),[:],{:},<:>"
<
------------------------------------------------------------------------------
*'b:delimitMate_quotes'*
Values: A string of characters separated by spaces.
Default: "\" ' `"
Use this option to tell delimitMate which characters should be considered as
quotes. Read |delimitMateAutoClose| for details.
e.g.: >
let b:delimitMate_quotes = "\" ' ` *"
<
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
Values: Any character.
Default: q
The value of this option will be used to wrap the selection in visual mode
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
e.g: >
let delimitMate_visual_leader = "f"
<
------------------------------------------------------------------------------
*'b:delimitMate_expand_cr'*
Values: A key mapping.
Default: "\<CR>"
The value of this option will be used to expand the car return character when
typed inside an empty delimiter pair. Read |delimitMateExpansion| for details.
e.g.: >
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
<
------------------------------------------------------------------------------
*'b:delimitMate_expand_space'*
Values: A key mapping.
Default: "\<Space>"
The value of this option will be used to expand the space character when typed
inside an empty delimiter pair. Read |delimitMateExpansion| for details.
e.g.: >
let b:delimitMate_expand_space = "\<Space>\<Space>\<Left>"
<
==============================================================================
4. PUBLIC COMMANDS *delimitMatePublicCommands*
------------------------------------------------------------------------------
:DelimitMateReload *:DelimitMateReload*
Re-sets all the mappings used for this script, use it if any option has been
changed.
------------------------------------------------------------------------------
:DelimitMateTest *:DelimitMateTest*
This command tests every mapping set-up for this script, useful for testing
custom configurations.
The following output corresponds to the default values, it will be different
depending on your configuration. "Open & close:" represents the final result
when the closing delimiter has been inserted, either manually or
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
"Visual-R" and "Visual" shows visual wrapping, see
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|delimitMateExpansion|. The cursor's position at the end of every test is
represented by an "|": >
* AUTOCLOSE:
Open & close: (|)
Delete: |
Exit: ()|
Space: ( |)
Visual-L: (v)
Visual-R: (v)
Car return: (
|)
Open & close: {|}
Delete: |
Exit: {}|
Space: { |}
Visual-L: {v}
Visual-R: {v}
Car return: {
|}
Open & close: [|]
Delete: |
Exit: []|
Space: [ |]
Visual-L: [v]
Visual-R: [v]
Car return: [
|]
Open & close: "|"
Delete: |
Exit: ""|
Space: " |"
Visual: "v"
Car return: "
|"
Open & close: '|'
Delete: |
Exit: ''|
Space: ' |'
Visual: 'v'
Car return: '
|'
Open & close: `|`
Delete: |
Exit: ``|
Space: ` |`
Visual: `v`
Car return: `
|`
<
==============================================================================
5. TODO LIST *delimitMateTodo*
- Automatic set-up by file type.
- Make visual wrapping work on blockwise visual mode.
- Limit behaviour by region.
- Fix some problems wrapping a single empty line in visual mode.
==============================================================================
6. MAINTAINER *delimitMateMaintainer*
Hi there! My name is Israel Chauca F. and I can be reached at:
mailto:israelchauca@gmail.com
Feel free to send me any suggestions and/or comments about this plugin, I'll
be very pleased to read them.
==============================================================================
7. CREDITS *delimitMateCredits*
Some of the code that make this script is modified or just shamelessly copied
from the following sources:
- 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
This script was inspired by the auto-completion of delimiters of TextMate.
vim:tw=78:ts=8:ft=help:norl:

View File

@@ -1,371 +0,0 @@
" ============================================================================
" File: delimitMate.vim
" Version: 1.0
" Description: This plugin tries to emulate the auto-completion of delimiters
" that TextMate provides.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" 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/
if exists("g:loaded_delimitMate") && !exists("g:delimitMate_testing") "{{{1
" Don't define the functions if they already exist: just do the work (unless we are testing):
call s:DelimitMateDo()
finish
endif
if v:version < 700
echoerr "delimitMate: this plugin requires vim >= 7!"
finish
endif
let g:loaded_delimitMate = 1
function! s:Init() "{{{1
if !exists("g:delimitMate_autoclose")
let s:autoclose = 1
else
let s:autoclose = g:delimitMate_autoclose
endif
if !exists("b: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
else
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
endif
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
else
let s:quotes = split("\" ' `")
endif
if !exists("g:delimitMate_visual_leader")
let s:visual_leader = g:mapleader
else
let s:visual_leader = g:delimitMate_visual_leader
endif
if !exists("b:delimitMate_expand_space")
let s:expand_space = "\<Space>"
elseif b:delimitMate_expand_space == ""
let s:expand_space = "\<Space>"
else
let s:expand_space = b:delimitMate_expand_space
endif
if !exists("b:delimitMate_expand_cr")
let s:expand_return = "\<CR>"
elseif b:delimitMate_expand_cr == ""
let s:expand_return = "\<CR>"
else
let s:expand_return = b:delimitMate_expand_cr
endif
let s:matchpairs = split(s:matchpairs_temp, ',')
let s:left_delims = split(s:matchpairs_temp, ':.,\=')
let s:right_delims = split(s:matchpairs_temp, ',\=.:')
let s:VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
endfunction
function! s:ValidMatchpairs(str) "{{{1
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
endfunc
function! s:IsEmptyPair(str) "{{{1
for pair in s:matchpairs
if a:str == join( split( pair, ':' ),'' )
return 1
endif
endfor
for quote in s:quotes
if a:str == quote . quote
return 1
endif
endfor
return 0
endfunc
function! s:WithinEmptyPair() "{{{1
let cur = strpart( getline('.'), col('.')-2, 2 )
return s:IsEmptyPair( cur )
endfunc
function! s:SkipDelim(char) "{{{1
let cur = strpart( getline('.'), col('.')-2, 3 )
if cur[0] == "\\"
return a:char
elseif cur[1] == a:char
return "\<Right>"
elseif cur[1] == ' ' && cur[2] == a:char
" I'm leaving this in case someone likes it.
return "\<Right>\<Right>"
elseif s:IsEmptyPair( cur[0] . a:char )
return a:char . "\<Left>"
else
return a:char
endif
endfunc
function! s:QuoteDelim(char) "{{{1
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
return a:char.a:char."\<Left>"
endif
endf
function! s:ClosePair(char) "{{{1
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
function! s:ResetMappings() "{{{1
for delim in s:right_delims + s:left_delims + s:quotes
silent! exec 'iunmap <buffer> ' . delim
silent! exec 'vunmap <buffer> ' . s:visual_leader . delim
endfor
silent! iunmap <buffer> <CR>
silent! iunmap <buffer> <Space>
endfunction
function! s:MapMsg(msg) "{{{1
redraw
echomsg a:msg
return ""
endfunction
function! s:NoAutoClose() "{{{1
" imap <buffer> ) <C-R>=<SID>SkipDelim('\)')<CR>
for delim in s:right_delims + s:quotes
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>SkipDelim("' . escape(delim,'"') . '")<CR>'
endfor
" Wrap the selection with delimiters, but do nothing if blockwise visual mode is active:
for i in range(len(s:matchpairs))
" Map left delimiter:
" vmap <buffer> <expr> q( visualmode() == "<C-V>" ? <SID>MapMsg(VMapMsg) : "s(\<C-R>\")\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . s:left_delims[i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[i] . '\<C-R>\"' . s:right_delims[i] . '\<Esc>"'
" Map right delimiter:
" vmap <buffer> <expr> q) visualmode() == "<C-V>" ? <SID>MapMsg(VMapMsg) : "s(\<C-R>\")\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[i] . '\<C-R>\"' . s:right_delims[i] . '"'
endfor
for quote in s:quotes
" vmap <buffer> <expr> q" visualmode() == "<C-V>" ? <SID>MapMsg(VMapMsg) : "s'\<C-R>\"'\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . quote . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') . '\<C-R>\"' . escape(quote,'"') . '\<Esc>"'
endfor
endfunction
function! s:AutoClose() "{{{1
" Add matching pair and jump to the midle:
" imap <buffer> ( ()<Left>
let s:i = 0
while s:i < len(s:matchpairs)
exec 'imap <buffer> ' . s:left_delims[s:i] . ' ' . s:left_delims[s:i] . s:right_delims[s:i] . '<Left>'
let s:i += 1
endwhile
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
" imap <buffer> " <C-R>=<SID>QuoteDelim("\"")<CR>
for delim in s:quotes
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>QuoteDelim("\' . delim . '")<CR>'
endfor
" Exit from inside the matching pair:
" imap <buffer> ) <C-R>=<SID>ClosePair(')')<CR>
for delim in s:right_delims
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>ClosePair("\' . delim . '")<CR>'
endfor
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
let s:i = 0
while s:i < len(s:matchpairs)
" Map left delimiter:
" vmap <buffer> <expr> q( visualmode() == "<C-V>" ? <SID>MapMsg("Message") : "s(\<C-R>\"\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . s:left_delims[s:i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\"\<Esc>"'
" Map right delimiter:
" vmap <buffer> <expr> q) visualmode() == "<C-V>" ? <SID>MapMsg("Message") : "s(\<C-R>\""\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[s:i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\""'
let s:i += 1
endwhile
" Wrap the selection with matching quotes, but do nothing if blockwise visual mode is active:
for quote in s:quotes
" vmap <buffer> <expr> q' visualmode() == "<C-V>" ? <SID>MapMsg("Message") : "s'\<C-R>\"'\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . quote . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') .'\<C-R>\"' . escape(quote,'"') . '\<Esc>"'
endfor
endfunction
function! s:ExpandReturn() "{{{1
if s:WithinEmptyPair()
return s:expand_return
else
return "\<CR>"
endif
endfunction
function! s:ExpandSpace() "{{{1
if s:WithinEmptyPair()
return s:expand_space
else
return "\<Space>"
endif
endfunction
function! s:ExtraMappings() "{{{1
" If pair is empty, delete both delimiters:
imap <buffer> <expr> <BS> <SID>WithinEmptyPair() ? "\<Right>\<BS>\<BS>" : "\<BS>"
" Expand return if inside an empty pair:
imap <buffer> <CR> <C-R>=<SID>ExpandReturn()<CR>
" Expand space if inside an empty pair:
imap <buffer> <Space> <C-R>=<SID>ExpandSpace()<CR>
endfunction
function! s:TestMappings() "{{{1
if s:autoclose
exec "normal i* AUTOCLOSE:\<CR>"
for i in range(len(s:left_delims))
exec "normal GGAOpen & close: " . s:left_delims[i]. "|"
exec "normal A\<CR>Delete: " . s:left_delims[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . s:left_delims[i] . s:right_delims[i] . "|"
exec "normal A\<CR>Space: " . s:left_delims[i] . " |"
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . s:visual_leader . s:left_delims[i]
exec "normal A\<CR>Visual-R: v\<Esc>v" . s:visual_leader . s:right_delims[i]
exec "normal A\<CR>Car return: " . s:left_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
endfor
for i in range(len(s:quotes))
exec "normal GGAOpen & close: " . s:quotes[i] . "|"
exec "normal A\<CR>Delete: " . s:quotes[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . s:quotes[i] . s:quotes[i] . "|"
exec "normal A\<CR>Space: " . s:quotes[i] . " |"
exec "normal GGA\<CR>Visual: v\<Esc>v" . s:visual_leader . s:quotes[i]
exec "normal A\<CR>Car return: " . s:quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
endfor
else
exec "normal i* NO AUTOCLOSE:\<CR>"
for i in range(len(s:left_delims))
exec "normal GGAOpen & close: " . s:left_delims[i] . s:right_delims[i] . "|"
exec "normal A\<CR>Delete: " . s:left_delims[i] . s:right_delims[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . s:left_delims[i] . s:right_delims[i] . s:right_delims[i] . "|"
exec "normal A\<CR>Space: " . s:left_delims[i] . s:right_delims[i] . " |"
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . s:visual_leader . s:left_delims[i]
exec "normal A\<CR>Visual-R: v\<Esc>v" . s:visual_leader . s:right_delims[i]
exec "normal A\<CR>Car return: " . s:left_delims[i] . s:right_delims[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
endfor
for i in range(len(s:quotes))
exec "normal GGAOpen & close: " . s:quotes[i] . s:quotes[i] . "|"
exec "normal A\<CR>Delete: " . s:quotes[i] . s:quotes[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . s:quotes[i] . s:quotes[i] . s:quotes[i] . "|"
exec "normal A\<CR>Space: " . s:quotes[i] . s:quotes[i] . " |"
exec "normal GGA\<CR>Visual: v\<Esc>v" . s:visual_leader . s:quotes[i]
exec "normal A\<CR>Car return: " . s:quotes[i] . s:quotes[i] . "\<CR>|\<Esc>GGA\<CR>\<CR>"
endfor
endif
exec "normal \<Esc>"
endfunction
function! s:SwitchAutoclose() "{{{1
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:TestMappingsDo() "{{{1
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() "{{{1
try
let s:save_cpo = &cpo
set cpo&vim
call s:Init()
call s:ResetMappings()
if s:autoclose
call s:AutoClose()
else
call s:NoAutoClose()
endif
call s:ExtraMappings()
finally
let &cpo = s:save_cpo
endtry
endfunction
" Do the real work: {{{1
call s:DelimitMateDo()
" Let me refresh without re-loading the buffer:
command! DelimitMateReload call s:DelimitMateDo()
" Quick test:
command! DelimitMateTest call s:TestMappingsDo()
" vim:foldmethod=marker:foldcolumn=2

943
doc/delimitMate.txt Normal file
View File

@@ -0,0 +1,943 @@
*delimitMate.txt* Trying to keep those beasts at bay! v2.7 *delimitMate*
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
==============================================================================
0.- CONTENTS *delimitMate-contents*
1. Introduction____________________________|delimitMateIntro|
2. Customization___________________________|delimitMateOptions|
2.1 Options summary____________________|delimitMateOptionSummary|
2.2 Options details____________________|delimitMateOptionDetails|
3. Functionality___________________________|delimitMateFunctionality|
3.1 Automatic closing & exiting________|delimitMateAutoClose|
3.2 Expansion of space and CR__________|delimitMateExpansion|
3.3 Backspace__________________________|delimitMateBackspace|
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
3.5 Balancing matching pairs___________|delimitMateBalance|
3.6 FileType based configuration_______|delimitMateFileType|
3.7 Syntax awareness___________________|delimitMateSyntax|
4. Commands________________________________|delimitMateCommands|
5. Mappings________________________________|delimitMateMappings|
6. Functions_______________________________|delimitMateFunctions|
7. Autocommands____________________________|delimitMateAutocmds|
8. TODO list_______________________________|delimitMateTodo|
9. Maintainer______________________________|delimitMateMaintainer|
10. Credits_________________________________|delimitMateCredits|
11. History_________________________________|delimitMateHistory|
==============================================================================
1.- INTRODUCTION *delimitMateIntro*
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.
Most of the features can be modified or disabled permanently, using global
variables, or on a FileType basis, using autocommands.
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
in a new buffer to see what is not working.
NOTE 2: Abbreviations set with |:iabbrev| will not be expanded by delimiters
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
the go.
==============================================================================
2. CUSTOMIZATION *delimitMateOptions*
You can create your own mappings for some features using the global functions.
Read |delimitMateFunctions| for more info.
------------------------------------------------------------------------------
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
The behaviour of this script can be customized setting the following options
in your vimrc file. You can use local options to set the configuration for
specific file types, see |delimitMateOptionDetails| for examples.
|'loaded_delimitMate'| Turns off the script.
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
insert the closing delimiter.
|'delimitMate_matchpairs'| Tells delimitMate which characters are
matching pairs.
|'delimitMate_quotes'| Tells delimitMate which quotes should be
used.
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
allowed to be nested.
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|'delimitMate_jump_expansion'| Turns on/off jumping over expansions.
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature.
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
feature.
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
syntax group names.
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|'delimitMate_eol_marker'| Determines what to insert after the closing
matchpair when typing an opening matchpair on
the end of the line.
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
balancing of single quotes when used as
apostrophes. NOTE: Not needed any more, kept
for compatibility with older versions.
------------------------------------------------------------------------------
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
Add the shown lines to your vimrc file in order to set the below options.
Buffer variables take precedence over global ones and can be used along with
autocmd to modify delimitMate's behavior for specific file types, read more in
|delimitMateFileType|.
Note: Use buffer variables only to set options for specific file types using
:autocmd, use global variables to set options for all buffers. Read more in
|g:var| and |b:var|.
------------------------------------------------------------------------------
*'loaded_delimitMate'*
*'b:loaded_delimitMate'*
This option prevents delimitMate from loading.
e.g.: >
let loaded_delimitMate = 1
au FileType mail let b:loaded_delimitMate = 1
<
------------------------------------------------------------------------------
*'delimitMate_offByDefault'*
Values: 0 or 1.~
Default: 0~
If this option is set to 1, delimitMate will load, but will not take
effect in any buffer unless |:DelimitMateSwitch| is called in that
buffer.
------------------------------------------------------------------------------
*'delimitMate_autoclose'*
*'b:delimitMate_autoclose'*
Values: 0 or 1. ~
Default: 1 ~
If this option is set to 0, delimitMate will not add a closing delimiter
automagically. See |delimitMateAutoClose| for details.
e.g.: >
let delimitMate_autoclose = 0
au FileType mail let b:delimitMate_autoclose = 0
<
------------------------------------------------------------------------------
*'delimitMate_matchpairs'*
*'b:delimitMate_matchpairs'*
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
characters.~
Default: &matchpairs ~
Use this option to tell delimitMate which characters should be considered
matching pairs. Read |delimitMateAutoClose| for details.
e.g: >
let delimitMate_matchpairs = "(:),[:],{:},<:>"
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
<
------------------------------------------------------------------------------
*'delimitMate_quotes'*
*'b:delimitMate_quotes'*
Values: A string of characters separated by spaces. ~
Default: "\" ' `" ~
Use this option to tell delimitMate which characters should be considered as
quotes. Read |delimitMateAutoClose| for details.
e.g.: >
let delimitMate_quotes = "\" ' ` *"
au FileType html let b:delimitMate_quotes = "\" '"
<
------------------------------------------------------------------------------
*'delimitMate_nesting_quotes'*
*'b:delimitMate_nesting_quotes'*
Values: A list of quotes. ~
Default: [] ~
When adding a third quote listed in this option is inserted, three quotes will
be inserted to the right of the cursor and the cursor will stay in the middle.
If more quotes are inserted the number of quotes on both sides of the cursor
will stay balanced.
e.g.: >
let delimitMate_nesting_quotes = ['"','`']
au FileType python let b:delimitMate_nesting_quotes = ['"']
<
------------------------------------------------------------------------------
*'delimitMate_expand_cr'*
*'b:delimitMate_expand_cr'*
Values: 0, 1 or 2 ~
Default: 0 ~
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
for details. NOTE This feature requires that 'backspace' is either set to 2 or
has "eol" and "start" as part of its value.
e.g.: >
let delimitMate_expand_cr = 1
au FileType mail let b:delimitMate_expand_cr = 1
<
------------------------------------------------------------------------------
*'delimitMate_expand_space'*
*'b:delimitMate_expand_space'*
Values: 1 or 0 ~
Default: 0 ~
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
for details.
e.g.: >
let delimitMate_expand_space = 1
au FileType tcl let b:delimitMate_expand_space = 1
<
------------------------------------------------------------------------------
*'delimitMate_expand_inside_quotes'*
*'b:delimitMate_expand_inside_quotes'*
Values: 1 or 0 ~
Default: 0 ~
When this option is set to 1 the expansion of space and cr will also be
applied to quotes. Read |delimitMateExpansion| for details.
e.g.: >
let delimitMate_expand_inside_quotes = 1
au FileType mail let b:delimitMate_expand_inside_quotes = 1
<
------------------------------------------------------------------------------
*'delimitMate_jump_expansion'*
*'b:delimitMate_jump_expansion'*
Values: 1 or 0 ~
Default: 0 ~
This option turns on/off the jumping over <CR> and <Space> expansions when
inserting closing matchpairs. Read |delimitMateExpansion| for details.
e.g.: >
let delimitMate_jump_expansion = 1
au FileType tcl let b:delimitMate_jump_expansion = 1
<
------------------------------------------------------------------------------
*'delimitMate_smart_quotes'*
*'b:delimitMate_smart_quotes'*
Values: String with an optional ! at the beginning followed by a regexp ~
Default:~
'\%(\w\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]]\)' ~
A bang (!) at the beginning is removed and used to "negate" the pattern. The
remaining text is used as a regexp to be matched on the current line. A single
quote is inserted when the pattern matches and a bang is not present. The bang
changes that, so a single quote is inserted only if the regexp does not match.
This feature is disabled when the variable is set to an empty string, with the
exception of apostrophes.
Note that you need to use '\%#' to match the position of the cursor. Keep in
mind that '\%#' matches with zero width, so if you need to match the char
under the cursor (which would be the one to the right on insert mode) use
something like '\%#.'.
e.g.: >
let delimitMate_smart_quotes = '\w\%#'
au FileType tcl let b:delimitMate_smart_quotes = '!\s\%#\w'
<
------------------------------------------------------------------------------
*'delimitMate_smart_matchpairs'*
*'b:delimitMate_smart_matchpairs'*
Values: Regexp ~
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
moment to match the text, an escaped bang (\!) in the regex will be replaced
by the character being inserted, while an escaped number symbol (\#) will be
replaced by the closing pair.
e.g.: >
let delimitMate_smart_matchpairs = ''
au FileType tcl let b:delimitMate_smart_matchpairs = '^\%(\w\|\$\)'
<
------------------------------------------------------------------------------
*'delimitMate_balance_matchpairs'*
*'b:delimitMate_balance_matchpairs'*
Values: 1 or 0 ~
Default: 0 ~
This option turns on/off the balancing of matching pairs. Read
|delimitMateBalance| for details.
e.g.: >
let delimitMate_balance_matchpairs = 1
au FileType tcl let b:delimitMate_balance_matchpairs = 1
<
------------------------------------------------------------------------------
*'delimitMate_excluded_regions'*
Values: A string of syntax group names names separated by single commas. ~
Default: Comment ~
This options turns delimitMate off for the listed regions, read |group-name|
for more info about what is a region.
e.g.: >
let delimitMate_excluded_regions = "Comment,String"
<
------------------------------------------------------------------------------
*'delimitMate_excluded_ft'*
Values: A string of file type names separated by single commas. ~
Default: Empty. ~
This options turns delimitMate off for the listed file types, use this option
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. ~
Default: Empty. ~
The contents of this string will be inserted after the closing matchpair or
quote when the respective opening matchpair or quote is inserted at the end
of the line.
e.g.: >
au FileType c,perl let b:delimitMate_eol_marker = ";"
<
------------------------------------------------------------------------------
*'delimitMate_apostrophes'*
Values: Strings separated by ":". ~
Default: No longer used. ~
NOTE: This feature is turned off by default, it's been kept for compatibility
with older version, read |delimitMateSmartQuotes| for details.
If auto-close is enabled, this option tells delimitMate how to try to fix the
balancing of single quotes when used as apostrophes. The values of this option
are strings of text where a single quote would be used as an apostrophe (e.g.:
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
disable this feature.
e.g.: >
let delimitMate_apostrophes = ""
au FileType tcl let delimitMate_apostrophes = ""
<
==============================================================================
3. FUNCTIONALITY *delimitMateFunctionality*
------------------------------------------------------------------------------
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
With automatic closing enabled, if an opening delimiter is inserted the plugin
inserts the closing delimiter and places the cursor between the pair. With
automatic closing disabled, no closing delimiters is inserted by delimitMate,
but when a pair of delimiters is typed, the cursor is placed in the middle.
When the cursor is inside an empty pair or located next to the left of a
closing delimiter, the cursor is placed outside the pair to the right of the
closing delimiter.
When |'delimitMate_smart_matchpairs'| is not empty and it matches the text to
the right of the cursor, delimitMate will not automatically insert the closing
pair.
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
for quotes respectively.
<S-Tab> will jump over a single closing delimiter or quote, <C-G>g will jump
over contiguous delimiters and/or quotes.
The following table shows the behaviour, this applies to quotes too (the final
position of the cursor is represented by a "|"):
With auto-close: >
Type | You get
=======================
( | (|)
|
() | ()|
|
(<S-Tab> | ()|
|
{("<C-G>g | {("")}|
<
Without auto-close: >
Type | You get
=========================
() | (|)
-----|
()) | ()|
-----|
()<S-Tab> | ()|
|
{}()""<C-G>g | {("")}|
<
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
------------------------------------------------------------------------------
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
When the cursor is inside an empty pair of any matchpair, <Space> and <CR> can be
expanded, see |'delimitMate_expand_space'| and
|'delimitMate_expand_cr'|:
Expand <Space> to: >
You start with | You get
==============================
(|) | ( | )
<
Expand <CR> to: >
You start with | You get
==============================
(|) | (
| |
| )
<
When you have |'delimitMate_jump_expansion'| enabled, if there is an existing
closing paren/bracket/etc. on the next line, delimitMate will make the cursor
jump over any whitespace/<CR> and place it after the existing closing
delimiter instead of inserting a new one.
When |'delimitMate_expand_cr'| is set to 2, the following will also happen: >
You start with | You get
==============================
(foo|) | (foo
| |
| )
<
Since <Space> and <CR> are used everywhere, I have made the functions involved
in expansions global, so they can be used to make custom mappings. Read
|delimitMateFunctions| for more details.
------------------------------------------------------------------------------
3.3 BACKSPACE *delimitMateBackspace*
If you press backspace inside an empty pair, both delimiters are deleted. When
expansions are enabled, <BS> will also delete the expansions.
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
will be deleted. NOTE that this will not usually work when using Vim from the
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
e.g. typing at the "|": >
What | Before | After
==============================================
<BS> | call expand(|) | call expand|
---------|-------------------|-----------------
<BS> | call expand( | ) | call expand(|)
---------|-------------------|-----------------
<BS> | call expand( | call expand(|)
| | |
| ) |
---------|-------------------|-----------------
<S-BS> | call expand(|) | call expand(|
<
------------------------------------------------------------------------------
3.4 SMART QUOTES *delimitMateSmartQuotes*
Only one quote will be inserted following a quote, a "\", following or
preceding a keyword character, or when the number of quotes in the current
line is odd. This should cover closing quotes after a string, opening quotes
before a string, escaped quotes and apostrophes. See more details about
customizing this feature on |'delimitMate_smart_quotes'|.
e.g. typing at the "|": >
What | Before | After
=======================================
" | Text | | Text "|"
" | "String| | "String"|
" | let i = "| | let i = "|"
'm | I| | I'm|
<
------------------------------------------------------------------------------
3.4 SMART MATCHPAIRS *delimitMateSmartMatchpairs*
This is similar to "smart quotes", but applied to the characters in
|'delimitMate_matchpairs'|. The difference is that delimitMate will not
auto-close the pair when the regex matches the text on the right of the
cursor. See |'delimitMate_smart_matchpairs'| for more details.
e.g. typing at the "|": >
What | Before | After
=======================================
( | function| | function(|)
( | |var | (|var
<
------------------------------------------------------------------------------
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
enabled, delimitMate will try to balance the closing pairs in the current
line.
e.g. typing at the "|": >
What | Before | After
=======================================
( | | | (|)
( | |) | (|)
(( | |) | ((|))
<
------------------------------------------------------------------------------
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
delimitMate options can be set globally for all buffers using global
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
options for specific file types (see |'filetype'|) using buffer variables in
the following way: >
au FileType mail,text let b:delimitMate_autoclose = 0
^ ^ ^ ^ ^
| | | | |
| | | | - Option value.
| | | - Option name.
| | - Buffer variable.
| - File types for which the option will be set.
- Don't forget to put this event.
<
NOTE that you should use buffer variables (|b:var|) only to set options with
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
------------------------------------------------------------------------------
3.7 SYNTAX AWARENESS *delimitMateSyntax*
The features of this plug-in might not be always helpful, comments and strings
usualy don't need auto-completion. delimitMate monitors which region is being
edited and if it detects that the cursor is in a comment it'll turn itself off
until the cursor leaves the comment. The excluded regions can be set using the
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
regions or syntax group names.
NOTE that this feature relies on a proper syntax file for the current file
type, if the appropiate syntax file doesn't define a region, delimitMate won't
know about it.
==============================================================================
4. COMMANDS *delimitMateCommands*
------------------------------------------------------------------------------
:DelimitMateReload *:DelimitMateReload*
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*
Switches the plug-in on and off.
------------------------------------------------------------------------------
:DelimitMateTest *:DelimitMateTest*
This command tests every mapping set-up for this script, useful for testing
custom configurations.
The following output corresponds to the default values, it will be different
depending on your configuration. "Open & close:" represents the final result
when the closing delimiter has been inserted, either manually or
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
"Visual-R" and "Visual" shows visual wrapping, see
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|delimitMateExpansion|. The cursor's position at the end of every test is
represented by an "|": >
* AUTOCLOSE:
Open & close: (|)
Delete: |
Exit: ()|
Space: ( |)
Visual-L: (v)
Visual-R: (v)
Car return: (
|)
Open & close: {|}
Delete: |
Exit: {}|
Space: { |}
Visual-L: {v}
Visual-R: {v}
Car return: {
|}
Open & close: [|]
Delete: |
Exit: []|
Space: [ |]
Visual-L: [v]
Visual-R: [v]
Car return: [
|]
Open & close: "|"
Delete: |
Exit: ""|
Space: " |"
Visual: "v"
Car return: "
|"
Open & close: '|'
Delete: |
Exit: ''|
Space: ' |'
Visual: 'v'
Car return: '
|'
Open & close: `|`
Delete: |
Exit: ``|
Space: ` |`
Visual: `v`
Car return: `
|`
<
==============================================================================
5. MAPPINGS *delimitMateMappings*
delimitMate doesn't override any existing map, so you may encounter that it
doesn't work as expected because a mapping is missing. In that case, the
conflicting mappings should be resolved by either disabling the conflicting
mapping or creating a custom mappings.
In order to make custom mappings easier and prevent overwritting existing
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
for its mappings.
These are the default mappings for the extra features:
<BS> is mapped to <Plug>delimitMateBS
<S-BS> is mapped to <Plug>delimitMateS-BS
<S-Tab> is mapped to <Plug>delimitMateS-Tab
<C-G>g is mapped to <Plug>delimitMateJumpMany
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
depend on the values of the delimitMate options, they have the following form:
<Plug>delimitMate + char
e.g.: for "(":
( is mapped to <Plug>delimitMate(
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
menus:
imap <expr> <CR> pumvisible()
\ ? "\<C-Y>"
\ : "<Plug>delimitMateCR"
==============================================================================
6. FUNCTIONS *delimitMateFunctions*
------------------------------------------------------------------------------
delimitMate#WithinEmptyPair() *delimitMate#WithinEmptyPair()*
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
e.g.: >
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
\ "<Plug>delimitMateCR" :
\ "external_mapping"
<
------------------------------------------------------------------------------
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
Returns 1 if there is a closing delimiter or a quote to the right of the
cursor, 0 otherwise.
------------------------------------------------------------------------------
delimitMate#JumpAny() *delimitMate#JumpAny()*
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 <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.
==============================================================================
8. TODO LIST *delimitMateTodo*
- Automatic set-up by file type.
- Make block-wise visual wrapping work on un-even regions.
==============================================================================
9. MAINTAINER *delimitMateMaintainer*
Hi there! My name is Israel Chauca F. and I can be reached at:
mailto:israelchauca@gmail.com
Feel free to send me any suggestions and/or comments about this plugin, I'll
be very pleased to read them.
==============================================================================
10. CREDITS *delimitMateCredits*
Contributors: ~
- Kim Silkebækken ~
Fixed mappings being echoed in the terminal.
- Eric Van Dewoestine ~
Implemented smart matchpairs.
Some of the code that makes this script was modified or just shamelessly
copied from the following sources:
- 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
- Karl Guertin ~
AutoClose:
http://www.vim.org/scripts/script.php?script_id=1849
- Thiago Alves ~
AutoClose:
http://www.vim.org/scripts/script.php?script_id=2009
- Edoardo Vacchi ~
ClosePairs:
http://www.vim.org/scripts/script.php?script_id=2373
This script was inspired by the auto-completion of delimiters on TextMate.
==============================================================================
11. HISTORY *delimitMateHistory*
Version Date Release notes ~
|---------|------------|-----------------------------------------------------|
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.
- Stop using setline().
- Better handling of nested quotes.
- Allow a custom pattern for smart_quotes.
|---------|------------|-----------------------------------------------------|
2.6 2011-01-14 * - Add smart_matchpairs feature.
- Add mapping to jump over contiguous delimiters.
- Fix behaviour of b:loaded_delimitMate.
|---------|------------|-----------------------------------------------------|
2.5.1 2010-09-30 * - Remove visual wrapping. Surround.vim offers a much
better implementation.
- Minor mods to DelimitMateTest.
|---------|------------|-----------------------------------------------------|
2.5 2010-09-22 * - Better handling of mappings.
- Add report for mappings in |:DelimitMateTest|.
- Allow the use of "|" and multi-byte characters in
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
- Allow commands to be concatenated using |.
|---------|------------|-----------------------------------------------------|
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
- Add missing doc on |'delimitMate_smart_quotes'|,
|delimitMateBalance| and
|'delimitMate_balance_matchpairs'|.
|---------|------------|-----------------------------------------------------|
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
- Visual wrapping now works on block-wise visual
with some limitations.
- Arrow keys didn't work on terminal.
- Added option to allow nested quotes.
- Expand Smart Quotes to look for a string on the
right of the cursor.
|---------|------------|-----------------------------------------------------|
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
expansion.
|---------|------------|-----------------------------------------------------|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
or other regions, customizable.
- Changed format of most mappings.
- Fix: <CR> expansion doesn't break automatic
indentation adjustments anymore.
- Fix: Arrow keys would insert A, B, C or D instead
of moving the cursor when using Vim on a terminal.
|---------|------------|-----------------------------------------------------|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
- Fix: some problems with <Left>, <Right> and <CR>.
- Fix: A small problem when inserting a delimiter at
the beginning of the line.
|---------|------------|-----------------------------------------------------|
2.1 2010-05-10 * - Most of the functions have been moved to an
autoload script to avoid loading unnecessary ones.
- Fixed a problem with the redo command.
- Many small fixes.
|---------|------------|-----------------------------------------------------|
2.0 2010-04-01 * New features:
- All features are redo/undo-wise safe.
- A single quote typed after an alphanumeric
character is considered an apostrophe and one
single quote is inserted.
- A quote typed after another quote inserts a single
quote and the cursor jumps to the middle.
- <S-Tab> jumps out of any empty pair.
- <CR> and <Space> expansions are fixed, but the
functions used for it are global and can be used in
custom mappings. The previous system is still
active if you have any of the expansion options
set.
- <S-Backspace> deletes the closing delimiter.
* Fixed bug:
- s:vars were being used to store buffer options.
|---------|------------|-----------------------------------------------------|
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
quotes when used as apostrophes. You can read
|delimitMate_apostrophes| for details.
Fixed an error when |b:delimitMate_expand_space|
wasn't set but |delimitMate_expand_space| wasn't.
|---------|------------|-----------------------------------------------------|
1.5 2009-10-05 * Fix: delimitMate should work correctly for files
passed as arguments to Vim. Thanks to Ben Beuchler
for helping to nail this bug.
|---------|------------|-----------------------------------------------------|
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
if they don't have set the file type option or were
opened directly from the terminal.
|---------|------------|-----------------------------------------------------|
1.3 2009-09-24 * Now local options can be used along with autocmd
for specific file type configurations.
Fixes:
- Unnamed register content is not lost on visual
mode.
- Use noremap where appropiate.
- Wrapping a single empty line works as expected.
|---------|------------|-----------------------------------------------------|
1.2 2009-09-07 * Fixes:
- When inside nested empty pairs, deleting the
innermost left delimiter would delete all right
contiguous delimiters.
- When inside an empty pair, inserting a left
delimiter wouldn't insert the right one, instead
the cursor would jump to the right.
- New buffer inside the current window wouldn't
have the mappings set.
|---------|------------|-----------------------------------------------------|
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
set and added support for GetLatestScripts
auto-detection.
|---------|------------|-----------------------------------------------------|
1.0 2009-08-23 * Initial upload.
|---------|------------|-----------------------------------------------------|
`\|||/´ MMM \|/ www __^__ ~
(o o) (o o) @ @ (O-O) /(o o)\\ ~
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
vim:tw=78:et:ts=8:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:

22
plugin/delimitMate.vim Normal file
View File

@@ -0,0 +1,22 @@
if exists("g:loaded_delimitMate") || &cp || !exists('##InsertCharPre')
finish
endif
let g:loaded_delimitMate = 1
let save_cpo = &cpo
set cpo&vim
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!
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: sw=2 et

14
test/Makefile Normal file
View File

@@ -0,0 +1,14 @@
test_files := $(wildcard *.test)
.PHONY: all monitor $(test_files)
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"

18
test/README.md Normal file
View 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

11
test/_setup.vim Normal file
View File

@@ -0,0 +1,11 @@
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
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

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:

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:

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