update rainbow parens and stuff

This commit is contained in:
Haak Saxberg 2016-12-21 21:27:33 -08:00 committed by Haak Saxberg
parent aba7f89b92
commit d8b94beba4
2 changed files with 36 additions and 83 deletions

View file

@ -171,22 +171,14 @@ function! s:assoc(dict, key, val)
let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
endfunction
function! s:ask(message, ...)
function! s:ask(message)
call inputsave()
echohl WarningMsg
let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
let proceed = input(a:message.' (y/N) ') =~? '^y'
echohl None
call inputrestore()
echo "\r"
return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0
endfunction
function! s:ask_no_interrupt(...)
try
return call('s:ask', a:000)
catch
return 0
endtry
return proceed
endfunction
function! plug#end()
@ -617,7 +609,6 @@ function! s:syntax()
syn match plugRelDate /([^)]*)$/ contained
syn match plugNotLoaded /(not loaded)$/
syn match plugError /^x.*/
syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
syn match plugH2 /^.*:\n-\+$/
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
hi def link plug1 Title
@ -715,12 +706,6 @@ function! s:prepare(...)
throw 'Invalid current working directory. Cannot proceed.'
endif
for evar in ['$GIT_DIR', '$GIT_WORK_TREE']
if exists(evar)
throw evar.' detected. Cannot proceed.'
endif
endfor
call s:job_abort()
if s:switch_in()
normal q
@ -736,9 +721,10 @@ function! s:prepare(...)
let s:plug_buf = winbufnr(0)
call s:assign_name()
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
execute 'silent! unmap <buffer>' k
endfor
silent! unmap <buffer> <cr>
silent! unmap <buffer> L
silent! unmap <buffer> o
silent! unmap <buffer> X
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
setf vim-plug
if exists('g:syntax_on')
@ -804,12 +790,7 @@ function! s:do(pull, force, todo)
let error = ''
let type = type(spec.do)
if type == s:TYPE.string
if spec.do[0] == ':'
call s:load_plugin(spec)
execute spec.do[1:]
else
let error = s:bang(spec.do)
endif
let error = s:bang(spec.do)
elseif type == s:TYPE.funcref
try
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
@ -1044,18 +1025,18 @@ function! s:update_finish()
call s:log4(name, 'Updating submodules. This may take a while.')
let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir)
endif
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
let msg = printf('%s %s: %s', v:shell_error ? 'x': '-', name, s:lastline(out))
if v:shell_error
call add(s:update.errors, name)
call s:regress_bar()
silent execute pos 'd _'
execute pos 'd _'
call append(4, msg) | 4
elseif !empty(out)
call setline(pos, msg[0])
call setline(pos, msg)
endif
redraw
endfor
silent 4 d _
4 d _
call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")'))
call s:finish(s:update.pull)
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.')
@ -1998,48 +1979,16 @@ function! s:clean(force)
if empty(todo)
call append(line('$'), 'Already clean.')
else
let s:clean_count = 0
call append(3, ['Directories to delete:', ''])
redraw!
if a:force || s:ask_no_interrupt('Delete all directories?')
call s:delete([6, line('$')], 1)
if a:force || s:ask('Proceed?')
for dir in todo
call s:rm_rf(dir)
endfor
call append(3, ['Removed.', ''])
else
call setline(4, 'Cancelled.')
nnoremap <silent> <buffer> d :set opfunc=<sid>delete_op<cr>g@
nmap <silent> <buffer> dd d_
xnoremap <silent> <buffer> d :<c-u>call <sid>delete_op(visualmode(), 1)<cr>
echo 'Delete the lines (d{motion}) to delete the corresponding directories'
call append(3, ['Cancelled.', ''])
endif
endif
4
setlocal nomodifiable
endfunction
function! s:delete_op(type, ...)
call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0)
endfunction
function! s:delete(range, force)
let [l1, l2] = a:range
let force = a:force
while l1 <= l2
let line = getline(l1)
if line =~ '^- ' && isdirectory(line[2:])
execute l1
redraw!
let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
let force = force || answer > 1
if answer
call s:rm_rf(line[2:])
setlocal modifiable
call setline(l1, '~'.line[1:])
let s:clean_count += 1
call setline(4, printf('Removed %d directories.', s:clean_count))
setlocal nomodifiable
endif
endif
let l1 += 1
endwhile
endfunction
function! s:upgrade()
@ -2181,15 +2130,11 @@ function! s:preview_commit()
return
endif
if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
execute 'e' sha
else
execute 'pedit' sha
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
execute 'pedit' sha
wincmd P
setlocal filetype=git buftype=nofile nobuflisted modifiable
execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
normal! gg"_dd
setlocal nomodifiable
nnoremap <silent> <buffer> q :q<cr>
wincmd p