|
|
|
|
@@ -84,6 +84,9 @@ let s:TYPE = {
|
|
|
|
|
\ }
|
|
|
|
|
let s:loaded = get(s:, 'loaded', {})
|
|
|
|
|
let s:triggers = get(s:, 'triggers', {})
|
|
|
|
|
let s:need_filetypeplugin_au = 0
|
|
|
|
|
let s:need_filetypeindent_au = 0
|
|
|
|
|
let s:autocmd_queue_for_vimenter = []
|
|
|
|
|
|
|
|
|
|
function! s:is_powershell(shell)
|
|
|
|
|
return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$'
|
|
|
|
|
@@ -323,6 +326,21 @@ function! plug#end()
|
|
|
|
|
if get(g:, 'did_load_filetypes', 0)
|
|
|
|
|
filetype off
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
let warn = []
|
|
|
|
|
if exists('g:did_load_ftplugin')
|
|
|
|
|
let warn += ['plugin']
|
|
|
|
|
let s:need_filetypeindent_au = 1
|
|
|
|
|
endif
|
|
|
|
|
if exists('g:did_indent_on')
|
|
|
|
|
let warn += ['indent']
|
|
|
|
|
let s:need_filetypeplugin_au = 1
|
|
|
|
|
endif
|
|
|
|
|
if !empty(warn)
|
|
|
|
|
redraw
|
|
|
|
|
call s:warn('echom', printf('[vim-plug] "filetype %s on" should not be used manually with vim-plug, please remove it from your vimrc.', join(warn)))
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
for name in g:plugs_order
|
|
|
|
|
if !has_key(g:plugs, name)
|
|
|
|
|
continue
|
|
|
|
|
@@ -398,7 +416,21 @@ function! plug#end()
|
|
|
|
|
if has('syntax') && !exists('g:syntax_on')
|
|
|
|
|
syntax enable
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
" NOTE: v:vim_did_enter might not exist with older Vims, and handling it
|
|
|
|
|
" manually can be used in tests.
|
|
|
|
|
let s:vim_did_enter = 0
|
|
|
|
|
function! s:plug_on_vimenter()
|
|
|
|
|
let s:vim_did_enter = 1
|
|
|
|
|
for event in s:autocmd_queue_for_vimenter
|
|
|
|
|
call s:doautocmd(event)
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
augroup PlugLOD
|
|
|
|
|
autocmd VimEnter * call s:plug_on_vimenter()
|
|
|
|
|
augroup END
|
|
|
|
|
else
|
|
|
|
|
let s:vim_did_enter = 1
|
|
|
|
|
call s:reload_plugins()
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
@@ -561,6 +593,12 @@ function! s:reorg_rtp()
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:doautocmd(...)
|
|
|
|
|
if !s:vim_did_enter
|
|
|
|
|
if index(s:autocmd_queue_for_vimenter, a:000) == -1
|
|
|
|
|
call add(s:autocmd_queue_for_vimenter, a:000)
|
|
|
|
|
endif
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
if exists('#'.join(a:000, '#'))
|
|
|
|
|
execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
|
|
|
|
|
endif
|
|
|
|
|
@@ -571,9 +609,7 @@ function! s:dobufread(names)
|
|
|
|
|
let path = s:rtp(g:plugs[name])
|
|
|
|
|
for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin']
|
|
|
|
|
if len(finddir(dir, path))
|
|
|
|
|
if exists('#BufRead')
|
|
|
|
|
doautocmd BufRead
|
|
|
|
|
endif
|
|
|
|
|
call s:doautocmd('BufRead')
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
endfor
|
|
|
|
|
@@ -647,8 +683,17 @@ function! s:lod_ft(pat, names)
|
|
|
|
|
let syn = 'syntax/'.a:pat.'.vim'
|
|
|
|
|
call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
|
|
|
|
|
execute 'autocmd! PlugLOD FileType' a:pat
|
|
|
|
|
call s:doautocmd('filetypeplugin', 'FileType')
|
|
|
|
|
call s:doautocmd('filetypeindent', 'FileType')
|
|
|
|
|
|
|
|
|
|
" Executing this is only necessary if "filetype plugin indent on" was used
|
|
|
|
|
" before plug#end, and can be skipped when Vim has not entered always.
|
|
|
|
|
if s:vim_did_enter
|
|
|
|
|
if s:need_filetypeplugin_au
|
|
|
|
|
call s:doautocmd('filetypeplugin', 'FileType')
|
|
|
|
|
endif
|
|
|
|
|
if s:need_filetypeindent_au
|
|
|
|
|
call s:doautocmd('filetypeindent', 'FileType')
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
|
|
|
|
@@ -783,10 +828,11 @@ endfunction
|
|
|
|
|
function! s:syntax()
|
|
|
|
|
syntax clear
|
|
|
|
|
syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
|
|
|
|
|
syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX
|
|
|
|
|
syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort
|
|
|
|
|
syn match plugNumber /[0-9]\+[0-9.]*/ contained
|
|
|
|
|
syn match plugBracket /[[\]]/ contained
|
|
|
|
|
syn match plugX /x/ contained
|
|
|
|
|
syn match plugAbort /\~/ contained
|
|
|
|
|
syn match plugDash /^-\{1}\ /
|
|
|
|
|
syn match plugPlus /^+/
|
|
|
|
|
syn match plugStar /^*/
|
|
|
|
|
@@ -811,6 +857,7 @@ function! s:syntax()
|
|
|
|
|
hi def link plug2 Repeat
|
|
|
|
|
hi def link plugH2 Type
|
|
|
|
|
hi def link plugX Exception
|
|
|
|
|
hi def link plugAbort Ignore
|
|
|
|
|
hi def link plugBracket Structure
|
|
|
|
|
hi def link plugNumber Number
|
|
|
|
|
|
|
|
|
|
@@ -908,7 +955,7 @@ function! s:prepare(...)
|
|
|
|
|
endif
|
|
|
|
|
endfor
|
|
|
|
|
|
|
|
|
|
call s:job_abort()
|
|
|
|
|
call s:job_abort(0)
|
|
|
|
|
if s:switch_in()
|
|
|
|
|
if b:plug_preview == 1
|
|
|
|
|
pc
|
|
|
|
|
@@ -944,6 +991,8 @@ function! s:close_pane()
|
|
|
|
|
if b:plug_preview == 1
|
|
|
|
|
pc
|
|
|
|
|
let b:plug_preview = -1
|
|
|
|
|
elseif exists('s:jobs') && !empty(s:jobs)
|
|
|
|
|
call s:job_abort(1)
|
|
|
|
|
else
|
|
|
|
|
bd
|
|
|
|
|
endif
|
|
|
|
|
@@ -1326,7 +1375,12 @@ function! s:update_finish()
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:job_abort()
|
|
|
|
|
function! s:mark_aborted(name, message)
|
|
|
|
|
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')
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
@@ -1340,8 +1394,18 @@ function! s:job_abort()
|
|
|
|
|
if j.new
|
|
|
|
|
call s:rm_rf(g:plugs[name].dir)
|
|
|
|
|
endif
|
|
|
|
|
if a:cancel
|
|
|
|
|
call s:mark_aborted(name, 'Aborted')
|
|
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
function! s:last_non_empty_line(lines)
|
|
|
|
|
@@ -1355,6 +1419,16 @@ function! s:last_non_empty_line(lines)
|
|
|
|
|
return ''
|
|
|
|
|
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
|
|
|
|
|
let self = a:self
|
|
|
|
|
let data = remove(self.lines, -1) . a:data
|
|
|
|
|
@@ -1363,10 +1437,9 @@ function! s:job_out_cb(self, data) abort
|
|
|
|
|
" To reduce the number of buffer updates
|
|
|
|
|
let self.tick = get(self, 'tick', -1) + 1
|
|
|
|
|
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)
|
|
|
|
|
if len(result)
|
|
|
|
|
call s:log(bullet, self.name, result)
|
|
|
|
|
call s:log(s:bullet_for(self), self.name, result)
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
@@ -1380,7 +1453,7 @@ endfunction
|
|
|
|
|
|
|
|
|
|
function! s:job_cb(fn, job, ch, data)
|
|
|
|
|
if !s:plug_window_exists() " plug window closed
|
|
|
|
|
return s:job_abort()
|
|
|
|
|
return s:job_abort(0)
|
|
|
|
|
endif
|
|
|
|
|
call call(a:fn, [a:job, a:data])
|
|
|
|
|
endfunction
|
|
|
|
|
@@ -1452,17 +1525,16 @@ function! s:reap(name)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
if len(result)
|
|
|
|
|
call s:log(bullet, a:name, result)
|
|
|
|
|
call s:log(s:bullet_for(job), a:name, result)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if !job.error && more
|
|
|
|
|
let job.spec.queue = job.queue
|
|
|
|
|
let s:update.todo[a:name] = job.spec
|
|
|
|
|
else
|
|
|
|
|
let s:update.bar .= job.error ? 'x' : '='
|
|
|
|
|
let s:update.bar .= s:bullet_for(job, '=')
|
|
|
|
|
call s:bar()
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
@@ -1541,6 +1613,12 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|
|
|
|
|
|
|
|
|
let name = keys(s:update.todo)[0]
|
|
|
|
|
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 new = empty(globpath(spec.dir, '.git', 1))
|
|
|
|
|
|
|
|
|
|
|