Add vim-bbye

This commit is contained in:
Alex Yatskov 2016-04-11 14:00:06 -07:00
parent 6c211eda45
commit 7cfc4efa65
3 changed files with 58 additions and 30 deletions

View File

@ -337,7 +337,12 @@ function! s:err(msg)
echohl ErrorMsg
echom '[vim-plug] '.a:msg
echohl None
return 0
endfunction
function! s:warn(cmd, msg)
echohl WarningMsg
execute a:cmd 'a:msg'
echohl None
endfunction
function! s:esc(path)
@ -660,7 +665,7 @@ function! s:switch_out(...)
endfunction
function! s:finish_bindings()
nnoremap <silent> <buffer> R :silent! call <SID>retry()<cr>
nnoremap <silent> <buffer> R :call <SID>retry()<cr>
nnoremap <silent> <buffer> D :PlugDiff<cr>
nnoremap <silent> <buffer> S :PlugStatus<cr>
nnoremap <silent> <buffer> U :call <SID>status_update()<cr>
@ -812,6 +817,7 @@ function! s:retry()
if empty(s:update.errors)
return
endif
echo
call s:update_impl(s:update.pull, s:update.force,
\ extend(copy(s:update.errors), [s:update.threads]))
endfunction
@ -824,6 +830,16 @@ function! s:names(...)
return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)'))
endfunction
function! s:check_ruby()
silent! ruby require 'thread'; VIM::command('let g:plug_ruby = 1')
if get(g:, 'plug_ruby', 0)
unlet g:plug_ruby
return 1
endif
redraw!
return s:warn('echom', 'Warning: Ruby interface is broken')
endfunction
function! s:update_impl(pull, force, args) abort
let args = copy(a:args)
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
@ -834,10 +850,7 @@ function! s:update_impl(pull, force, args) abort
\ filter(managed, 'index(args, v:key) >= 0')
if empty(todo)
echohl WarningMsg
echo 'No plugin to '. (a:pull ? 'update' : 'install') . '.'
echohl None
return
return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install'))
endif
if !s:is_win && s:git_version_requirement(2, 3)
@ -859,13 +872,11 @@ function! s:update_impl(pull, force, args) abort
endif
if has('nvim') && !exists('*jobwait') && threads > 1
echohl WarningMsg
echomsg 'vim-plug: update Neovim for parallel installer'
echohl None
call s:warn('echom', '[vim-plug] Update Neovim for parallel installer')
endif
let python = (has('python') || has('python3')) && (!s:nvim || has('vim_starting'))
let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running'))
let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby()
let s:update = {
\ 'start': reltime(),
@ -944,7 +955,7 @@ function! s:update_finish()
endif
if s:switch_in()
call append(3, '- Updating ...') | 4
for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.pull || has_key(s:update.new, v:key))'))
for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))'))
let pos = s:logpos(name)
if !pos
continue
@ -962,11 +973,11 @@ function! s:update_finish()
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
endif
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
\ (has_key(s:update.new, name) || s:is_updated(spec.dir))
\ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
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 = printf('%s %s: %s', v:shell_error ? 'x': '-', name, get(s:lines(out), -1, ''))
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()
@ -1088,7 +1099,6 @@ function! s:logpos(name)
return i
endif
endfor
return 0
endfunction
function! s:log(bullet, name, lines)
@ -1135,7 +1145,7 @@ while 1 " Without TCO, Vim stack is bound to explode
let has_tag = has_key(spec, 'tag')
if !new
let error = s:git_validate(spec, 0)
let [error, _] = s:git_validate(spec, 0)
if empty(error)
if pull
let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
@ -1424,7 +1434,7 @@ class Plugin(object):
self.write(Action.DONE, self.name, result[-1:])
def repo_uri(self):
cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url'
cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url'
command = Command(cmd, self.args['dir'], G_TIMEOUT,)
result = command.execute(G_RETRIES)
return result[-1]
@ -1725,7 +1735,7 @@ function! s:update_ruby()
ok, result =
if exists
chdir = "#{cd} #{iswin ? dir : esc(dir)}"
ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil, nil
ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil
current_uri = data.lines.to_a.last
if !ret
if data =~ /^Interrupted|^Timeout/
@ -1818,7 +1828,7 @@ endfunction
function! s:git_validate(spec, check_branch)
let err = ''
if isdirectory(a:spec.dir)
let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url', a:spec.dir))
let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir))
let remote = result[-1]
if v:shell_error
let err = join([remote, 'PlugClean required.'], "\n")
@ -1850,11 +1860,18 @@ function! s:git_validate(spec, check_branch)
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
\ branch, a:spec.branch)
endif
if empty(err)
let commits = len(s:lines(s:system(printf('git rev-list origin/%s..HEAD', a:spec.branch), a:spec.dir)))
if !v:shell_error && commits
let err = join([printf('Diverged from origin/%s by %d commit(s).', a:spec.branch, commits),
\ 'Reinstall after PlugClean.'], "\n")
endif
endif
endif
else
let err = 'Not found'
endif
return err
return [err, err =~# 'PlugClean']
endfunction
function! s:rm_rf(dir)
@ -1865,15 +1882,23 @@ endfunction
function! s:clean(force)
call s:prepare()
call append(0, 'Searching for unused plugins in '.g:plug_home)
call append(0, 'Searching for invalid plugins in '.g:plug_home)
call append(1, '')
" List of valid directories
let dirs = []
let errs = {}
let [cnt, total] = [0, len(g:plugs)]
for [name, spec] in items(g:plugs)
if !s:is_managed(name) || empty(s:git_validate(spec, 0))
if !s:is_managed(name)
call add(dirs, spec.dir)
else
let [err, clean] = s:git_validate(spec, 1)
if clean
let errs[spec.dir] = s:lines(err)[0]
else
call add(dirs, spec.dir)
endif
endif
let cnt += 1
call s:progress_bar(2, repeat('=', cnt), total)
@ -1897,11 +1922,14 @@ function! s:clean(force)
if !has_key(allowed, f) && isdirectory(f)
call add(todo, f)
call append(line('$'), '- ' . f)
if has_key(errs, f)
call append(line('$'), ' ' . errs[f])
endif
let found = filter(found, 'stridx(v:val, f) != 0')
end
endwhile
normal! G
4
redraw
if empty(todo)
call append(line('$'), 'Already clean.')
@ -1910,12 +1938,12 @@ function! s:clean(force)
for dir in todo
call s:rm_rf(dir)
endfor
call append(line('$'), 'Removed.')
call append(3, ['Removed.', ''])
else
call append(line('$'), 'Cancelled.')
call append(3, ['Cancelled.', ''])
endif
endif
normal! G
4
endfunction
function! s:upgrade()
@ -1962,7 +1990,7 @@ function! s:status()
for [name, spec] in items(g:plugs)
if has_key(spec, 'uri')
if isdirectory(spec.dir)
let err = s:git_validate(spec, 1)
let [err, _] = s:git_validate(spec, 1)
let [valid, msg] = [empty(err), empty(err) ? 'OK' : err]
else
let [valid, msg] = [0, 'Not found. Try PlugInstall.']
@ -2026,7 +2054,6 @@ function! s:is_preview_window_open()
wincmd p
return 1
endif
return 0
endfunction
function! s:find_name(lnum)

View File

@ -3,9 +3,6 @@ let mapleader = "\<Space>"
" core
nnoremap <silent><Leader>w :w<Cr>
nnoremap <silent><Leader>x :x<Cr>
nnoremap <silent><Bs> :bd!<Cr>
nnoremap <silent><A-Bs> :bp\|bd! #<Cr>
nnoremap <silent><C-Bs> <C-W>q
nnoremap <silent><Leader><Leader> :b#<Cr>
nnoremap <silent><Esc><Esc> :nohlsearch<Cr>
nnoremap Q <Nop>
@ -41,6 +38,9 @@ nnoremap k gk
" vim-argwrap
nnoremap <silent><Leader>a :ArgWrap<Cr>
" vim-bbye
nnoremap <silent><Bs> :Bdelete<Cr>
" vim-bufonly
nnoremap <silent><S-Bs> :BufOnly<Cr>

View File

@ -15,6 +15,7 @@ Plug 'https://github.com/fatih/vim-go.git'
Plug 'https://github.com/junegunn/vim-easy-align.git'
Plug 'https://github.com/mattn/emmet-vim.git'
Plug 'https://github.com/michaeljsmith/vim-indent-object.git'
Plug 'https://github.com/moll/vim-bbye.git'
Plug 'https://github.com/nathanaelkane/vim-indent-guides.git'
Plug 'https://github.com/ntpeters/vim-better-whitespace.git'
Plug 'https://github.com/othree/html5.vim.git'