Commit 9c5d304e authored by Murukesh Mohanan's avatar Murukesh Mohanan

plugin segregation

parent fe09b48c
.VimballRecord
.netrwhist
doc/*
bundle/*/doc/tags
plugged
view
spell/en.utf-8.add.spl
autoload/plug.vim.olg
......@@ -977,7 +977,7 @@ 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 = 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()
......@@ -1145,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' : ''
......@@ -1860,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)
......@@ -1875,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)
......@@ -1907,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.')
......@@ -1920,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()
......@@ -1972,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.']
......
......@@ -119,33 +119,41 @@ endfunction
"execute pathogen#infect()
call plug#begin()
Plug 'murukeshm/vim-manpager'
" Common plugins
Plug 'vim-scripts/diffchar.vim'
Plug 'scrooloose/nerdtree'
Plug 'ervandew/supertab'
Plug 'scrooloose/syntastic'
Plug 'dag/vim2hs', {'for': 'hs'}
Plug 'tpope/vim-surround'
Plug 'bling/vim-airline'
Plug 'tpope/vim-fugitive'
Plug 'lervag/vimtex', {'for': 'tex'}
Plug 'tomasr/molokai'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'gabrielelana/vim-markdown', {'for': 'markdown'}
Plug 'majutsushi/tagbar', {'for': ['cpp', 'c', 'go', 'sh', 'js']}
Plug 'fatih/vim-go', {'for': 'go'}
Plug 'godlygeek/tabular'
if executable('cmake')
" YCM command lifted from vim-plug readme
Plug 'Valloric/YouCompleteMe', { 'do': YCMInstallCmd(), 'for': ['cpp', 'c', 'go', 'sh', 'js', 'vim'] }
autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif
endif
Plug 'godlygeek/tabular'
if !has('windows')
if executable('go')
Plug 'fatih/vim-go', {'for': 'go'}
endif
if executable('latex')
Plug 'lervag/vimtex', {'for': 'tex'}
endif
if executable('ghc')
Plug 'dag/vim2hs', {'for': 'hs'}
endif
if executable('man')
Plug 'murukeshm/vim-manpager'
endif
if executable('dpkg')
Plug 'vim-scripts/deb.vim'
endif
if executable('logrotate')
Plug 'moon-musick/vim-logrotate'
endif
call plug#end()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment