From 3ce7f7ffcf625373257d6fcad4ae43b85980779b Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Sun, 27 Sep 2009 16:49:03 -0500 Subject: [PATCH] === 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. --- delimitMate.txt | 34 +++++++++++++++++-------------- delimitMate.vim | 53 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/delimitMate.txt b/delimitMate.txt index 2a85e9f..1961b94 100644 --- a/delimitMate.txt +++ b/delimitMate.txt @@ -174,8 +174,8 @@ e.g.: > ------------------------------------------------------------------------------ *'delimitMate_autoclose'* *'b:delimitMate_autoclose'* -Values: 0 or 1. -Default: 1 +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. @@ -186,8 +186,8 @@ e.g.: > ------------------------------------------------------------------------------ *'delimitMate_matchpairs'* *'b:delimitMate_matchpairs'* -Values: A string with |matchpairs| syntax. -Default: &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. @@ -198,8 +198,8 @@ e.g: > ------------------------------------------------------------------------------ *'delimitMate_quotes'* *'b:delimitMate_quotes'* -Values: A string of characters separated by spaces. -Default: "\" ' `" +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. @@ -210,8 +210,8 @@ e.g.: > ------------------------------------------------------------------------------ *'delimitMate_visual_leader'* *'b:delimitMate_visual_leader'* -Values: Any character. -Default: q +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. @@ -222,8 +222,8 @@ e.g: > ------------------------------------------------------------------------------ *'delimitMate_expand_cr'* *'b:delimitMate_expand_cr'* -Values: A key mapping. -Default: "\" +Values: A key mapping. ~ +Default: "\" ~ 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. @@ -234,8 +234,8 @@ e.g.: > ------------------------------------------------------------------------------ *'delimitMate_expand_space'* *'b:delimitMate_expand_space'* -Values: A key mapping. -Default: "\" +Values: A key mapping. ~ +Default: "\" ~ The value of this option will be used to expand the space character when typed inside an empty delimiter pair. Read |delimitMateExpansion| for details. @@ -245,8 +245,8 @@ e.g.: > < ------------------------------------------------------------------------------ *'delimitMate_excluded_ft'* -Values: A string of file type names separated by single commas. -Defaul: Empty. +Values: A string of file type names separated by single commas. ~ +Defaul: Empty. ~ This options turns delimitMate off for the listed file types, use this option only if don't want any of the features it provides. @@ -371,7 +371,11 @@ This script was inspired by the auto-completion of delimiters of TextMate. ============================================================================== 8. HISTORY *delimitMateHistory* - Version Date Release notes + Version Date Release notes ~ +|---------|------------|-----------------------------------------------------| + 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. diff --git a/delimitMate.vim b/delimitMate.vim index d0b9a23..31c5b30 100644 --- a/delimitMate.vim +++ b/delimitMate.vim @@ -1,6 +1,6 @@ " ============================================================================ " File: delimitMate.vim -" Version: 1.3 +" Version: 1.4 " Description: This plugin tries to emulate the auto-completion of delimiters " that TextMate provides. " Maintainer: Israel Chauca F. @@ -108,7 +108,7 @@ function! s:Init() "{{{1 elseif exists("b:delimitMate_visual_leader") let s:visual_leader = b:delimitMate_visual_leader else - let s:visual_leader = g:delimitMate_visual_leader + let s:visual_leader = g:delimitMate_visual_leader endif " }}} if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space") " {{{ @@ -392,7 +392,7 @@ function! s:TestMappings() "{{{1 exec "normal A\Car return: " . s:quotes[i] . s:quotes[i] . "\|\GGA\\" endfor endif - exec "normal \" + exec "normal \i" endfunction "}}}1 function! s:SwitchAutoclose() "{{{1 @@ -406,6 +406,42 @@ function! s:SwitchAutoclose() "{{{1 DelimitMateReload endfunction "}}}1 +function! s:UnMap() " {{{ + + for char in s:right_delims + s:quotes + if maparg(char,"i") =~ 'SkipDelim' + exec 'iunmap ' . char + "echomsg 'iunmap ' . char + endif + endfor + for char in s:right_delims + s:left_delims + s:quotes + if maparg(s:visual_leader . char,"v") =~ 'IsBlock' + exec 'vunmap ' . s:visual_leader . char + "echomsg 'vunmap ' . s:visual_leader . char + endif + endfor + let s:i = 0 + while s:i < len(s:matchpairs) + if maparg(char,"i") =~ s:left_delims[s:i] . s:right_delims[s:i] . '' + exec 'iunmap ' . char + "echomsg 'iunmap ' . char + endif + let s:i += 1 + endwhile + for char in s:quotes + if maparg(char, "i") =~ 'QuoteDelim' + exec 'iunmap ' . char + "echomsg 'iunmap ' . char + endif + endfor + for char in s:right_delims + if maparg(char, "i") + exec 'iunmap ' . char + "echomsg 'iunmap ' . char + endif + endfor +endfunction " }}} + function! s:TestMappingsDo() "{{{1 if !exists("g:delimitMate_testing") call s:DelimitMateDo() @@ -423,7 +459,7 @@ function! s:DelimitMateDo() "{{{1 if exists("g:delimitMate_excluded_ft") for ft in split(g:delimitMate_excluded_ft,',') if ft ==? &filetype - echomsg "Excluded" + call s:UnMap() return 1 endif endfor @@ -439,7 +475,7 @@ function! s:DelimitMateDo() "{{{1 endfunction "}}}1 " Do the real work: {{{1 -"call s:DelimitMateDo() +call s:DelimitMateDo() " Let me refresh without re-loading the buffer: command! DelimitMateReload call s:DelimitMateDo() @@ -447,8 +483,11 @@ command! DelimitMateReload call s:DelimitMateDo() " Quick test: command! DelimitMateTest call s:TestMappingsDo() -"autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") || &filetype !=? "mailapp" | call DelimitMateDo() | endif -autocmd VimEnter * autocmd FileType * if !exists("b:loaded_delimitMate") | call DelimitMateDo() | endif +" Run on file type events. +autocmd VimEnter * autocmd FileType * call DelimitMateDo() + +" Run on new buffers. +autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call DelimitMateDo() | endif " GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim " vim:foldmethod=marker:foldcolumn=2