mirror of
https://github.com/junegunn/vim-plug.git
synced 2026-02-19 11:34:12 +08:00
Compare commits
3 Commits
0.14.0
...
2c64cbc5f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c64cbc5f9 | ||
|
|
82ffd4f9ca | ||
|
|
2958782ef4 |
@@ -315,7 +315,7 @@ vim.cmd('silent! colorscheme seoul256')
|
|||||||
- `S` - `PlugStatus`
|
- `S` - `PlugStatus`
|
||||||
- `R` - Retry failed update or installation tasks
|
- `R` - Retry failed update or installation tasks
|
||||||
- `U` - Update plugins in the selected range
|
- `U` - Update plugins in the selected range
|
||||||
- `q` - Abort the running tasks or close the window
|
- `q` - Close the window
|
||||||
- `:PlugStatus`
|
- `:PlugStatus`
|
||||||
- `L` - Load plugin
|
- `L` - Load plugin
|
||||||
- `:PlugDiff`
|
- `:PlugDiff`
|
||||||
|
|||||||
77
plug.vim
77
plug.vim
@@ -372,8 +372,10 @@ function! plug#end()
|
|||||||
|
|
||||||
for [cmd, names] in items(lod.cmd)
|
for [cmd, names] in items(lod.cmd)
|
||||||
execute printf(
|
execute printf(
|
||||||
\ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
\ has('patch-7.4.1898')
|
||||||
\ cmd, string(cmd), string(names))
|
\ ? 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, <q-mods> ,%s)'
|
||||||
|
\ : 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)'
|
||||||
|
\ , cmd, string(cmd), string(names))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
for [map, names] in items(lod.map)
|
for [map, names] in items(lod.map)
|
||||||
@@ -651,11 +653,19 @@ function! s:lod_ft(pat, names)
|
|||||||
call s:doautocmd('filetypeindent', 'FileType')
|
call s:doautocmd('filetypeindent', 'FileType')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
if has('patch-7.4.1898')
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
function! s:lod_cmd(cmd, bang, l1, l2, args, mods, names)
|
||||||
call s:dobufread(a:names)
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
call s:dobufread(a:names)
|
||||||
endfunction
|
execute printf('%s %s%s%s %s', a:mods, (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
||||||
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
|
call s:dobufread(a:names)
|
||||||
|
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
function! s:lod_map(map, names, with_prefix, prefix)
|
function! s:lod_map(map, names, with_prefix, prefix)
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
@@ -783,11 +793,10 @@ endfunction
|
|||||||
function! s:syntax()
|
function! s:syntax()
|
||||||
syntax clear
|
syntax clear
|
||||||
syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
|
syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
|
||||||
syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort
|
syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
|
||||||
syn match plugNumber /[0-9]\+[0-9.]*/ contained
|
syn match plugNumber /[0-9]\+[0-9.]*/ contained
|
||||||
syn match plugBracket /[[\]]/ contained
|
syn match plugBracket /[[\]]/ contained
|
||||||
syn match plugX /x/ contained
|
syn match plugX /x/ contained
|
||||||
syn match plugAbort /\~/ contained
|
|
||||||
syn match plugDash /^-\{1}\ /
|
syn match plugDash /^-\{1}\ /
|
||||||
syn match plugPlus /^+/
|
syn match plugPlus /^+/
|
||||||
syn match plugStar /^*/
|
syn match plugStar /^*/
|
||||||
@@ -812,7 +821,6 @@ function! s:syntax()
|
|||||||
hi def link plug2 Repeat
|
hi def link plug2 Repeat
|
||||||
hi def link plugH2 Type
|
hi def link plugH2 Type
|
||||||
hi def link plugX Exception
|
hi def link plugX Exception
|
||||||
hi def link plugAbort Ignore
|
|
||||||
hi def link plugBracket Structure
|
hi def link plugBracket Structure
|
||||||
hi def link plugNumber Number
|
hi def link plugNumber Number
|
||||||
|
|
||||||
@@ -910,7 +918,7 @@ function! s:prepare(...)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
call s:job_abort(0)
|
call s:job_abort()
|
||||||
if s:switch_in()
|
if s:switch_in()
|
||||||
if b:plug_preview == 1
|
if b:plug_preview == 1
|
||||||
pc
|
pc
|
||||||
@@ -946,8 +954,6 @@ function! s:close_pane()
|
|||||||
if b:plug_preview == 1
|
if b:plug_preview == 1
|
||||||
pc
|
pc
|
||||||
let b:plug_preview = -1
|
let b:plug_preview = -1
|
||||||
elseif exists('s:jobs') && !empty(s:jobs)
|
|
||||||
call s:job_abort(1)
|
|
||||||
else
|
else
|
||||||
bd
|
bd
|
||||||
endif
|
endif
|
||||||
@@ -1330,12 +1336,7 @@ function! s:update_finish()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:mark_aborted(name, message)
|
function! s:job_abort()
|
||||||
let attrs = { 'running': 0, 'error': 1, 'abort': 1, 'lines': [a:message] }
|
|
||||||
let s:jobs[a:name] = extend(get(s:jobs, a:name, {}), attrs)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:job_abort(cancel)
|
|
||||||
if (!s:nvim && !s:vim8) || !exists('s:jobs')
|
if (!s:nvim && !s:vim8) || !exists('s:jobs')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -1349,18 +1350,8 @@ function! s:job_abort(cancel)
|
|||||||
if j.new
|
if j.new
|
||||||
call s:rm_rf(g:plugs[name].dir)
|
call s:rm_rf(g:plugs[name].dir)
|
||||||
endif
|
endif
|
||||||
if a:cancel
|
|
||||||
call s:mark_aborted(name, 'Aborted')
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
|
let s:jobs = {}
|
||||||
if a:cancel
|
|
||||||
for todo in values(s:update.todo)
|
|
||||||
let todo.abort = 1
|
|
||||||
endfor
|
|
||||||
else
|
|
||||||
let s:jobs = {}
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:last_non_empty_line(lines)
|
function! s:last_non_empty_line(lines)
|
||||||
@@ -1374,16 +1365,6 @@ function! s:last_non_empty_line(lines)
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:bullet_for(job, ...)
|
|
||||||
if a:job.running
|
|
||||||
return a:job.new ? '+' : '*'
|
|
||||||
endif
|
|
||||||
if get(a:job, 'abort', 0)
|
|
||||||
return '~'
|
|
||||||
endif
|
|
||||||
return a:job.error ? 'x' : get(a:000, 0, '-')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:job_out_cb(self, data) abort
|
function! s:job_out_cb(self, data) abort
|
||||||
let self = a:self
|
let self = a:self
|
||||||
let data = remove(self.lines, -1) . a:data
|
let data = remove(self.lines, -1) . a:data
|
||||||
@@ -1392,9 +1373,10 @@ function! s:job_out_cb(self, data) abort
|
|||||||
" To reduce the number of buffer updates
|
" To reduce the number of buffer updates
|
||||||
let self.tick = get(self, 'tick', -1) + 1
|
let self.tick = get(self, 'tick', -1) + 1
|
||||||
if !self.running || self.tick % len(s:jobs) == 0
|
if !self.running || self.tick % len(s:jobs) == 0
|
||||||
|
let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
|
||||||
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
|
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
|
||||||
if len(result)
|
if len(result)
|
||||||
call s:log(s:bullet_for(self), self.name, result)
|
call s:log(bullet, self.name, result)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1408,7 +1390,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:job_cb(fn, job, ch, data)
|
function! s:job_cb(fn, job, ch, data)
|
||||||
if !s:plug_window_exists() " plug window closed
|
if !s:plug_window_exists() " plug window closed
|
||||||
return s:job_abort(0)
|
return s:job_abort()
|
||||||
endif
|
endif
|
||||||
call call(a:fn, [a:job, a:data])
|
call call(a:fn, [a:job, a:data])
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1480,16 +1462,17 @@ function! s:reap(name)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let more = len(get(job, 'queue', []))
|
let more = len(get(job, 'queue', []))
|
||||||
|
let bullet = job.error ? 'x' : more ? (job.new ? '+' : '*') : '-'
|
||||||
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
|
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
|
||||||
if len(result)
|
if len(result)
|
||||||
call s:log(s:bullet_for(job), a:name, result)
|
call s:log(bullet, a:name, result)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !job.error && more
|
if !job.error && more
|
||||||
let job.spec.queue = job.queue
|
let job.spec.queue = job.queue
|
||||||
let s:update.todo[a:name] = job.spec
|
let s:update.todo[a:name] = job.spec
|
||||||
else
|
else
|
||||||
let s:update.bar .= s:bullet_for(job, '=')
|
let s:update.bar .= job.error ? 'x' : '='
|
||||||
call s:bar()
|
call s:bar()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1568,12 +1551,6 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
|
|
||||||
let name = keys(s:update.todo)[0]
|
let name = keys(s:update.todo)[0]
|
||||||
let spec = remove(s:update.todo, name)
|
let spec = remove(s:update.todo, name)
|
||||||
if get(spec, 'abort', 0)
|
|
||||||
call s:mark_aborted(name, 'Skipped')
|
|
||||||
call s:reap(name)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let queue = get(spec, 'queue', [])
|
let queue = get(spec, 'queue', [])
|
||||||
let new = empty(globpath(spec.dir, '.git', 1))
|
let new = empty(globpath(spec.dir, '.git', 1))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user