mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-08 13:44:47 +08:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
becbd2d353 | ||
|
|
382c36bf57 | ||
|
|
537a1da0fa | ||
|
|
055978491a | ||
|
|
16687aec24 | ||
|
|
728b57a656 | ||
|
|
98143957cf | ||
|
|
b5719054be | ||
|
|
39d8f522f7 | ||
|
|
8bc47fd1c4 | ||
|
|
bc97837c71 | ||
|
|
d24ad6b301 | ||
|
|
81de76fe52 | ||
|
|
5945fdfd14 | ||
|
|
9a77c3aee6 | ||
|
|
342a04b427 | ||
|
|
03e94587ae | ||
|
|
c78a6e6d93 | ||
|
|
470c053a3b | ||
|
|
254a89d67c | ||
|
|
e7b4dedb84 | ||
|
|
21a3ade90c | ||
|
|
8e30e70bcd | ||
|
|
ac792c01b6 | ||
|
|
c23ef684e3 | ||
|
|
b63924f2b2 | ||
|
|
07b7cc969f | ||
|
|
13e52d42ae | ||
|
|
aa9d737763 | ||
|
|
bf2b68edab | ||
|
|
fe9022433d | ||
|
|
6f7e6413ce | ||
|
|
a9a37854da | ||
|
|
0739792d01 | ||
|
|
6f4f1b06d3 | ||
|
|
0049b07a1c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
*.sw?
|
*.sw?
|
||||||
*.un?
|
*.un?
|
||||||
*.vba
|
*.vba
|
||||||
|
*.vmb
|
||||||
*.zip
|
*.zip
|
||||||
*.gz
|
*.gz
|
||||||
vimball.txt
|
vimball.txt
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -4,7 +4,6 @@ LIB = $(wildcard autoload/*.vim)
|
|||||||
SOURCES += $(LIB)
|
SOURCES += $(LIB)
|
||||||
DOC = $(wildcard doc/*.txt)
|
DOC = $(wildcard doc/*.txt)
|
||||||
SOURCES += $(DOC)
|
SOURCES += $(DOC)
|
||||||
#NAME = $(shell basename "$$PWD")
|
|
||||||
NAME = delimitMate
|
NAME = delimitMate
|
||||||
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
|
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
|
||||||
FILENAME = $(NAME)-$(VERSION)
|
FILENAME = $(NAME)-$(VERSION)
|
||||||
@@ -28,8 +27,8 @@ clean:
|
|||||||
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
|
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile)'
|
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile|basic_vimrc)(.)'
|
||||||
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile)*'
|
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile|basic_vimrc)*'
|
||||||
|
|
||||||
undo:
|
undo:
|
||||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||||
@@ -74,7 +73,7 @@ done;
|
|||||||
zip $@ $^
|
zip $@ $^
|
||||||
|
|
||||||
%.vmb.gz: vimball
|
%.vmb.gz: vimball
|
||||||
gzip -f $(basename $@)
|
gzip -f < $(basename $@) > $@
|
||||||
|
|
||||||
%.tar.gz: $(SOURCES)
|
%.tar.gz: $(SOURCES)
|
||||||
tar -cvzf $@ $^
|
tar -cvzf $@ $^
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -34,10 +34,11 @@
|
|||||||
4. Commands________________________________|delimitMateCommands|
|
4. Commands________________________________|delimitMateCommands|
|
||||||
5. Mappings________________________________|delimitMateMappings|
|
5. Mappings________________________________|delimitMateMappings|
|
||||||
6. Functions_______________________________|delimitMateFunctions|
|
6. Functions_______________________________|delimitMateFunctions|
|
||||||
7. TODO list_______________________________|delimitMateTodo|
|
7. Autocommands____________________________|delimitMateAutocmds|
|
||||||
8. Maintainer______________________________|delimitMateMaintainer|
|
8. TODO list_______________________________|delimitMateTodo|
|
||||||
9. Credits_________________________________|delimitMateCredits|
|
9. Maintainer______________________________|delimitMateMaintainer|
|
||||||
10. History_________________________________|delimitMateHistory|
|
10. Credits_________________________________|delimitMateCredits|
|
||||||
|
11. History_________________________________|delimitMateHistory|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1.- INTRODUCTION *delimitMateIntro*
|
1.- INTRODUCTION *delimitMateIntro*
|
||||||
@@ -60,7 +61,7 @@ the go.
|
|||||||
2. CUSTOMIZATION *delimitMateOptions*
|
2. CUSTOMIZATION *delimitMateOptions*
|
||||||
|
|
||||||
You can create your own mappings for some features using the global functions.
|
You can create your own mappings for some features using the global functions.
|
||||||
Read |DelimitMateFunctions| for more info.
|
Read |delimitMateFunctions| for more info.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||||
@@ -190,6 +191,8 @@ e.g.: >
|
|||||||
let delimitMate_nesting_quotes = ['"','`']
|
let delimitMate_nesting_quotes = ['"','`']
|
||||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||||
<
|
<
|
||||||
|
For Python this is set by default by the plugin.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_expand_cr'*
|
*'delimitMate_expand_cr'*
|
||||||
*'b:delimitMate_expand_cr'*
|
*'b:delimitMate_expand_cr'*
|
||||||
@@ -265,7 +268,7 @@ e.g.: >
|
|||||||
*'delimitMate_smart_matchpairs'*
|
*'delimitMate_smart_matchpairs'*
|
||||||
*'b:delimitMate_smart_matchpairs'*
|
*'b:delimitMate_smart_matchpairs'*
|
||||||
Values: Regexp ~
|
Values: Regexp ~
|
||||||
Default: '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)' ~
|
Default: '^\%(\w\|\!\|[£$]\|[^[:space:][:punct:]]\)' ~
|
||||||
|
|
||||||
This regex is matched against the text to the right of cursor, if it's not
|
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
|
empty and there is a match delimitMate will not autoclose the pair. At the
|
||||||
@@ -308,6 +311,21 @@ only if you don't want any of the features it provides on those file types.
|
|||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
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'*
|
*'delimitMate_eol_marker'*
|
||||||
Values: String. ~
|
Values: String. ~
|
||||||
@@ -368,11 +386,11 @@ With auto-close: >
|
|||||||
Type | You get
|
Type | You get
|
||||||
=======================
|
=======================
|
||||||
( | (|)
|
( | (|)
|
||||||
–––––––––––|–––––––––––
|
-----------|-----------
|
||||||
() | ()|
|
() | ()|
|
||||||
–––––––––––|–––––––––––
|
-----------|-----------
|
||||||
(<S-Tab> | ()|
|
(<S-Tab> | ()|
|
||||||
–––––––––––|–––––––––––
|
-----------|-----------
|
||||||
{("<C-G>g | {("")}|
|
{("<C-G>g | {("")}|
|
||||||
<
|
<
|
||||||
Without auto-close: >
|
Without auto-close: >
|
||||||
@@ -380,11 +398,11 @@ Without auto-close: >
|
|||||||
Type | You get
|
Type | You get
|
||||||
=========================
|
=========================
|
||||||
() | (|)
|
() | (|)
|
||||||
–––––––––-----|––––––––––
|
--------------|----------
|
||||||
()) | ()|
|
()) | ()|
|
||||||
–––––––––-----|––––––––––
|
--------------|----------
|
||||||
()<S-Tab> | ()|
|
()<S-Tab> | ()|
|
||||||
––––––––––––––|–––––––––––
|
--------------|----------
|
||||||
{}()""<C-G>g | {("")}|
|
{}()""<C-G>g | {("")}|
|
||||||
<
|
<
|
||||||
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||||
@@ -547,6 +565,16 @@ know about it.
|
|||||||
Re-sets all the mappings used for this script, use it if any option has been
|
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.
|
changed or if the filetype option hasn't been set yet.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
:DelimitMateOn *:DelimitMateOn*
|
||||||
|
|
||||||
|
Enable delimitMate mappings.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
:DelimitMateOff *:DelimitMateOff*
|
||||||
|
|
||||||
|
Disable delimitMate mappings.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
:DelimitMateSwitch *:DelimitMateSwitch*
|
:DelimitMateSwitch *:DelimitMateSwitch*
|
||||||
|
|
||||||
@@ -669,7 +697,7 @@ Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
|||||||
e.g.: >
|
e.g.: >
|
||||||
|
|
||||||
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
\ "<Plug>delimitMateCR" :
|
||||||
\ "external_mapping"
|
\ "external_mapping"
|
||||||
<
|
<
|
||||||
|
|
||||||
@@ -686,17 +714,50 @@ This function returns a mapping that will make the cursor jump to the right
|
|||||||
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny()<CR>
|
inoremap <expr> <C-Tab> delimitMate#JumpAny()
|
||||||
<
|
<
|
||||||
|
==============================================================================
|
||||||
|
7. AUTOCOMMANDS *delimitMateAutocmds*
|
||||||
|
|
||||||
|
delimitMate emits 2 |User| autocommands to make it easier for users to
|
||||||
|
leverage delimitMate's support for per-filetype customization.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
delimitMate_map *delimitMate_map*
|
||||||
|
|
||||||
|
This |User| event is emittted just prior to delimitMate defining its
|
||||||
|
buffer-local key mappings. You can use this command to define your own
|
||||||
|
mappings that are disabled when delimitMate is turned off or excludes the
|
||||||
|
current filetype.
|
||||||
|
>
|
||||||
|
au User delimitMate_map call s:delimitMate_map()
|
||||||
|
function s:delimitMate_map()
|
||||||
|
imap <buffer><expr> <C-Tab> delimitMate#JumpAny()
|
||||||
|
endfunction
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
delimitMate_unmap *delimitMate_unmap*
|
||||||
|
|
||||||
|
This |User| event is emitted just after delimitMate clears its buffer-local
|
||||||
|
key mappings. You can use this command to clear your own mappings that you set
|
||||||
|
in response to |delimitMate_map|.
|
||||||
|
>
|
||||||
|
au User delimitMate_unmap call s:delimitMate_unmap()
|
||||||
|
function s:delimitMate_unmap()
|
||||||
|
silent! iunmap <buffer> <C-Tab>
|
||||||
|
endfunction
|
||||||
|
<
|
||||||
|
Note: This event may be emitted before |delimitMate_map|, and may be emitted
|
||||||
|
multiple times in a row without any intervening |delimitMate_map| events.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. TODO LIST *delimitMateTodo*
|
8. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make block-wise visual wrapping work on un-even regions.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. MAINTAINER *delimitMateMaintainer*
|
9. MAINTAINER *delimitMateMaintainer*
|
||||||
|
|
||||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||||
mailto:israelchauca@gmail.com
|
mailto:israelchauca@gmail.com
|
||||||
@@ -705,7 +766,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
|
|||||||
be very pleased to read them.
|
be very pleased to read them.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. CREDITS *delimitMateCredits*
|
10. CREDITS *delimitMateCredits*
|
||||||
|
|
||||||
Contributors: ~
|
Contributors: ~
|
||||||
|
|
||||||
@@ -741,12 +802,14 @@ copied from the following sources:
|
|||||||
This script was inspired by the auto-completion of delimiters on TextMate.
|
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
10. HISTORY *delimitMateHistory*
|
11. HISTORY *delimitMateHistory*
|
||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.7 2013-07-15 * Current release:
|
2.8 2013-07-15 * Current release:
|
||||||
- Lots of bug fixes.
|
- Add :DelimitMateOn & :DelimitMateOff.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.7 2013-07-15 * - Lots of bug fixes.
|
||||||
- Add delimitMate_offByDefault.
|
- Add delimitMate_offByDefault.
|
||||||
- Add delimitMate_eol_marker.
|
- Add delimitMate_eol_marker.
|
||||||
- Reduce the number of mappings.
|
- Reduce the number of mappings.
|
||||||
|
|||||||
@@ -9,391 +9,395 @@
|
|||||||
" Initialization: {{{
|
" Initialization: {{{
|
||||||
|
|
||||||
if exists("g:loaded_delimitMate") || &cp
|
if exists("g:loaded_delimitMate") || &cp
|
||||||
" User doesn't want this plugin or compatible is set, let's get out!
|
" User doesn't want this plugin or compatible is set, let's get out!
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_delimitMate = 1
|
let g:loaded_delimitMate = 1
|
||||||
let save_cpo = &cpo
|
let save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
if v:version < 700
|
if v:version < 700
|
||||||
echoerr "delimitMate: this plugin requires vim >= 7!"
|
echoerr "delimitMate: this plugin requires vim >= 7!"
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1
|
let s:loaded_delimitMate = 1
|
||||||
let delimitMate_version = "2.7"
|
let delimitMate_version = "2.8"
|
||||||
|
|
||||||
function! s:option_init(name, default) "{{{
|
|
||||||
let b = exists("b:delimitMate_" . a:name)
|
|
||||||
let g = exists("g:delimitMate_" . a:name)
|
|
||||||
" Find value to use.
|
|
||||||
if !b && !g
|
|
||||||
let value = a:default
|
|
||||||
elseif b
|
|
||||||
exec "let value = b:delimitMate_" . a:name
|
|
||||||
else
|
|
||||||
exec "let value = g:delimitMate_" . a:name
|
|
||||||
endif
|
|
||||||
call s:s(a:name, value)
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! s:init() "{{{
|
|
||||||
" Initialize variables:
|
|
||||||
" autoclose
|
|
||||||
call s:option_init("autoclose", 1)
|
|
||||||
" matchpairs
|
|
||||||
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
|
||||||
call s:option_init("matchpairs_list", map(split(s:g('matchpairs'), ','), 'split(v:val, '':'')'))
|
|
||||||
let pairs = s:g('matchpairs_list')
|
|
||||||
if len(filter(pairs, 'v:val[0] ==# v:val[1]'))
|
|
||||||
echohl ErrorMsg
|
|
||||||
echom 'delimitMate: each member of a pair in delimitMate_matchpairs must be different from each other.'
|
|
||||||
echom 'delimitMate: invalid pairs: ' . join(map(pairs, 'join(v:val, ":")'), ', ')
|
|
||||||
echohl Normal
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
call s:option_init("left_delims", map(copy(s:g('matchpairs_list')), 'v:val[0]'))
|
|
||||||
call s:option_init("right_delims", map(copy(s:g('matchpairs_list')), 'v:val[1]'))
|
|
||||||
" quotes
|
|
||||||
call s:option_init("quotes", "\" ' `")
|
|
||||||
call s:option_init("quotes_list",split(s:g('quotes'), '\s\+'))
|
|
||||||
" nesting_quotes
|
|
||||||
call s:option_init("nesting_quotes", [])
|
|
||||||
" excluded_regions
|
|
||||||
call s:option_init("excluded_regions", "Comment")
|
|
||||||
call s:option_init("excluded_regions_list", split(s:g('excluded_regions'), ',\s*'))
|
|
||||||
let enabled = len(s:g('excluded_regions_list')) > 0
|
|
||||||
call s:option_init("excluded_regions_enabled", enabled)
|
|
||||||
" excluded filetypes
|
|
||||||
call s:option_init("excluded_ft", "")
|
|
||||||
" expand_space
|
|
||||||
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
|
||||||
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
|
||||||
echom "Read :help 'delimitMate_expand_space' for more details."
|
|
||||||
unlet b:delimitMate_expand_space
|
|
||||||
let b:delimitMate_expand_space = 1
|
|
||||||
endif
|
|
||||||
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("")
|
|
||||||
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!"
|
|
||||||
echom "Read :help 'delimitMate_expand_space' for more details."
|
|
||||||
unlet g:delimitMate_expand_space
|
|
||||||
let g:delimitMate_expand_space = 1
|
|
||||||
endif
|
|
||||||
call s:option_init("expand_space", 0)
|
|
||||||
" expand_cr
|
|
||||||
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
|
||||||
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
|
||||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
|
||||||
unlet b:delimitMate_expand_cr
|
|
||||||
let b:delimitMate_expand_cr = 1
|
|
||||||
endif
|
|
||||||
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
|
||||||
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
|
||||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
|
||||||
unlet g:delimitMate_expand_cr
|
|
||||||
let g:delimitMate_expand_cr = 1
|
|
||||||
endif
|
|
||||||
if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) &&
|
|
||||||
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
|
||||||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
|
||||||
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
|
|
||||||
endif
|
|
||||||
call s:option_init("expand_cr", 0)
|
|
||||||
" expand_in_quotes
|
|
||||||
call s:option_init('expand_inside_quotes', 0)
|
|
||||||
" jump_expansion
|
|
||||||
call s:option_init("jump_expansion", 0)
|
|
||||||
" smart_matchpairs
|
|
||||||
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)')
|
|
||||||
" smart_quotes
|
|
||||||
" XXX: backward compatibility. Ugly, should go the way of the dodo soon.
|
|
||||||
let quotes = escape(join(s:g('quotes_list'), ''), '\-^[]')
|
|
||||||
let default_smart_quotes = '\%(\w\|[^[:punct:][:space:]' . quotes . ']\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]' . quotes . ']\)'
|
|
||||||
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) == type(0)
|
|
||||||
if g:delimitMate_smart_quotes
|
|
||||||
unlet g:delimitMate_smart_quotes
|
|
||||||
else
|
|
||||||
unlet g:delimitMate_smart_quotes
|
|
||||||
let g:delimitMate_smart_quotes = ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if exists('b:delimitMate_smart_quotes') && type(b:delimitMate_smart_quotes) == type(0)
|
|
||||||
if b:delimitMate_smart_quotes
|
|
||||||
unlet b:delimitMate_smart_quotes
|
|
||||||
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) && g:delimitMate_smart_quotes
|
|
||||||
let b:delimitMate_smart_quotes = default_smart_quotes
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
unlet b:delimitMate_smart_quotes
|
|
||||||
let b:delimitMate_smart_quotes = ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
call s:option_init("smart_quotes", default_smart_quotes)
|
|
||||||
" apostrophes
|
|
||||||
call s:option_init("apostrophes", "")
|
|
||||||
call s:option_init("apostrophes_list", split(s:g('apostrophes'), ":\s*"))
|
|
||||||
" tab2exit
|
|
||||||
call s:option_init("tab2exit", 1)
|
|
||||||
" balance_matchpairs
|
|
||||||
call s:option_init("balance_matchpairs", 0)
|
|
||||||
" eol marker
|
|
||||||
call s:option_init("eol_marker", "")
|
|
||||||
" Everything is fine.
|
|
||||||
return 1
|
|
||||||
endfunction "}}} Init()
|
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Functions: {{{
|
" Functions: {{{
|
||||||
|
|
||||||
function! s:g(...) " {{{
|
function! s:option_init(name, default) "{{{
|
||||||
return call('delimitMate#Get', a:000)
|
let opt_name = "delimitMate_" . a:name
|
||||||
endfunction " }}}
|
" Find value to use.
|
||||||
|
if !has_key(b:, opt_name) && !has_key(g:, opt_name)
|
||||||
|
let value = a:default
|
||||||
|
elseif has_key(b:, opt_name)
|
||||||
|
let value = b:[opt_name]
|
||||||
|
else
|
||||||
|
let value = g:[opt_name]
|
||||||
|
endif
|
||||||
|
call s:set(a:name, value)
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:s(...) " {{{
|
function! s:init() "{{{
|
||||||
return call('delimitMate#Set', a:000)
|
" Initialize variables:
|
||||||
|
" autoclose
|
||||||
|
call s:option_init("autoclose", 1)
|
||||||
|
" matchpairs
|
||||||
|
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||||
|
call s:option_init("matchpairs_list", map(split(s:get('matchpairs', ''), '.:.\zs,\ze.:.'), 'split(v:val, ''^.\zs:\ze.$'')'))
|
||||||
|
let pairs = s:get('matchpairs_list', [])
|
||||||
|
if len(filter(pairs, 'v:val[0] ==# v:val[1]'))
|
||||||
|
echohl ErrorMsg
|
||||||
|
echom 'delimitMate: each member of a pair in delimitMate_matchpairs must be different from each other.'
|
||||||
|
echom 'delimitMate: invalid pairs: ' . join(map(pairs, 'join(v:val, ":")'), ', ')
|
||||||
|
echohl Normal
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
call s:option_init("left_delims", map(copy(s:get('matchpairs_list', [])), 'v:val[0]'))
|
||||||
|
call s:option_init("right_delims", map(copy(s:get('matchpairs_list', [])), 'v:val[1]'))
|
||||||
|
" quotes
|
||||||
|
call s:option_init("quotes", "\" ' `")
|
||||||
|
call s:option_init("quotes_list",split(s:get('quotes', ''), '\s\+'))
|
||||||
|
" nesting_quotes
|
||||||
|
call s:option_init("nesting_quotes", [])
|
||||||
|
" excluded_regions
|
||||||
|
call s:option_init("excluded_regions", "Comment")
|
||||||
|
call s:option_init("excluded_regions_list", split(s:get('excluded_regions', ''), ',\s*'))
|
||||||
|
let enabled = len(s:get('excluded_regions_list', [])) > 0
|
||||||
|
call s:option_init("excluded_regions_enabled", enabled)
|
||||||
|
" expand_space
|
||||||
|
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||||
|
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
|
unlet b:delimitMate_expand_space
|
||||||
|
let b:delimitMate_expand_space = 1
|
||||||
|
endif
|
||||||
|
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("")
|
||||||
|
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
|
unlet g:delimitMate_expand_space
|
||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
endif
|
||||||
|
call s:option_init("expand_space", 0)
|
||||||
|
" expand_cr
|
||||||
|
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
||||||
|
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet b:delimitMate_expand_cr
|
||||||
|
let b:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
||||||
|
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet g:delimitMate_expand_cr
|
||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) &&
|
||||||
|
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
||||||
|
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
||||||
|
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
|
||||||
|
endif
|
||||||
|
call s:option_init("expand_cr", 0)
|
||||||
|
" expand_in_quotes
|
||||||
|
call s:option_init('expand_inside_quotes', 0)
|
||||||
|
" jump_expansion
|
||||||
|
call s:option_init("jump_expansion", 0)
|
||||||
|
" smart_matchpairs
|
||||||
|
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|[£$]\|[^[:punct:][:space:]]\)')
|
||||||
|
" smart_quotes
|
||||||
|
" XXX: backward compatibility. Ugly, should go the way of the dodo soon.
|
||||||
|
let quotes = escape(join(s:get('quotes_list', []), ''), '\-^[]')
|
||||||
|
let default_smart_quotes = '\%(\w\|[^[:punct:][:space:]' . quotes . ']\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]' . quotes . ']\)'
|
||||||
|
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) == type(0)
|
||||||
|
if g:delimitMate_smart_quotes
|
||||||
|
unlet g:delimitMate_smart_quotes
|
||||||
|
else
|
||||||
|
unlet g:delimitMate_smart_quotes
|
||||||
|
let g:delimitMate_smart_quotes = ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if exists('b:delimitMate_smart_quotes') && type(b:delimitMate_smart_quotes) == type(0)
|
||||||
|
if b:delimitMate_smart_quotes
|
||||||
|
unlet b:delimitMate_smart_quotes
|
||||||
|
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) && g:delimitMate_smart_quotes
|
||||||
|
let b:delimitMate_smart_quotes = default_smart_quotes
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
unlet b:delimitMate_smart_quotes
|
||||||
|
let b:delimitMate_smart_quotes = ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
call s:option_init("smart_quotes", default_smart_quotes)
|
||||||
|
" apostrophes
|
||||||
|
call s:option_init("apostrophes", "")
|
||||||
|
call s:option_init("apostrophes_list", split(s:get('apostrophes', ''), ":\s*"))
|
||||||
|
" tab2exit
|
||||||
|
call s:option_init("tab2exit", 1)
|
||||||
|
" balance_matchpairs
|
||||||
|
call s:option_init("balance_matchpairs", 0)
|
||||||
|
" eol marker
|
||||||
|
call s:option_init("insert_eol_marker", 1)
|
||||||
|
call s:option_init("eol_marker", "")
|
||||||
|
" Everything is fine.
|
||||||
|
return 1
|
||||||
|
endfunction "}}} Init()
|
||||||
|
|
||||||
|
function! s:get(name, default) "{{{
|
||||||
|
let bufoptions = delimitMate#Get()
|
||||||
|
return get(bufoptions, a:name, a:default)
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:set(...) " {{{
|
||||||
|
return call('delimitMate#Set', a:000)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! s:Map() "{{{
|
function! s:Map() "{{{
|
||||||
" Set mappings:
|
" Set mappings:
|
||||||
try
|
try
|
||||||
let save_keymap = &keymap
|
let save_keymap = &keymap
|
||||||
let save_iminsert = &iminsert
|
let save_iminsert = &iminsert
|
||||||
let save_imsearch = &imsearch
|
let save_imsearch = &imsearch
|
||||||
let save_cpo = &cpo
|
let save_cpo = &cpo
|
||||||
set keymap=
|
set keymap=
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
if s:g('autoclose')
|
silent! doautocmd <nomodeline> User delimitMate_map
|
||||||
call s:AutoClose()
|
if s:get('autoclose', 1)
|
||||||
else
|
call s:AutoClose()
|
||||||
call s:NoAutoClose()
|
else
|
||||||
endif
|
call s:NoAutoClose()
|
||||||
call s:ExtraMappings()
|
endif
|
||||||
finally
|
call s:ExtraMappings()
|
||||||
let &cpo = save_cpo
|
finally
|
||||||
let &keymap = save_keymap
|
let &cpo = save_cpo
|
||||||
let &iminsert = save_iminsert
|
let &keymap = save_keymap
|
||||||
let &imsearch = save_imsearch
|
let &iminsert = save_iminsert
|
||||||
endtry
|
let &imsearch = save_imsearch
|
||||||
|
endtry
|
||||||
let b:delimitMate_enabled = 1
|
|
||||||
|
|
||||||
|
let b:delimitMate_enabled = 1
|
||||||
endfunction "}}} Map()
|
endfunction "}}} Map()
|
||||||
|
|
||||||
function! s:Unmap() " {{{
|
function! s:Unmap() " {{{
|
||||||
let imaps =
|
let imaps =
|
||||||
\ s:g('right_delims', []) +
|
\ s:get('right_delims', []) +
|
||||||
\ s:g('left_delims', []) +
|
\ s:get('left_delims', []) +
|
||||||
\ s:g('quotes_list', []) +
|
\ s:get('quotes_list', []) +
|
||||||
\ s:g('apostrophes_list', []) +
|
\ s:get('apostrophes_list', []) +
|
||||||
\ ['<BS>', '<C-h>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
\ ['<BS>', '<C-h>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||||
\ ['<C-Left>', '<C-Right>'] +
|
\ ['<C-Left>', '<C-Right>'] +
|
||||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
|
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
|
||||||
|
|
||||||
for map in imaps
|
for map in imaps
|
||||||
if maparg(map, "i") =~? 'delimitMate'
|
if maparg(map, "i") =~# '^<Plug>delimitMate'
|
||||||
if map == '|'
|
if map == '|'
|
||||||
let map = '<Bar>'
|
let map = '<Bar>'
|
||||||
endif
|
endif
|
||||||
exec 'silent! iunmap <buffer> ' . map
|
exec 'silent! iunmap <buffer> ' . map
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let b:delimitMate_enabled = 0
|
silent! doautocmd <nomodeline> User delimitMate_unmap
|
||||||
|
let b:delimitMate_enabled = 0
|
||||||
endfunction " }}} s:Unmap()
|
endfunction " }}} s:Unmap()
|
||||||
|
|
||||||
function! s:TestMappingsDo() "{{{
|
function! s:test() "{{{
|
||||||
if &modified
|
if &modified
|
||||||
let confirm = input("Modified buffer, type \"yes\" to write and proceed "
|
let confirm = input("Modified buffer, type \"yes\" to write and proceed "
|
||||||
\ . "with test: ") ==? 'yes'
|
\ . "with test: ") ==? 'yes'
|
||||||
if !confirm
|
if !confirm
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call delimitMate#TestMappings()
|
call delimitMate#Test()
|
||||||
g/\%^$/d
|
g/\%^$/d
|
||||||
0
|
0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo(...) "{{{
|
function! s:setup(...) "{{{
|
||||||
" First, remove all magic, if needed:
|
let swap = a:0 && a:1 == 2
|
||||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
let enable = a:0 && a:1
|
||||||
call s:Unmap()
|
let disable = a:0 && !a:1
|
||||||
endif
|
" First, remove all magic, if needed:
|
||||||
" Check if this file type is excluded:
|
if get(b:, 'delimitMate_enabled', 0)
|
||||||
if exists("g:delimitMate_excluded_ft") &&
|
call s:Unmap()
|
||||||
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
" Switch
|
||||||
" Finish here:
|
if swap
|
||||||
return 1
|
echo "delimitMate is disabled."
|
||||||
endif
|
return
|
||||||
" Check if user tried to disable using b:loaded_delimitMate
|
endif
|
||||||
if exists("b:loaded_delimitMate")
|
endif
|
||||||
return 1
|
if disable
|
||||||
endif
|
" Just disable the mappings.
|
||||||
" Initialize settings:
|
return
|
||||||
if ! s:init()
|
endif
|
||||||
" Something went wrong.
|
if !a:0
|
||||||
return
|
" Check if this file type is excluded:
|
||||||
endif
|
if exists("g:delimitMate_excluded_ft") &&
|
||||||
" Now, add magic:
|
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||||
if !exists("g:delimitMate_offByDefault") || !g:delimitMate_offByDefault
|
" Finish here:
|
||||||
call s:Map()
|
return 1
|
||||||
endif
|
endif
|
||||||
if a:0 > 0
|
" Check if user tried to disable using b:loaded_delimitMate
|
||||||
echo "delimitMate has been reset."
|
if exists("b:loaded_delimitMate")
|
||||||
endif
|
return 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
" Initialize settings:
|
||||||
|
if ! s:init()
|
||||||
|
" Something went wrong.
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
if enable || swap || !get(g:, 'delimitMate_offByDefault', 0)
|
||||||
|
" Now, add magic:
|
||||||
|
call s:Map()
|
||||||
|
if a:0
|
||||||
|
echo "delimitMate is enabled."
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateSwitch() "{{{
|
|
||||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
|
||||||
call s:Unmap()
|
|
||||||
echo "delimitMate has been disabled."
|
|
||||||
else
|
|
||||||
call s:Unmap()
|
|
||||||
call s:init()
|
|
||||||
call s:Map()
|
|
||||||
echo "delimitMate has been enabled."
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Mappers: {{{
|
|
||||||
function! s:TriggerAbb() "{{{
|
function! s:TriggerAbb() "{{{
|
||||||
if v:version < 703
|
if v:version < 703
|
||||||
\ || ( v:version == 703 && !has('patch489') )
|
\ || ( v:version == 703 && !has('patch489') )
|
||||||
\ || pumvisible()
|
\ || pumvisible()
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
return "\<C-]>"
|
return "\<C-]>"
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:NoAutoClose() "{{{
|
function! s:NoAutoClose() "{{{
|
||||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||||
for delim in s:g('right_delims') + s:g('quotes_list')
|
for delim in s:get('right_delims', []) + s:get('quotes_list', [])
|
||||||
if delim == '|'
|
if delim == '|'
|
||||||
let delim = '<Bar>'
|
let delim = '<Bar>'
|
||||||
endif
|
endif
|
||||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=<SID>TriggerAbb().delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=<SID>TriggerAbb().delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||||
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:AutoClose() "{{{
|
function! s:AutoClose() "{{{
|
||||||
" Add matching pair and jump to the midle:
|
" Add matching pair and jump to the midle:
|
||||||
" inoremap <silent> <buffer> ( ()<Left>
|
" inoremap <silent> <buffer> ( ()<Left>
|
||||||
let i = 0
|
let i = 0
|
||||||
while i < len(s:g('matchpairs_list'))
|
while i < len(s:get('matchpairs_list', []))
|
||||||
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i]
|
let ld = s:get('left_delims', [])[i] == '|' ? '<bar>' : s:get('left_delims', [])[i]
|
||||||
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('right_delims')[i]
|
let rd = s:get('right_delims', [])[i] == '|' ? '<bar>' : s:get('right_delims', [])[i]
|
||||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . ld
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . ld
|
||||||
\. ' <SID>TriggerAbb().delimitMate#ParenDelim("' . escape(rd, '|') . '")'
|
\. ' <SID>TriggerAbb().delimitMate#ParenDelim("' . escape(rd, '|') . '")'
|
||||||
exec 'silent! imap <unique> <buffer> '.ld
|
exec 'silent! imap <unique> <buffer> '.ld
|
||||||
\.' <Plug>delimitMate'.ld
|
\.' <Plug>delimitMate'.ld
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Exit from inside the matching pair:
|
" Exit from inside the matching pair:
|
||||||
for delim in s:g('right_delims')
|
for delim in s:get('right_delims', [])
|
||||||
let delim = delim == '|' ? '<bar>' : delim
|
let delim = delim == '|' ? '<bar>' : delim
|
||||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||||
\. ' <SID>TriggerAbb().delimitMate#JumpOut("\' . delim . '")'
|
\. ' <SID>TriggerAbb().delimitMate#JumpOut("\' . delim . '")'
|
||||||
exec 'silent! imap <unique> <buffer> ' . delim
|
exec 'silent! imap <unique> <buffer> ' . delim
|
||||||
\. ' <Plug>delimitMate'. delim
|
\. ' <Plug>delimitMate'. delim
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||||
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||||
for delim in s:g('quotes_list')
|
for delim in s:get('quotes_list', [])
|
||||||
if delim == '|'
|
if delim == '|'
|
||||||
let delim = '<Bar>'
|
let delim = '<Bar>'
|
||||||
endif
|
endif
|
||||||
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||||
\. ' <SID>TriggerAbb()."<C-R>=delimitMate#QuoteDelim(\"\\\' . delim . '\")<CR>"'
|
\. ' <SID>TriggerAbb()."<C-R>=delimitMate#QuoteDelim(\"\\\' . delim . '\")<CR>"'
|
||||||
exec 'silent! imap <unique> <buffer> ' . delim
|
exec 'silent! imap <unique> <buffer> ' . delim
|
||||||
\. ' <Plug>delimitMate' . delim
|
\. ' <Plug>delimitMate' . delim
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Try to fix the use of apostrophes (kept for backward compatibility):
|
" Try to fix the use of apostrophes (kept for backward compatibility):
|
||||||
" inoremap <silent> <buffer> n't n't
|
" inoremap <silent> <buffer> n't n't
|
||||||
for map in s:g('apostrophes_list')
|
for map in s:get('apostrophes_list', [])
|
||||||
exec "inoremap <silent> " . map . " " . map
|
exec "inoremap <silent> " . map . " " . map
|
||||||
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:ExtraMappings() "{{{
|
function! s:ExtraMappings() "{{{
|
||||||
" If pair is empty, delete both delimiters:
|
" If pair is empty, delete both delimiters:
|
||||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||||
if !hasmapto('<Plug>delimitMateBS','i')
|
if !hasmapto('<Plug>delimitMateBS','i')
|
||||||
if maparg('<BS>'. 'i') == ''
|
if empty(maparg('<BS>', 'i'))
|
||||||
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||||
endif
|
endif
|
||||||
if maparg('<C-h>'. 'i') == ''
|
if empty(maparg('<C-H>', 'i'))
|
||||||
silent! imap <unique> <buffer> <C-h> <Plug>delimitMateBS
|
silent! imap <unique> <buffer> <C-h> <Plug>delimitMateBS
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
" If pair is empty, delete closing delimiter:
|
" If pair is empty, delete closing delimiter:
|
||||||
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||||
if !hasmapto('<Plug>delimitMateS-BS','i') && maparg('<S-BS>', 'i') == ''
|
if !hasmapto('<Plug>delimitMateS-BS','i') && maparg('<S-BS>', 'i') == ''
|
||||||
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||||
endif
|
endif
|
||||||
" Expand return if inside an empty pair:
|
" Expand return if inside an empty pair:
|
||||||
inoremap <expr><silent> <Plug>delimitMateCR <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
inoremap <expr><silent> <Plug>delimitMateCR <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
if s:g('expand_cr') && !hasmapto('<Plug>delimitMateCR', 'i') && maparg('<CR>', 'i') == ''
|
if s:get('expand_cr', 0) && !hasmapto('<Plug>delimitMateCR', 'i') && maparg('<CR>', 'i') == ''
|
||||||
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||||
endif
|
endif
|
||||||
" Expand space if inside an empty pair:
|
" Expand space if inside an empty pair:
|
||||||
inoremap <expr><silent> <Plug>delimitMateSpace <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandSpace()\<CR>"
|
inoremap <expr><silent> <Plug>delimitMateSpace <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandSpace()\<CR>"
|
||||||
if s:g('expand_space') && !hasmapto('<Plug>delimitMateSpace', 'i') && maparg('<Space>', 'i') == ''
|
if s:get('expand_space', 0) && !hasmapto('<Plug>delimitMateSpace', 'i') && maparg('<Space>', 'i') == ''
|
||||||
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||||
endif
|
endif
|
||||||
" Jump over any delimiter:
|
" Jump over any delimiter:
|
||||||
inoremap <expr><silent> <Plug>delimitMateS-Tab <SID>TriggerAbb()."\<C-R>=delimitMate#JumpAny()\<CR>"
|
inoremap <expr><silent> <Plug>delimitMateS-Tab <SID>TriggerAbb()."\<C-R>=delimitMate#JumpAny()\<CR>"
|
||||||
if s:g('tab2exit') && !hasmapto('<Plug>delimitMateS-Tab', 'i') && maparg('<S-Tab>', 'i') == ''
|
if s:get('tab2exit', 0) && !hasmapto('<Plug>delimitMateS-Tab', 'i') && maparg('<S-Tab>', 'i') == ''
|
||||||
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||||
endif
|
endif
|
||||||
" Jump over next delimiters
|
" Jump over next delimiters
|
||||||
inoremap <expr><buffer> <Plug>delimitMateJumpMany <SID>TriggerAbb()."\<C-R>=delimitMate#JumpMany()\<CR>"
|
inoremap <expr><buffer> <Plug>delimitMateJumpMany <SID>TriggerAbb()."\<C-R>=delimitMate#JumpMany()\<CR>"
|
||||||
if !hasmapto('<Plug>delimitMateJumpMany', 'i') && maparg("<C-G>g", 'i') == ''
|
if !hasmapto('<Plug>delimitMateJumpMany', 'i') && maparg("<C-G>g", 'i') == ''
|
||||||
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
|
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Commands: {{{
|
" Commands: {{{
|
||||||
|
|
||||||
call s:DelimitMateDo()
|
|
||||||
|
|
||||||
" Let me refresh without re-loading the buffer:
|
" Let me refresh without re-loading the buffer:
|
||||||
command! -bar DelimitMateReload call s:DelimitMateDo(1)
|
command! -bar DelimitMateReload call s:setup(1)
|
||||||
|
|
||||||
" Quick test:
|
" Quick test:
|
||||||
command! -bar DelimitMateTest call s:TestMappingsDo()
|
command! -bar DelimitMateTest call s:test()
|
||||||
|
|
||||||
" Switch On/Off:
|
" Switch On/Off:
|
||||||
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
|
command! -bar DelimitMateSwitch call s:setup(2)
|
||||||
|
" Enable mappings:
|
||||||
|
command! -bar DelimitMateOn call s:setup(1)
|
||||||
|
" Disable mappings:
|
||||||
|
command! -bar DelimitMateOff call s:setup(0)
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Autocommands: {{{
|
" Autocommands: {{{
|
||||||
|
|
||||||
augroup delimitMate
|
augroup delimitMate
|
||||||
au!
|
au!
|
||||||
" Run on file type change.
|
" Run on file type change.
|
||||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
au FileType * call <SID>setup()
|
||||||
autocmd FileType * call <SID>DelimitMateDo()
|
au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
|
||||||
|
|
||||||
" Run on new buffers.
|
" Run on new buffers.
|
||||||
autocmd BufNewFile,BufRead,BufEnter *
|
au BufNewFile,BufRead,BufEnter,CmdwinEnter *
|
||||||
\ if !exists('b:delimitMate_was_here') |
|
\ if !exists('b:delimitMate_was_here') |
|
||||||
\ call <SID>DelimitMateDo() |
|
\ call <SID>setup() |
|
||||||
\ let b:delimitMate_was_here = 1 |
|
\ let b:delimitMate_was_here = 1 |
|
||||||
\ endif
|
\ endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
" This is for the default buffer when it does not have a filetype.
|
||||||
|
call s:setup()
|
||||||
|
|
||||||
let &cpo = save_cpo
|
let &cpo = save_cpo
|
||||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
||||||
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
||||||
|
|||||||
@@ -39,3 +39,13 @@ let b:delimitMate_eol_marker = ';'
|
|||||||
unlet b:delimitMate_eol_marker
|
unlet b:delimitMate_eol_marker
|
||||||
iabb def ghi
|
iabb def ghi
|
||||||
"def(" "ghi()"
|
"def(" "ghi()"
|
||||||
|
iunabb def
|
||||||
|
|
||||||
|
"abc а\<Left>(" "abc (а"
|
||||||
|
"abc ñ\<Left>(" "abc (ñ"
|
||||||
|
"abc $\<Left>(" "abc ($"
|
||||||
|
"abc £\<Left>(" "abc (£"
|
||||||
|
"abc d\<Left>(" "abc (d"
|
||||||
|
"abc \<C-V>(\<Left>(" "abc (("
|
||||||
|
"abc .\<Left>(" "abc ()."
|
||||||
|
"abc \<Left>(" "abc () "
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!'
|
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!,,::'
|
||||||
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||||
call vimtest#StartTap()
|
call vimtest#StartTap()
|
||||||
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||||
let itemsnumber = len(split(g:delimitMate_matchpairs, ','))
|
let itemsnumber = len(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'))
|
||||||
call vimtap#Plan(testsnumber * itemsnumber)
|
call vimtap#Plan(testsnumber * itemsnumber)
|
||||||
let tcount = 1
|
let tcount = 1
|
||||||
let reload = 1
|
let reload = 1
|
||||||
@@ -24,7 +24,7 @@ for item in lines
|
|||||||
let reload = 0
|
let reload = 0
|
||||||
endif
|
endif
|
||||||
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||||
for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")')
|
for [s:l,s:r] in map(split(g:delimitMate_matchpairs, '.:.\zs,\ze.:.'), 'split(v:val, ''.\zs:\ze.'')')
|
||||||
let input2 = substitute(input, '(', s:l, 'g')
|
let input2 = substitute(input, '(', s:l, 'g')
|
||||||
let input2 = substitute(input2, ')', s:r, 'g')
|
let input2 = substitute(input2, ')', s:r, 'g')
|
||||||
let output2 = substitute(output, '(', s:l, 'g')
|
let output2 = substitute(output, '(', s:l, 'g')
|
||||||
|
|||||||
44
test/eol_marker.vim
Normal file
44
test/eol_marker.vim
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
let g:delimitMate_eol_marker = ';'
|
||||||
|
call vimtest#StartTap()
|
||||||
|
call vimtap#Plan(8)
|
||||||
|
" NOTE: Do not forget to update the plan ^
|
||||||
|
let g:delimitMate_insert_eol_marker = 0
|
||||||
|
DelimitMateReload
|
||||||
|
normal i(
|
||||||
|
call vimtap#Is(getline(1), '()', 'value = 1, case 1')
|
||||||
|
%d _
|
||||||
|
exec "normal i(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^(\n\s*x\n)$', ' "normal i(\<CR>x", Value = 2, case 2')
|
||||||
|
let g:delimitMate_insert_eol_marker = 1
|
||||||
|
DelimitMateReload
|
||||||
|
%d _
|
||||||
|
normal i(
|
||||||
|
call vimtap#Is(getline(1), '();', '"normal i(", value = 1, case 1')
|
||||||
|
%d _
|
||||||
|
exec "normal i(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||||
|
%d _
|
||||||
|
let g:delimitMate_insert_eol_marker = 2
|
||||||
|
DelimitMateReload
|
||||||
|
normal i(
|
||||||
|
call vimtap#Is(getline(1), '()', '"normal i(", Value = 2, case 1')
|
||||||
|
%d _
|
||||||
|
exec "normal i(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||||
|
|
||||||
|
%d _
|
||||||
|
exec "normal i{(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 3')
|
||||||
|
|
||||||
|
%d _
|
||||||
|
exec "normal i;\<Esc>I{(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 4')
|
||||||
|
|
||||||
|
" End: quit vim.
|
||||||
|
call vimtest#Quit()
|
||||||
8
test/first_buffer_no_ft.vim
Normal file
8
test/first_buffer_no_ft.vim
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
let g:delimitMate_eol_marker = ';'
|
||||||
|
call vimtest#StartTap()
|
||||||
|
call vimtap#Plan(1)
|
||||||
|
call vimtap#Like(maparg('(', 'i'), '<Plug>delimitMate(', 'Mappings defined for the first buffer without filetype set.')
|
||||||
|
call vimtest#Quit()
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user