mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins. Added vim-golang as a mode
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
" commentary.vim - Comment stuff out
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 1.1
|
||||
" Version: 1.2
|
||||
" GetLatestVimScripts: 3695 1 :AutoInstall: commentary.vim
|
||||
|
||||
if exists("g:loaded_commentary") || &cp || v:version < 700
|
||||
@ -8,6 +8,12 @@ if exists("g:loaded_commentary") || &cp || v:version < 700
|
||||
endif
|
||||
let g:loaded_commentary = 1
|
||||
|
||||
function! s:surroundings() abort
|
||||
return split(substitute(substitute(
|
||||
\ get(b:, 'commentary_format', &commentstring)
|
||||
\ ,'\S\zs%s',' %s','') ,'%s\ze\S', '%s ', ''), '%s', 1)
|
||||
endfunction
|
||||
|
||||
function! s:go(type,...) abort
|
||||
if a:0
|
||||
let [lnum1, lnum2] = [a:type, a:1]
|
||||
@ -15,7 +21,7 @@ function! s:go(type,...) abort
|
||||
let [lnum1, lnum2] = [line("'["), line("']")]
|
||||
endif
|
||||
|
||||
let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1)
|
||||
let [l, r] = s:surroundings()
|
||||
let uncomment = 2
|
||||
for lnum in range(lnum1,lnum2)
|
||||
let line = matchstr(getline(lnum),'\S.*\s\@<!')
|
||||
@ -38,10 +44,11 @@ function! s:go(type,...) abort
|
||||
endif
|
||||
call setline(lnum,line)
|
||||
endfor
|
||||
silent doautocmd User CommentaryPost
|
||||
endfunction
|
||||
|
||||
function! s:undo()
|
||||
let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1)
|
||||
function! s:undo() abort
|
||||
let [l, r] = s:surroundings()
|
||||
let lnums = [line('.')+1, line('.')-2]
|
||||
for [index, dir, bound, line] in [[0, -1, 1, ''], [1, 1, line('$'), '']]
|
||||
while lnums[index] != bound && line ==# '' || !(stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
@ -65,7 +72,7 @@ if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
|
||||
nmap gcu <Plug>CommentaryUndo
|
||||
endif
|
||||
|
||||
if maparg('\\','n') ==# '' && maparg('\','n') ==# ''
|
||||
if maparg('\\','n') ==# '' && maparg('\','n') ==# '' && get(g:, 'commentary_map_backslash', 1)
|
||||
xmap \\ <Plug>Commentary
|
||||
nmap \\ <Plug>Commentary
|
||||
nmap \\\ <Plug>CommentaryLine
|
||||
|
Reference in New Issue
Block a user