mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
" Version: 1.3
|
||||
" GetLatestVimScripts: 3695 1 :AutoInstall: commentary.vim
|
||||
|
||||
if exists("g:loaded_commentary") || &cp || v:version < 700
|
||||
if exists("g:loaded_commentary") || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_commentary = 1
|
||||
@ -15,18 +15,21 @@ endfunction
|
||||
|
||||
function! s:strip_white_space(l,r,line) abort
|
||||
let [l, r] = [a:l, a:r]
|
||||
if l[-1:] == ' ' && stridx(a:line,l) == -1 && stridx(a:line,l[0:-2]) == 0
|
||||
if l[-1:] ==# ' ' && stridx(a:line,l) == -1 && stridx(a:line,l[0:-2]) == 0
|
||||
let l = l[:-2]
|
||||
endif
|
||||
if r[0] == ' ' && a:line[-strlen(r):] != r && a:line[1-strlen(r):] == r[1:]
|
||||
if r[0] ==# ' ' && a:line[-strlen(r):] != r && a:line[1-strlen(r):] == r[1:]
|
||||
let r = r[1:]
|
||||
endif
|
||||
return [l, r]
|
||||
endfunction
|
||||
|
||||
function! s:go(type,...) abort
|
||||
if a:0
|
||||
let [lnum1, lnum2] = [a:type, a:1]
|
||||
function! s:go(...) abort
|
||||
if !a:0
|
||||
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
|
||||
return 'g@'
|
||||
elseif a:0 > 1
|
||||
let [lnum1, lnum2] = [a:1, a:2]
|
||||
else
|
||||
let [lnum1, lnum2] = [line("'["), line("']")]
|
||||
endif
|
||||
@ -36,7 +39,7 @@ function! s:go(type,...) abort
|
||||
for lnum in range(lnum1,lnum2)
|
||||
let line = matchstr(getline(lnum),'\S.*\s\@<!')
|
||||
let [l, r] = s:strip_white_space(l,r,line)
|
||||
if line != '' && (stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
if len(line) && (stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
let uncomment = 0
|
||||
endif
|
||||
endfor
|
||||
@ -62,6 +65,7 @@ function! s:go(type,...) abort
|
||||
finally
|
||||
let &modelines = modelines
|
||||
endtry
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:textobject(inner) abort
|
||||
@ -85,13 +89,13 @@ function! s:textobject(inner) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
xnoremap <silent> <Plug>Commentary :<C-U>call <SID>go(line("'<"),line("'>"))<CR>
|
||||
nnoremap <silent> <Plug>Commentary :<C-U>set opfunc=<SID>go<CR>g@
|
||||
nnoremap <silent> <Plug>CommentaryLine :<C-U>set opfunc=<SID>go<Bar>exe 'norm! 'v:count1.'g@_'<CR>
|
||||
command! -range -bar Commentary call s:go(<line1>,<line2>)
|
||||
xnoremap <expr> <Plug>Commentary <SID>go()
|
||||
nnoremap <expr> <Plug>Commentary <SID>go()
|
||||
nnoremap <expr> <Plug>CommentaryLine <SID>go() . '_'
|
||||
onoremap <silent> <Plug>Commentary :<C-U>call <SID>textobject(0)<CR>
|
||||
nnoremap <silent> <Plug>ChangeCommentary c:<C-U>call <SID>textobject(1)<CR>
|
||||
nmap <silent> <Plug>CommentaryUndo <Plug>Commentary<Plug>Commentary
|
||||
command! -range -bar Commentary call s:go(<line1>,<line2>)
|
||||
nmap <silent> <Plug>CommentaryUndo :echoerr "Change your <Plug>CommentaryUndo map to <Plug>Commentary<Plug>Commentary"<CR>
|
||||
|
||||
if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
|
||||
xmap gc <Plug>Commentary
|
||||
|
Reference in New Issue
Block a user