specky/plugin/specky.vim
branchvim-stuff
changeset 3 db3e3abfc647
parent 2 6b33188f1694
child 5 3346aa8d5364
equal deleted inserted replaced
2:6b33188f1694 3:db3e3abfc647
    12 	execute 'map ' . g:speckySpecSwitcherKey . ' :call <SID>SpecSwitcher()<CR>'
    12 	execute 'map ' . g:speckySpecSwitcherKey . ' :call <SID>SpecSwitcher()<CR>'
    13 endif
    13 endif
    14 
    14 
    15 if exists( 'g:speckyQuoteSwitcherKey' )
    15 if exists( 'g:speckyQuoteSwitcherKey' )
    16 	execute 'map ' . g:speckyQuoteSwitcherKey . ' :call <SID>QuoteSwitcher()<CR>'
    16 	execute 'map ' . g:speckyQuoteSwitcherKey . ' :call <SID>QuoteSwitcher()<CR>'
       
    17 endif
       
    18 
       
    19 if exists( 'g:speckyBannerKey' )
       
    20 	execute 'map ' . g:speckyBannerKey . ' :call <SID>MakeBanner()<CR>'
    17 endif
    21 endif
    18 
    22 
    19 if exists( 'g:speckyRunSpecKey' )
    23 if exists( 'g:speckyRunSpecKey' )
    20 	execute 'map ' . g:speckyRunSpecKey . ' :call <SID>RunSpec()<CR>'
    24 	execute 'map ' . g:speckyRunSpecKey . ' :call <SID>RunSpec()<CR>'
    21 endif
    25 endif
    37 let s:menuloc = '&Plugin.&specky'
    41 let s:menuloc = '&Plugin.&specky'
    38 execute 'menu ' . s:menuloc . '.&Jump\ to\ code/spec :call <SID>SpecSwitcher()<CR>'
    42 execute 'menu ' . s:menuloc . '.&Jump\ to\ code/spec :call <SID>SpecSwitcher()<CR>'
    39 execute 'menu ' . s:menuloc . '.Run\ &spec :call <SID>RunSpec()<CR>'
    43 execute 'menu ' . s:menuloc . '.Run\ &spec :call <SID>RunSpec()<CR>'
    40 execute 'menu ' . s:menuloc . '.&RDoc\ lookup :call <SID>RunRdoc()<CR>'
    44 execute 'menu ' . s:menuloc . '.&RDoc\ lookup :call <SID>RunRdoc()<CR>'
    41 execute 'menu ' . s:menuloc . '.Rotate\ &quote\ style :call <SID>QuoteSwitcher()<CR>'
    45 execute 'menu ' . s:menuloc . '.Rotate\ &quote\ style :call <SID>QuoteSwitcher()<CR>'
       
    46 execute 'menu ' . s:menuloc . '.Make\ a\ &banner :call <SID>MakeBanner()<CR>'
    42 
    47 
    43 
    48 
    44 " }}}
    49 " }}}
    45 " SpecSwitcher() {{{
    50 " SpecSwitcher() {{{
    46 "
    51 "
   112 	let l:word = expand("<cword>")
   117 	let l:word = expand("<cword>")
   113 
   118 
   114 	if l:type == '"'
   119 	if l:type == '"'
   115 		" Double quote to single
   120 		" Double quote to single
   116 		"
   121 		"
   117 		execute ":normal viWs'" . l:word . "'"
   122 		execute ":normal viWc'" . l:word . "'"
   118 
   123 
   119 	elseif l:type == "'"
   124 	elseif l:type == "'"
   120 		if &ft == "ruby"
   125 		if &ft == "ruby"
   121 			" Single quote to symbol
   126 			" Single quote to symbol
   122 			"
   127 			"
   123 			execute ':normal viWs:' . l:word
   128 			execute ':normal viWc:' . l:word
   124 		else
   129 		else
   125 			" Single quote to double
   130 			" Single quote to double
   126 			"
   131 			"
   127 			execute ':normal viWs"' . l:word . '"'
   132 			execute ':normal viWc"' . l:word . '"'
   128 		end
   133 		end
   129 
   134 
   130 	else
   135 	else
   131 		" Whatever to double quote
   136 		" Whatever to double quote
   132 		"
   137 		"
   133 		execute ':normal viWs"' . l:word . '"'
   138 		execute ':normal viWc"' . l:word . '"'
   134 	endif
   139 	endif
   135 
   140 
   136 	" Move the cursor back into the cl:word
   141 	" Move the cursor back into the cl:word
   137 	"
   142 	"
   138 	call cursor( 0, getpos('.')[2] - 1 )
   143 	call cursor( 0, getpos('.')[2] - 1 )
       
   144 endfunction
       
   145 
       
   146 
       
   147 " }}}
       
   148 " MakeBanner() {{{
       
   149 "
       
   150 " Create a quick banner from the current line's text.
       
   151 "
       
   152 function! <SID>MakeBanner()
       
   153 	let l:banner_text = toupper(join( split( getline('.'), '\zs' ), ' ' ))
       
   154 	let l:banner_text = substitute( l:banner_text, '^\s\+', '', '' )
       
   155 	let l:sep = repeat( '#', 72 )
       
   156 	let l:line = line('.')
       
   157 
       
   158 	call setline( l:line, l:sep )
       
   159  	call append( l:line, [ '### ' . l:banner_text, l:sep ] )
       
   160 	call cursor( l:line + 3, 0 )
   139 endfunction
   161 endfunction
   140 
   162 
   141 
   163 
   142 " }}}
   164 " }}}
   143 " RunSpec() {{{
   165 " RunSpec() {{{