Improved Go formatting support, upgrading Plug

This commit is contained in:
Alex Yatskov 2015-06-17 16:57:52 +09:00
parent 0c687c1082
commit 9baa4d4c8b
2 changed files with 124 additions and 99 deletions

View File

@ -14,6 +14,9 @@
" Plug 'junegunn/seoul256.vim' " Plug 'junegunn/seoul256.vim'
" Plug 'junegunn/vim-easy-align' " Plug 'junegunn/vim-easy-align'
" "
" " Group dependencies, vim-snippets depends on ultisnips
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"
" " On-demand loading " " On-demand loading
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' } " Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
@ -22,7 +25,7 @@
" Plug 'https://github.com/junegunn/vim-github-dashboard.git' " Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" "
" " Plugin options " " Plugin options
" Plug 'nsf/gocode', { 'tag': 'go.weekly.2012-03-13', 'rtp': 'vim' } " Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" "
" " Plugin outside ~/.vim/plugged with post-update hook " " Plugin outside ~/.vim/plugged with post-update hook
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' } " Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
@ -72,8 +75,6 @@ let s:plug_tab = get(s:, 'plug_tab', -1)
let s:plug_buf = get(s:, 'plug_buf', -1) let s:plug_buf = get(s:, 'plug_buf', -1)
let s:mac_gui = has('gui_macvim') && has('gui_running') let s:mac_gui = has('gui_macvim') && has('gui_running')
let s:is_win = has('win32') || has('win64') let s:is_win = has('win32') || has('win64')
let s:py2 = has('python') && !has('nvim') && !s:is_win && !has('win32unix')
let s:ruby = has('ruby') && !has('nvim') && (v:version >= 703 || v:version == 702 && has('patch374'))
let s:nvim = has('nvim') && exists('*jobwait') && !s:is_win let s:nvim = has('nvim') && exists('*jobwait') && !s:is_win
let s:me = resolve(expand('<sfile>:p')) let s:me = resolve(expand('<sfile>:p'))
let s:base_spec = { 'branch': 'master', 'frozen': 0 } let s:base_spec = { 'branch': 'master', 'frozen': 0 }
@ -358,7 +359,9 @@ function! plug#load(...)
for name in a:000 for name in a:000
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
endfor endfor
if exists('#BufRead')
doautocmd BufRead doautocmd BufRead
endif
return 1 return 1
endfunction endfunction
@ -388,14 +391,21 @@ function! s:lod(names, types)
for dir in a:types for dir in a:types
call s:source(rtp, dir.'/**/*.vim') call s:source(rtp, dir.'/**/*.vim')
endfor endfor
if exists('#User#'.name)
execute 'doautocmd User' name
endif
endfor endfor
endfunction endfunction
function! s:lod_ft(pat, names) function! s:lod_ft(pat, names)
call s:lod(a:names, ['plugin', 'after/plugin']) call s:lod(a:names, ['plugin', 'after/plugin'])
execute 'autocmd! PlugLOD FileType' a:pat execute 'autocmd! PlugLOD FileType' a:pat
if exists('#filetypeplugin#FileType')
doautocmd filetypeplugin FileType doautocmd filetypeplugin FileType
endif
if exists('#filetypeindent#FileType')
doautocmd filetypeindent FileType doautocmd filetypeindent FileType
endif
endfunction endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, names) function! s:lod_cmd(cmd, bang, l1, l2, args, names)
@ -430,7 +440,7 @@ function! s:add(repo, ...)
call add(g:plugs_order, name) call add(g:plugs_order, name)
endif endif
let g:plugs[name] = spec let g:plugs[name] = spec
let s:loaded[name] = 0 let s:loaded[name] = get(s:loaded, name, 0)
catch catch
return s:err(v:exception) return s:err(v:exception)
endtry endtry
@ -746,6 +756,10 @@ function! s:update_impl(pull, force, args) abort
echohl None echohl None
endif endif
let python = (has('python') || has('python3')) && !s:is_win && !has('win32unix')
\ && (!s:nvim || has('vim_starting'))
let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374'))
let s:update = { let s:update = {
\ 'start': reltime(), \ 'start': reltime(),
\ 'all': todo, \ 'all': todo,
@ -754,7 +768,7 @@ function! s:update_impl(pull, force, args) abort
\ 'pull': a:pull, \ 'pull': a:pull,
\ 'force': a:force, \ 'force': a:force,
\ 'new': {}, \ 'new': {},
\ 'threads': (s:py2 || s:ruby || s:nvim) ? min([len(todo), threads]) : 1, \ 'threads': (python || ruby || s:nvim) ? min([len(todo), threads]) : 1,
\ 'bar': '', \ 'bar': '',
\ 'fin': 0 \ 'fin': 0
\ } \ }
@ -762,22 +776,27 @@ function! s:update_impl(pull, force, args) abort
call s:prepare() call s:prepare()
call append(0, ['', '']) call append(0, ['', ''])
normal! 2G normal! 2G
silent! redraw
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
" Python version requirement (>= 2.7) " Python version requirement (>= 2.7)
if s:py2 && !s:ruby && !s:nvim && s:update.threads > 1 if python && !has('python3') && !ruby && !s:nvim && s:update.threads > 1
redir => pyv redir => pyv
silent python import platform; print(platform.python_version()) silent python import platform; print(platform.python_version())
redir END redir END
let s:py2 = s:version_requirement( let python = s:version_requirement(
\ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
endif endif
if (s:py2 || s:ruby) && !s:nvim && s:update.threads > 1
if (python || ruby) && s:update.threads > 1
try try
let imd = &imd let imd = &imd
if s:mac_gui if s:mac_gui
set noimd set noimd
endif endif
if s:ruby if ruby
call s:update_ruby() call s:update_ruby()
else else
call s:update_python() call s:update_python()
@ -961,16 +980,18 @@ while 1 " Without TCO, Vim stack is bound to explode
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
redraw redraw
let checkout = s:shellesc(has_key(spec, 'tag') ? spec.tag : spec.branch) let has_tag = has_key(spec, 'tag')
let merge = s:shellesc(has_key(spec, 'tag') ? spec.tag : 'origin/'.spec.branch) let checkout = s:shellesc(has_tag ? spec.tag : spec.branch)
let merge = s:shellesc(has_tag ? spec.tag : 'origin/'.spec.branch)
if !new if !new
let [valid, msg] = s:git_valid(spec, 0) let [valid, msg] = s:git_valid(spec, 0)
if valid if valid
if pull if pull
let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
call s:spawn(name, call s:spawn(name,
\ printf('(git fetch %s 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only %s 2>&1 && git submodule update --init --recursive 2>&1)', \ printf('(git fetch %s %s 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only %s 2>&1 && git submodule update --init --recursive 2>&1)',
\ prog, checkout, merge), { 'dir': spec.dir }) \ fetch_opt, prog, checkout, merge), { 'dir': spec.dir })
else else
let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 } let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 }
endif endif
@ -979,7 +1000,8 @@ while 1 " Without TCO, Vim stack is bound to explode
endif endif
else else
call s:spawn(name, call s:spawn(name,
\ printf('git clone %s --recursive %s -b %s %s 2>&1', \ printf('git clone %s %s --recursive %s -b %s %s 2>&1',
\ has_tag ? '' : s:clone_opt,
\ prog, \ prog,
\ s:shellesc(spec.uri), \ s:shellesc(spec.uri),
\ checkout, \ checkout,
@ -996,12 +1018,16 @@ endwhile
endfunction endfunction
function! s:update_python() function! s:update_python()
python << EOF let py_exe = has('python3') ? 'python3' : 'python'
execute py_exe "<< EOF"
""" Due to use of signals this function is POSIX only. """ """ Due to use of signals this function is POSIX only. """
import datetime import datetime
import functools import functools
import os import os
import Queue try:
import queue
except ImportError:
import Queue as queue
import random import random
import re import re
import shutil import shutil
@ -1013,48 +1039,36 @@ import time
import traceback import traceback
import vim import vim
G_NVIM = vim.eval("has('nvim')") == '1'
G_PULL = vim.eval('s:update.pull') == '1' G_PULL = vim.eval('s:update.pull') == '1'
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
G_CLONE_OPT = vim.eval('s:clone_opt')
G_PROGRESS = vim.eval('s:progress_opt(1)') G_PROGRESS = vim.eval('s:progress_opt(1)')
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
G_STOP = thr.Event() G_STOP = thr.Event()
G_THREADS = {}
class CmdTimedOut(Exception): class BaseExc(Exception):
def __init__(self, msg):
self._msg = msg
@property
def msg(self):
return self._msg
class CmdTimedOut(BaseExc):
pass pass
class CmdFailed(Exception): class CmdFailed(BaseExc):
pass pass
class InvalidURI(Exception): class InvalidURI(BaseExc):
pass pass
class Action(object): class Action(object):
INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
class GLog(object):
ON = None
LOGDIR = None
@classmethod
def write(cls, msg):
if cls.ON is None:
cls.ON = int(vim.eval('get(g:, "plug_log_on", 0)'))
cls.LOGDIR = os.path.expanduser(vim.eval('get(g:, "plug_logs", "~/plug_logs")'))
if cls.ON:
if not os.path.exists(cls.LOGDIR):
os.makedirs(cls.LOGDIR)
cls._write(msg)
@classmethod
def _write(cls, msg):
name = thr.current_thread().name
fname = cls.LOGDIR + os.path.sep + name
with open(fname, 'ab') as flog:
ltime = datetime.datetime.now().strftime("%H:%M:%S.%f")
msg = '[{0},{1}] {2}{3}'.format(name, ltime, msg, '\n')
flog.write(msg)
class Buffer(object): class Buffer(object):
def __init__(self, lock, num_plugs): def __init__(self, lock, num_plugs, is_pull, is_win):
self.bar = '' self.bar = ''
self.event = 'Updating' if vim.eval('s:update.pull') == '1' else 'Installing' self.event = 'Updating' if is_pull else 'Installing'
self.is_win = vim.eval('s:is_win') == '1' self.is_win = is_win
self.lock = lock self.lock = lock
self.maxy = int(vim.eval('winheight(".")')) self.maxy = int(vim.eval('winheight(".")'))
self.num_plugs = num_plugs self.num_plugs = num_plugs
@ -1080,15 +1094,12 @@ class Buffer(object):
num_spaces = self.num_plugs - len(self.bar) num_spaces = self.num_plugs - len(self.bar)
curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
with self.lock:
vim.command('normal! 2G') vim.command('normal! 2G')
if not self.is_win: if not self.is_win:
vim.command('redraw') vim.command('redraw')
def write(self, *args, **kwargs): def write(self, action, name, lines):
with self.lock:
self._write(*args, **kwargs)
def _write(self, action, name, lines):
first, rest = lines[0], lines[1:] first, rest = lines[0], lines[1:]
msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)]
padded_rest = [' ' + line for line in rest] padded_rest = [' ' + line for line in rest]
@ -1113,7 +1124,7 @@ class Buffer(object):
self.header() self.header()
except vim.error: except vim.error:
GLog.write('Buffer Update FAILED.') pass
class Command(object): class Command(object):
def __init__(self, cmd, cmd_dir=None, timeout=60, ntries=3, cb=None, clean=None): def __init__(self, cmd, cmd_dir=None, timeout=60, ntries=3, cb=None, clean=None):
@ -1159,7 +1170,7 @@ class Command(object):
proc = None proc = None
first_line = True first_line = True
try: try:
tfile = tempfile.NamedTemporaryFile() tfile = tempfile.NamedTemporaryFile(mode='w+b', delete=False)
proc = subprocess.Popen(self.cmd, cwd=self.cmd_dir, stdout=tfile, proc = subprocess.Popen(self.cmd, cwd=self.cmd_dir, stdout=tfile,
stderr=subprocess.STDOUT, shell=True, preexec_fn=os.setsid) stderr=subprocess.STDOUT, shell=True, preexec_fn=os.setsid)
while proc.poll() is None: while proc.poll() is None:
@ -1180,7 +1191,7 @@ class Command(object):
raise CmdTimedOut(['Timeout!']) raise CmdTimedOut(['Timeout!'])
tfile.seek(0) tfile.seek(0)
result = [line.rstrip() for line in tfile] result = [line.decode().rstrip() for line in tfile]
if proc.returncode != 0: if proc.returncode != 0:
msg = [''] msg = ['']
@ -1192,18 +1203,21 @@ class Command(object):
if self.clean: if self.clean:
self.clean() self.clean()
raise raise
finally:
os.remove(tfile.name)
return result return result
class Plugin(object): class Plugin(object):
def __init__(self, name, args, buf, lock): def __init__(self, name, args, buf_q, lock):
self.name = name self.name = name
self.args = args self.args = args
self.buf = buf self.buf_q = buf_q
self.lock = lock self.lock = lock
tag = args.get('tag', 0) tag = args.get('tag', 0)
self.checkout = esc(tag if tag else args['branch']) self.checkout = esc(tag if tag else args['branch'])
self.merge = esc(tag if tag else 'origin/' + args['branch']) self.merge = esc(tag if tag else 'origin/' + args['branch'])
self.tag = tag
def manage(self): def manage(self):
try: try:
@ -1212,9 +1226,9 @@ class Plugin(object):
else: else:
self.install() self.install()
with self.lock: with self.lock:
vim.command("let s:update.new['{0}'] = 1".format(self.name)) thread_vim_command("let s:update.new['{0}'] = 1".format(self.name))
except (CmdTimedOut, CmdFailed, InvalidURI) as exc: except (CmdTimedOut, CmdFailed, InvalidURI) as exc:
self.write(Action.ERROR, self.name, exc.message) self.write(Action.ERROR, self.name, exc.msg)
except KeyboardInterrupt: except KeyboardInterrupt:
G_STOP.set() G_STOP.set()
self.write(Action.ERROR, self.name, ['Interrupted!']) self.write(Action.ERROR, self.name, ['Interrupted!'])
@ -1236,9 +1250,9 @@ class Plugin(object):
return _clean return _clean
self.write(Action.INSTALL, self.name, ['Installing ...']) self.write(Action.INSTALL, self.name, ['Installing ...'])
callback = functools.partial(self.buf.write, Action.INSTALL, self.name) callback = functools.partial(self.write, Action.INSTALL, self.name)
cmd = 'git clone {0} --recursive {1} -b {2} {3} 2>&1'.format( cmd = 'git clone {0} {1} --recursive {2} -b {3} {4} 2>&1'.format(
G_PROGRESS, self.args['uri'], self.checkout, esc(target)) '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], self.checkout, esc(target))
com = Command(cmd, None, G_TIMEOUT, G_RETRIES, callback, clean(target)) com = Command(cmd, None, G_TIMEOUT, G_RETRIES, callback, clean(target))
result = com.attempt_cmd() result = com.attempt_cmd()
self.write(Action.DONE, self.name, result[-1:]) self.write(Action.DONE, self.name, result[-1:])
@ -1256,16 +1270,15 @@ class Plugin(object):
if G_PULL: if G_PULL:
self.write(Action.UPDATE, self.name, ['Updating ...']) self.write(Action.UPDATE, self.name, ['Updating ...'])
callback = functools.partial(self.buf.write, Action.UPDATE, self.name) callback = functools.partial(self.write, Action.UPDATE, self.name)
cmds = ['git fetch {0}'.format(G_PROGRESS), fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else ''
cmds = ['git fetch {0} {1}'.format(fetch_opt, G_PROGRESS),
'git checkout -q {0}'.format(self.checkout), 'git checkout -q {0}'.format(self.checkout),
'git merge --ff-only {0}'.format(self.merge), 'git merge --ff-only {0}'.format(self.merge),
'git submodule update --init --recursive'] 'git submodule update --init --recursive']
cmd = ' 2>&1 && '.join(cmds) cmd = ' 2>&1 && '.join(cmds)
GLog.write(cmd)
com = Command(cmd, self.args['dir'], G_TIMEOUT, G_RETRIES, callback) com = Command(cmd, self.args['dir'], G_TIMEOUT, G_RETRIES, callback)
result = com.attempt_cmd() result = com.attempt_cmd()
GLog.write(result)
self.write(Action.DONE, self.name, result[-1:]) self.write(Action.DONE, self.name, result[-1:])
else: else:
self.write(Action.DONE, self.name, ['Already installed']) self.write(Action.DONE, self.name, ['Already installed'])
@ -1277,8 +1290,7 @@ class Plugin(object):
return result[-1] return result[-1]
def write(self, action, name, msg): def write(self, action, name, msg):
GLog.write('{0} {1}: {2}'.format(action, name, '\n'.join(msg))) self.buf_q.put((action, name, msg))
self.buf.write(action, name, msg)
class PlugThread(thr.Thread): class PlugThread(thr.Thread):
def __init__(self, tname, args): def __init__(self, tname, args):
@ -1288,17 +1300,20 @@ class PlugThread(thr.Thread):
def run(self): def run(self):
thr.current_thread().name = self.tname thr.current_thread().name = self.tname
work_q, lock, buf = self.args buf_q, work_q, lock = self.args
try: try:
while not G_STOP.is_set(): while not G_STOP.is_set():
name, args = work_q.get_nowait() name, args = work_q.get_nowait()
GLog.write('{0}: Dir {1}'.format(name, args['dir'])) plug = Plugin(name, args, buf_q, lock)
plug = Plugin(name, args, buf, lock)
plug.manage() plug.manage()
work_q.task_done() work_q.task_done()
except Queue.Empty: except queue.Empty:
GLog.write('Queue now empty.') pass
finally:
global G_THREADS
with lock:
del G_THREADS[thr.current_thread().name]
class RefreshThread(thr.Thread): class RefreshThread(thr.Thread):
def __init__(self, lock): def __init__(self, lock):
@ -1309,19 +1324,26 @@ class RefreshThread(thr.Thread):
def run(self): def run(self):
while self.running: while self.running:
with self.lock: with self.lock:
vim.command('noautocmd normal! a') thread_vim_command('noautocmd normal! a')
time.sleep(0.2) time.sleep(0.2)
def stop(self): def stop(self):
self.running = False self.running = False
if G_NVIM:
def thread_vim_command(cmd):
vim.session.threadsafe_call(lambda: vim.command(cmd))
else:
def thread_vim_command(cmd):
vim.command(cmd)
def esc(name): def esc(name):
return '"' + name.replace('"', '\"') + '"' return '"' + name.replace('"', '\"') + '"'
def nonblock_read(fname): def nonblock_read(fname):
""" Read a file with nonblock flag. Return the last line. """ """ Read a file with nonblock flag. Return the last line. """
fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
buf = os.read(fread, 100000) buf = os.read(fread, 100000).decode()
os.close(fread) os.close(fread)
line = buf.rstrip('\r\n') line = buf.rstrip('\r\n')
@ -1334,42 +1356,40 @@ def nonblock_read(fname):
def main(): def main():
thr.current_thread().name = 'main' thr.current_thread().name = 'main'
GLog.write('')
if GLog.ON and os.path.exists(GLog.LOGDIR):
shutil.rmtree(GLog.LOGDIR)
threads = []
nthreads = int(vim.eval('s:update.threads')) nthreads = int(vim.eval('s:update.threads'))
plugs = vim.eval('s:update.todo') plugs = vim.eval('s:update.todo')
mac_gui = vim.eval('s:mac_gui') == '1' mac_gui = vim.eval('s:mac_gui') == '1'
is_win = vim.eval('s:is_win') == '1' is_win = vim.eval('s:is_win') == '1'
GLog.write('Plugs: {0}'.format(plugs))
GLog.write('PULL: {0}, WIN: {1}, MAC: {2}'.format(G_PULL, is_win, mac_gui))
GLog.write('Num Threads: {0}'.format(nthreads))
lock = thr.Lock() lock = thr.Lock()
buf = Buffer(lock, len(plugs)) buf = Buffer(lock, len(plugs), G_PULL, is_win)
work_q = Queue.Queue() buf_q, work_q = queue.Queue(), queue.Queue()
for work in plugs.items(): for work in plugs.items():
work_q.put(work) work_q.put(work)
GLog.write('Starting Threads') global G_THREADS
for num in range(nthreads): for num in range(nthreads):
tname = 'PlugT-{0:02}'.format(num) tname = 'PlugT-{0:02}'.format(num)
thread = PlugThread(tname, (work_q, lock, buf)) thread = PlugThread(tname, (buf_q, work_q, lock))
thread.start() thread.start()
threads.append(thread) G_THREADS[tname] = thread
if mac_gui: if mac_gui:
rthread = RefreshThread(lock) rthread = RefreshThread(lock)
rthread.start() rthread.start()
GLog.write('Joining Live Threads') while not buf_q.empty() or len(G_THREADS) != 0:
for thread in threads: try:
thread.join() action, name, msg = buf_q.get(True, 0.25)
buf.write(action, name, msg)
buf_q.task_done()
except queue.Empty:
pass
except KeyboardInterrupt:
G_STOP.set()
if mac_gui: if mac_gui:
rthread.stop() rthread.stop()
rthread.join() rthread.join()
GLog.write('Cleanly Exited Main')
main() main()
EOF EOF
@ -1533,6 +1553,7 @@ function! s:update_ruby()
end end
} if VIM::evaluate('s:mac_gui') == 1 } if VIM::evaluate('s:mac_gui') == 1
clone_opt = VIM::evaluate('s:clone_opt')
progress = VIM::evaluate('s:progress_opt(1)') progress = VIM::evaluate('s:progress_opt(1)')
nthr.times do nthr.times do
mtx.synchronize do mtx.synchronize do
@ -1562,7 +1583,8 @@ function! s:update_ruby()
else else
if pull if pull
log.call name, 'Updating ...', :update log.call name, 'Updating ...', :update
bt.call "#{cd} #{dir} && git fetch #{progress} 2>&1 && git checkout -q #{checkout} 2>&1 && git merge --ff-only #{merge} 2>&1 && #{subm}", name, :update, nil fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : ''
bt.call "#{cd} #{dir} && git fetch #{fetch_opt} #{progress} 2>&1 && git checkout -q #{checkout} 2>&1 && git merge --ff-only #{merge} 2>&1 && #{subm}", name, :update, nil
else else
[true, skip] [true, skip]
end end
@ -1570,7 +1592,7 @@ function! s:update_ruby()
else else
d = esc dir.sub(%r{[\\/]+$}, '') d = esc dir.sub(%r{[\\/]+$}, '')
log.call name, 'Installing ...', :install log.call name, 'Installing ...', :install
bt.call "git clone #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc { bt.call "git clone #{clone_opt unless tag} #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc {
FileUtils.rm_rf dir FileUtils.rm_rf dir
} }
end end
@ -1620,14 +1642,14 @@ endfunction
function! s:system(cmd, ...) function! s:system(cmd, ...)
try try
let sh = &shell let [sh, shrd] = [&shell, &shellredir]
if !s:is_win if !s:is_win
set shell=sh set shell=sh shellredir=>%s\ 2>&1
endif endif
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
return system(s:is_win ? '('.cmd.')' : cmd) return system(s:is_win ? '('.cmd.')' : cmd)
finally finally
let &shell = sh let [&shell, &shellredir] = [sh, shrd]
endtry endtry
endfunction endfunction
@ -1880,7 +1902,7 @@ function! s:preview_commit()
execute 'pedit' sha execute 'pedit' sha
wincmd P wincmd P
setlocal filetype=git buftype=nofile nobuflisted setlocal filetype=git buftype=nofile nobuflisted
execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show' sha execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --pretty=medium' sha
normal! gg"_dd normal! gg"_dd
wincmd p wincmd p
endfunction endfunction

View File

@ -53,6 +53,9 @@ let g:syntastic_always_populate_loc_list = 1
" vim-airline " vim-airline
let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#enabled = 1
" vim-go
let g:go_fmt_command = 'goimports'
" vim-latex " vim-latex
let g:Tex_DefaultTargetFormat = 'pdf' let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_MultipleCompileFormats = 'pdf, aux' let g:Tex_MultipleCompileFormats = 'pdf, aux'