Skip to content

Commit 309d6fe

Browse files
Fritz Mehnervim-scripts
Fritz Mehner
authored andcommitted
Version 4.2.1
- Bugfix: Setup of local templates in case of global installation. - Help: Bash and utility manuals wrapped on window width. - Bugfix: \hm and \hh work wrong in insert mode. - Bugfix: Better compatibility with custom mappings (use "normal!" and "noremap" consistently). - Added 'Bash_SetMapLeader' and 'Bash_ResetMapLeader'. - Minor corrections and improvements.
1 parent d8a12bd commit 309d6fe

File tree

11 files changed

+372
-135
lines changed

11 files changed

+372
-135
lines changed

autoload/mmtemplates/core.vim

Lines changed: 162 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
" Organization:
1212
" Version: see variable g:Templates_Version below
1313
" Created: 30.08.2011
14-
" Revision: 11.02.2013
14+
" Revision: 28.03.2014
1515
" License: Copyright (c) 2012-2013, Wolfgang Mehner
1616
" This program is free software; you can redistribute it and/or
1717
" modify it under the terms of the GNU General Public License as
@@ -38,14 +38,103 @@ endif
3838
"
3939
" prevent duplicate loading
4040
" need compatible
41-
if &cp || ( exists('g:Templates_Version') && ! exists('g:Templates_DevelopmentOverwrite') )
41+
if &cp || ( exists('g:Templates_Version') && g:Templates_Version != 'searching' && ! exists('g:Templates_DevelopmentOverwrite') )
4242
finish
4343
endif
44-
let g:Templates_Version= '0.9.2-1' " version number of this script; do not change
4544
"
46-
if ! exists ( 'g:Templates_MapInUseWarn' )
47-
let g:Templates_MapInUseWarn = 1
45+
let s:Templates_Version = '0.9.3' " version number of this script; do not change
46+
"
47+
"----------------------------------------------------------------------
48+
" --- Find Newest Version --- {{{2
49+
"----------------------------------------------------------------------
50+
"
51+
if exists('g:Templates_DevelopmentOverwrite')
52+
" skip ahead
53+
elseif exists('g:Templates_VersionUse')
54+
"
55+
" not the newest one: abort
56+
if s:Templates_Version != g:Templates_VersionUse
57+
finish
58+
endif
59+
"
60+
" otherwise: skip ahead
61+
"
62+
elseif exists('g:Templates_VersionSearch')
63+
"
64+
" add own version number to the list
65+
call add ( g:Templates_VersionSearch, s:Templates_Version )
66+
"
67+
finish
68+
"
69+
else
70+
"
71+
"-------------------------------------------------------------------------------
72+
" s:VersionComp : Compare two version numbers. {{{3
73+
"
74+
" Parameters:
75+
" op1 - first version number (string)
76+
" op2 - second version number (string)
77+
" Returns:
78+
" result - -1, 0 or 1, to the specifications of sort() (integer)
79+
"-------------------------------------------------------------------------------
80+
function! s:VersionComp ( op1, op2 )
81+
"
82+
let l1 = split ( a:op1, '[.-]' )
83+
let l2 = split ( a:op2, '[.-]' )
84+
"
85+
for i in range( 0, max( [ len( l1 ), len( l2 ) ] ) - 1 )
86+
" until now, all fields where equal
87+
if len ( l2 ) <= i
88+
return -1 " op1 has more fields -> sorts first
89+
elseif len( l1 ) <= i
90+
return 1 " op2 has more fields -> sorts first
91+
elseif str2nr ( l1[i] ) > str2nr ( l2[i] )
92+
return -1 " op1 is larger here -> sorts first
93+
elseif str2nr ( l2[i] ) > str2nr ( l1[i] )
94+
return 1 " op2 is larger here -> sorts first
95+
endif
96+
endfor
97+
"
98+
return 0 " same amount of fields, all equal
99+
endfunction " ---------- end of function s:VersionComp ----------
100+
" }}}3
101+
"-------------------------------------------------------------------------------
102+
"
103+
try
104+
"
105+
" collect all available version
106+
let g:Templates_Version = 'searching'
107+
let g:Templates_VersionSearch = []
108+
"
109+
runtime! autoload/mmtemplates/core.vim
110+
"
111+
" select the newest one
112+
call sort ( g:Templates_VersionSearch, 's:VersionComp' )
113+
"
114+
let g:Templates_VersionUse = g:Templates_VersionSearch[ 0 ]
115+
"
116+
" run all scripts again, the newest one will be used
117+
runtime! autoload/mmtemplates/core.vim
118+
"
119+
unlet g:Templates_VersionSearch
120+
unlet g:Templates_VersionUse
121+
"
122+
finish
123+
"
124+
catch /.*/
125+
"
126+
" an error occurred, skip ahead
127+
echohl WarningMsg
128+
echomsg 'Search for the newest version number failed.'
129+
echomsg 'Using this version ('.s:Templates_Version.').'
130+
echohl None
131+
endtry
132+
"
48133
endif
134+
" }}}2
135+
"-------------------------------------------------------------------------------
136+
"
137+
let g:Templates_Version = s:Templates_Version " version number of this script; do not change
49138
"
50139
"----------------------------------------------------------------------
51140
" === Modul Setup === {{{1
@@ -54,6 +143,10 @@ endif
54143
let s:DebugGlobalOverwrite = 0
55144
let s:DebugLevel = s:DebugGlobalOverwrite
56145
"
146+
if ! exists ( 'g:Templates_MapInUseWarn' )
147+
let g:Templates_MapInUseWarn = 1
148+
endif
149+
"
57150
let s:StateStackStyleTop = -2
58151
let s:StateStackFile = -1
59152
"
@@ -409,7 +502,7 @@ function! s:OpenFold ( mode )
409502
" jump to the last line of the previously closed fold
410503
let foldstart = foldclosed(".")
411504
let foldend = foldclosedend(".")
412-
normal zv
505+
normal! zv
413506
if a:mode == 'below'
414507
exe ":".foldend
415508
elseif a:mode == 'start'
@@ -2495,7 +2588,7 @@ function! s:InsertIntoBuffer ( text, placement, indentation, flag_mode )
24952588
" puts the selected area into the buffer @"
24962589
let pos1 = line("'<")
24972590
let pos2 = line("'>") + len(split( text, '\n' )) - 1
2498-
normal gvy
2591+
normal! gvy
24992592
let repl = escape ( part[0].@".part[1], '\&~' )
25002593
" substitute the selected area (using the '< and '> marks)
25012594
exe ':s/\%''<.*\%''>./'.repl.'/'
@@ -2516,7 +2609,7 @@ function! s:InsertIntoBuffer ( text, placement, indentation, flag_mode )
25162609
" proper indenting
25172610
if indentation
25182611
silent exe ":".pos1
2519-
silent exe "normal ".( pos2-pos1+1 )."=="
2612+
silent exe "normal! ".( pos2-pos1+1 )."=="
25202613
endif
25212614
"
25222615
return [ pos1, pos2 ]
@@ -2533,8 +2626,8 @@ function! s:PositionCursor ( placement, flag_mode, pos1, pos2 )
25332626
" :TODO:12.08.2013 11:03:WM: changeable syntax?
25342627
" :TODO:12.08.2013 12:00:WM: change behavior?
25352628
"
2536-
exe ":".a:pos1
2537-
let mtch = search( '<CURSOR>\|{CURSOR}', 'c', a:pos2 )
2629+
call setpos ( '.', [ bufnr('%'), a:pos1, 1, 0 ] )
2630+
let mtch = search( '\m<CURSOR>\|{CURSOR}', 'c', a:pos2 )
25382631
if mtch != 0
25392632
" tag found (and cursor moved, we are now at the position of the match)
25402633
let line = getline(mtch)
@@ -2545,9 +2638,9 @@ function! s:PositionCursor ( placement, flag_mode, pos1, pos2 )
25452638
"if a:flag_mode == 'v' && getline('.') =~ '^\s*\%(<CURSOR>\|{CURSOR}\)\s*$'
25462639
" the line contains nothing but the tag: remove and join without
25472640
" changing the second line
2548-
normal J
2641+
normal! J
25492642
"call setline( mtch, '' )
2550-
"normal gJ
2643+
"normal! gJ
25512644
else
25522645
" the line contains other characters: remove the tag and start appending
25532646
"call setline( mtch, substitute( line, '<CURSOR>\|{CURSOR}', '', '' ) )
@@ -2758,7 +2851,7 @@ function! mmtemplates#core#InsertTemplate ( library, t_name, ... ) range
27582851
" restore the state: folding and formatter program
27592852
if &foldenable
27602853
exe "set foldmethod=".foldmethod_save
2761-
normal zv
2854+
normal! zv
27622855
endif
27632856
let &equalprg = equalprg_save
27642857
"
@@ -3034,11 +3127,11 @@ function! s:CreateSubmenu ( t_lib, root_menu, global_name, menu, priority )
30343127
let assemble .= '.'
30353128
"
30363129
if -1 != stridx ( clean, '<TAB>' )
3037-
exe 'amenu '.priority_str.a:root_menu.escape( assemble.clean, ' ' ).' :echo "This is a menu header."<CR>'
3130+
exe 'anoremenu '.priority_str.a:root_menu.escape( assemble.clean, ' ' ).' :echo "This is a menu header."<CR>'
30383131
else
3039-
exe 'amenu '.priority_str.a:root_menu.escape( assemble.clean, ' ' ).'<TAB>'.escape( a:global_name, ' .' ).' :echo "This is a menu header."<CR>'
3132+
exe 'anoremenu '.priority_str.a:root_menu.escape( assemble.clean, ' ' ).'<TAB>'.escape( a:global_name, ' .' ).' :echo "This is a menu header."<CR>'
30403133
endif
3041-
exe 'amenu '.a:root_menu.escape( assemble, ' ' ).'-TSep00- <Nop>'
3134+
exe 'anoremenu '.a:root_menu.escape( assemble, ' ' ).'-TSep00- <Nop>'
30423135
endif
30433136
let submenu .= clean.'.'
30443137
endfor
@@ -3080,7 +3173,7 @@ function! s:CreateTemplateMenus ( t_lib, root_menu, global_name, t_lib_name )
30803173
let sep_nr = a:t_lib.menu_existing[ m_key ] + 1
30813174
let a:t_lib.menu_existing[ m_key ] = sep_nr
30823175
"
3083-
exe 'amenu '.a:root_menu.escape( t_menu, ' ' ).'-TSep'.sep_nr.'- :'
3176+
exe 'anoremenu '.a:root_menu.escape( t_menu, ' ' ).'-TSep'.sep_nr.'- :'
30843177
"
30853178
continue
30863179
endif
@@ -3104,26 +3197,26 @@ function! s:CreateTemplateMenus ( t_lib, root_menu, global_name, t_lib_name )
31043197
"
31053198
if entry == 1
31063199
" <Esc><Esc> prevents problems in insert mode
3107-
exe 'amenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")<CR>'
3108-
exe 'imenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","i")<CR>'
3200+
exe 'anoremenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")<CR>'
3201+
exe 'inoremenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","i")<CR>'
31093202
if visual == 1
3110-
exe 'vmenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")<CR>'
3203+
exe 'vnoremenu <silent> '.a:root_menu.compl_entry.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")<CR>'
31113204
endif
31123205
elseif entry == 2
31133206
call s:CreateSubmenu ( a:t_lib, a:root_menu, a:global_name, t_menu.t_last.map_entry, s:StandardPriority )
31143207
"
31153208
for item in s:GetPickList ( t_name )
31163209
let item_entry = compl_entry.'.'.substitute ( substitute ( escape ( item, ' .' ), '&', '\&\&', 'g' ), '\w', '\&&', '' )
3117-
exe 'amenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","pick",'.string(item).')<CR>'
3118-
exe 'imenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","i","pick",'.string(item).')<CR>'
3210+
exe 'anoremenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","pick",'.string(item).')<CR>'
3211+
exe 'inoremenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","i","pick",'.string(item).')<CR>'
31193212
if visual == 1
3120-
exe 'vmenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v","pick",'.string(item).')<CR>'
3213+
exe 'vnoremenu <silent> '.a:root_menu.item_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v","pick",'.string(item).')<CR>'
31213214
endif
31223215
endfor
31233216
"
3124-
" exe 'amenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")<CR>'
3217+
" exe 'anoremenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")<CR>'
31253218
" if visual == 1
3126-
" exe 'vmenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")<CR>'
3219+
" exe 'vnoremenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' <Esc><Esc>:call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")<CR>'
31273220
" endif
31283221
endif
31293222
"
@@ -3155,9 +3248,9 @@ function! s:CreateSpecialsMenus ( t_lib, root_menu, global_name, t_lib_name, spe
31553248
" create edit and reread templates
31563249
let entry_edit = s:InsertShortcut ( '.edit\ templates', sc_edit, 1 ).'<TAB>'.map_edit
31573250
let entry_read = s:InsertShortcut ( '.reread\ templates', sc_read, 1 ).'<TAB>'.map_read
3158-
exe 'amenu <silent> '.a:root_menu.specials_menu.entry_edit
3251+
exe 'anoremenu <silent> '.a:root_menu.specials_menu.entry_edit
31593252
\ .' :call mmtemplates#core#EditTemplateFiles('.a:t_lib_name.',-1)<CR>'
3160-
exe 'amenu <silent> '.a:root_menu.specials_menu.entry_read
3253+
exe 'anoremenu <silent> '.a:root_menu.specials_menu.entry_read
31613254
\ .' :call mmtemplates#core#ReadTemplates('.a:t_lib_name.',"reload","all")<CR>'
31623255
endif
31633256
"
@@ -3168,7 +3261,7 @@ function! s:CreateSpecialsMenus ( t_lib, root_menu, global_name, t_lib_name, spe
31683261
call s:CreateSubmenu ( a:t_lib, a:root_menu, a:global_name, specials_menu.entry_styles, s:StandardPriority )
31693262
"
31703263
for s in a:t_lib.styles
3171-
exe 'amenu <silent> '.a:root_menu.specials_menu.'.choose\ style.&'.s
3264+
exe 'anoremenu <silent> '.a:root_menu.specials_menu.'.choose\ style.&'.s
31723265
\ .' :call mmtemplates#core#ChooseStyle('.a:t_lib_name.','.string(s).')<CR>'
31733266
endfor
31743267
"
@@ -3735,7 +3828,7 @@ endfunction " ---------- end of function mmtemplates#core#EditTemplateFiles
37353828
"
37363829
function! mmtemplates#core#JumpToTag ( regex )
37373830
"
3738-
let match = search( a:regex, 'c' )
3831+
let match = search( '\m'.a:regex, 'c' )
37393832
if match > 0
37403833
" remove the target
37413834
call setline( match, substitute( getline('.'), a:regex, '', '' ) )
@@ -3744,6 +3837,46 @@ function! mmtemplates#core#JumpToTag ( regex )
37443837
return ''
37453838
endfunction " ---------- end of function mmtemplates#core#JumpToTag ----------
37463839
"
3840+
"----------------------------------------------------------------------
3841+
" mmtemplates#core#SetMapleader : Set the local mapleader. {{{1
3842+
"----------------------------------------------------------------------
3843+
"
3844+
" list of lists: [ "<localleader>", "<globalleader>" ]
3845+
let s:mapleader_stack = []
3846+
"
3847+
function! mmtemplates#core#SetMapleader ( localleader )
3848+
"
3849+
if empty ( a:localleader )
3850+
call add ( s:mapleader_stack, [] )
3851+
else
3852+
if exists ( 'g:maplocalleader' )
3853+
call add ( s:mapleader_stack, [ a:localleader, g:maplocalleader ] )
3854+
else
3855+
call add ( s:mapleader_stack, [ a:localleader ] )
3856+
endif
3857+
let g:maplocalleader = a:localleader
3858+
endif
3859+
"
3860+
endfunction " ---------- end of function mmtemplates#core#SetMapleader ----------
3861+
"
3862+
"----------------------------------------------------------------------
3863+
" mmtemplates#core#ResetMapleader : Reset the local mapleader. {{{1
3864+
"----------------------------------------------------------------------
3865+
"
3866+
function! mmtemplates#core#ResetMapleader ()
3867+
"
3868+
let ll_save = remove ( s:mapleader_stack, -1 )
3869+
"
3870+
if ! empty ( ll_save )
3871+
if len ( ll_save ) > 1
3872+
let g:maplocalleader = ll_save[1]
3873+
else
3874+
unlet g:maplocalleader
3875+
endif
3876+
endif
3877+
"
3878+
endfunction " ---------- end of function mmtemplates#core#ResetMapleader ----------
3879+
"
37473880
" }}}1
37483881
"
37493882
" =====================================================================================

bash-support/README.bashsupport

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
README for bash-support.vim (Version 4.2) / January 04 2014
1+
README for bash-support.vim (Version 4.2.1) / March 25 2014
22

33
* INSTALLATION
44
* RELEASE NOTES
@@ -123,13 +123,14 @@ Look at the bashsupport help with
123123
+-----------------------------------------------+
124124

125125
=======================================================================================
126-
RELEASE NOTES FOR VERSION 4.2
126+
RELEASE NOTES FOR VERSION 4.2.1
127127
=======================================================================================
128-
129-
- Default shell can be set in ~/.vimrc via g:BASH_Executable.
130-
- Errors can be parsed for bash, dash, ksh, zsh.
131-
- Bugfix: QuickFix list doesn't work properly (thanks to @PengZheng)
132-
- 'Run -> make script executable' (\re) is now a toggle.
128+
- Bugfix: Setup of local templates in case of global installation.
129+
- Help: Bash and utility manuals wrapped on window width.
130+
- Bugfix: \hm and \hh work wrong in insert mode.
131+
- Bugfix: Better compatibility with custom mappings
132+
(use "normal!" and "noremap" consistently).
133+
- Added 'Bash_SetMapLeader' and 'Bash_ResetMapLeader'.
133134
- Minor corrections and improvements.
134135

135136
OLDER RELEASE NOTES : see file 'ChangeLog'

bash-support/rc/customization.gvimrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ let c_comment_strings=1 " highlight strings inside C comments
3636
" shift left : change window focus to one on left
3737
" shift right : change window focus to one on right
3838
"-------------------------------------------------------------------------------
39-
nmap <s-down> <c-w>w
40-
nmap <s-up> <c-w>W
41-
nmap <s-left> <c-w>h
42-
nmap <s-right> <c-w>l
39+
nnoremap <s-down> <c-w>w
40+
nnoremap <s-up> <c-w>W
41+
nnoremap <s-left> <c-w>h
42+
nnoremap <s-right> <c-w>l
4343
"
4444
"-------------------------------------------------------------------------------
4545
" some additional hot keys
4646
"-------------------------------------------------------------------------------
4747
" S-F3 - call gvim file browser
4848
"-------------------------------------------------------------------------------
49-
map <silent> <s-F3> :silent browse confirm e<CR>
50-
imap <silent> <s-F3> <Esc>:silent browse confirm e<CR>
49+
noremap <silent> <s-F3> :silent browse confirm e<CR>
50+
inoremap <silent> <s-F3> <Esc>:silent browse confirm e<CR>
5151
"
5252
"-------------------------------------------------------------------------------
5353
" toggle insert mode <--> 'normal mode with the <RightMouse>-key
5454
"-------------------------------------------------------------------------------
5555
"
56-
nmap <RightMouse> <Insert>
57-
imap <RightMouse> <ESC>
56+
nnoremap <RightMouse> <Insert>
57+
inoremap <RightMouse> <ESC>
5858
"
5959
"-------------------------------------------------------------------------------
6060
" use font with clearly distinguishable brackets : ()[]{}

0 commit comments

Comments
 (0)