15 Commits
0.6.1 ... 0.6.2

Author SHA1 Message Date
Junegunn Choi
3606c294de Merge pull request #135 from threeifbywhiskey/confirmation-convention
Downcase opt-in confirmation options
2014-12-08 23:58:05 +09:00
Dorien Snake
06f903d8af Downcase opt-in confirmation options
There's a fairly widespread convention which recommends indicating the default
confirmation option in uppercase. Granted, the number of applicable instances
in vim-plug is currently only two, but perhaps this'll save users with such an
inclination having to hit Enter just to sate their curiosities.
2014-12-08 08:49:45 -05:00
Junegunn Choi
1f704deb76 Merge branch 'master' of github.com:junegunn/vim-plug 2014-12-08 17:37:46 +09:00
Junegunn Choi
3ebf6361bf Update README 2014-12-08 17:37:26 +09:00
Junegunn Choi
9b99c1f885 Merge pull request #134 from wilywampa/master
Check for full match of command name
2014-12-08 10:02:09 +09:00
Jacob Niehus
53cc8a53d9 Check for full match of command name 2014-12-07 13:19:09 -07:00
Junegunn Choi
2ee153d610 Define s:triggers by default to avoid error after upgrade (#132) 2014-12-05 12:05:57 +09:00
Junegunn Choi
7019171737 Fix #131 - Syntax error 2014-12-04 15:13:37 +09:00
Junegunn Choi
044c3a67c4 Fix #130 - Proper cleanup of on-demand loading triggers 2014-12-04 13:06:13 +09:00
Junegunn Choi
48514768c2 Fix missing progress update (#127)
In the recent versions of NeoVim, jobstart() does not return
monotonically increasing numbers, this caused vim-plug to miss updating
the progress of a task when the job ID for the task is already
reassigned to a new task.
2014-12-02 02:48:25 +09:00
Junegunn Choi
68ad02c5c3 Display "Press 'D'" message only when existing plugins are updated
Fix #123
2014-11-24 03:32:01 +09:00
Junegunn Choi
12bc2ea1da Fix some test code 2014-11-21 01:06:17 +09:00
Junegunn Choi
ade7fb95b1 Fix failing test case 2014-11-08 11:33:11 +09:00
Junegunn Choi
9c55223869 Merge pull request #118 from splinterofchaos/job_data-list
Update: job_data[2] as a list.
2014-11-08 10:28:53 +09:00
Scott Prager
495becf442 Update: job_data[2] is a list. 2014-10-29 01:03:58 -04:00
3 changed files with 96 additions and 27 deletions

View File

@@ -1,9 +1,9 @@
![vim-plug](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png) <img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="56" alt="vim-plug">
[![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)](https://travis-ci.org/junegunn/vim-plug) [![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)](https://travis-ci.org/junegunn/vim-plug)
A minimalist Vim plugin manager. A minimalist Vim plugin manager.
![](https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif) <img src="https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif" height="450">
### Pros. ### Pros.

View File

@@ -83,6 +83,7 @@ let s:TYPE = {
\ 'funcref': type(function('call')) \ 'funcref': type(function('call'))
\ } \ }
let s:loaded = get(s:, 'loaded', {}) let s:loaded = get(s:, 'loaded', {})
let s:triggers = get(s:, 'triggers', {})
function! plug#begin(...) function! plug#begin(...)
if a:0 > 0 if a:0 > 0
@@ -99,6 +100,7 @@ function! plug#begin(...)
let g:plug_home = home let g:plug_home = home
let g:plugs = {} let g:plugs = {}
let g:plugs_order = [] let g:plugs_order = []
let s:triggers = {}
call s:define_commands() call s:define_commands()
return 1 return 1
@@ -122,6 +124,10 @@ function! s:to_a(v)
return type(a:v) == s:TYPE.list ? a:v : [a:v] return type(a:v) == s:TYPE.list ? a:v : [a:v]
endfunction endfunction
function! s:to_s(v)
return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n"
endfunction
function! s:source(from, ...) function! s:source(from, ...)
for pattern in a:000 for pattern in a:000
for vim in s:lines(globpath(a:from, pattern)) for vim in s:lines(globpath(a:from, pattern))
@@ -152,6 +158,7 @@ function! plug#end()
endif endif
if has_key(plug, 'on') if has_key(plug, 'on')
let s:triggers[name] = { 'map': [], 'cmd': [] }
for cmd in s:to_a(plug.on) for cmd in s:to_a(plug.on)
if cmd =~ '^<Plug>.\+' if cmd =~ '^<Plug>.\+'
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
@@ -162,10 +169,14 @@ function! plug#end()
\ mode, cmd, map_prefix, string(cmd), string(name), key_prefix) \ mode, cmd, map_prefix, string(cmd), string(name), key_prefix)
endfor endfor
endif endif
elseif !exists(':'.cmd) call add(s:triggers[name].map, cmd)
execute printf( elseif cmd =~ '^[A-Z]'
\ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)', if exists(':'.cmd) != 2
\ cmd, string(cmd), string(name)) execute printf(
\ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
\ cmd, string(cmd), string(name))
endif
call add(s:triggers[name].cmd, cmd)
endif endif
endfor endfor
endif endif
@@ -320,8 +331,23 @@ function! plug#load(...)
return 1 return 1
endfunction endfunction
function! s:remove_triggers(name)
if !has_key(s:triggers, a:name)
return
endif
for cmd in s:triggers[a:name].cmd
execute 'delc' cmd
endfor
for map in s:triggers[a:name].map
execute 'unmap' map
execute 'iunmap' map
endfor
call remove(s:triggers, a:name)
endfunction
function! s:lod(names, types) function! s:lod(names, types)
for name in a:names for name in a:names
call s:remove_triggers(name)
let s:loaded[name] = 1 let s:loaded[name] = 1
endfor endfor
call s:reorg_rtp() call s:reorg_rtp()
@@ -342,14 +368,11 @@ function! s:lod_ft(pat, names)
endfunction endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, name) function! s:lod_cmd(cmd, bang, l1, l2, args, name)
execute 'delc' a:cmd
call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod([a:name], ['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) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
endfunction endfunction
function! s:lod_map(map, name, prefix) function! s:lod_map(map, name, prefix)
execute 'unmap' a:map
execute 'iunmap' a:map
call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
let extra = '' let extra = ''
while 1 while 1
@@ -629,7 +652,7 @@ function! s:finish(pull)
if !empty(s:update.errors) if !empty(s:update.errors)
call add(msgs, "Press 'R' to retry.") call add(msgs, "Press 'R' to retry.")
endif endif
if a:pull && !empty(filter(getline(5, '$'), if a:pull && len(s:update.new) < len(filter(getline(5, '$'),
\ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0")) \ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0"))
call add(msgs, "Press 'D' to see the updated changes.") call add(msgs, "Press 'D' to see the updated changes.")
endif endif
@@ -672,7 +695,7 @@ function! s:update_impl(pull, force, args) abort
try try
call mkdir(g:plug_home, 'p') call mkdir(g:plug_home, 'p')
catch catch
return s:err(printf('Invalid plug directory: %s.' return s:err(printf('Invalid plug directory: %s. '.
\ 'Try to call plug#begin with a valid directory', g:plug_home)) \ 'Try to call plug#begin with a valid directory', g:plug_home))
endtry endtry
endif endif
@@ -748,20 +771,18 @@ function! s:job_abort()
call system('rm -rf ' . s:shellesc(g:plugs[name].dir)) call system('rm -rf ' . s:shellesc(g:plugs[name].dir))
endif endif
endfor endfor
let s:jobs = {} let s:jobs = {}
let s:jobs_idx = {}
endfunction endfunction
function! s:job_handler() abort function! s:job_handler(name) abort
if !s:plug_window_exists() " plug window closed if !s:plug_window_exists() " plug window closed
return s:job_abort() return s:job_abort()
endif endif
let name = get(s:jobs_idx, v:job_data[0], '') if !has_key(s:jobs, a:name)
if empty(name) " stale task
return return
endif endif
let job = s:jobs[name] let job = s:jobs[a:name]
if v:job_data[1] == 'exit' if v:job_data[1] == 'exit'
let job.running = 0 let job.running = 0
@@ -769,14 +790,14 @@ function! s:job_handler() abort
let job.error = 1 let job.error = 1
let job.result = substitute(job.result, "Error[\r\n]$", '', '') let job.result = substitute(job.result, "Error[\r\n]$", '', '')
endif endif
call s:reap(name) call s:reap(a:name)
call s:tick() call s:tick()
else else
let job.result .= v:job_data[2] let job.result .= s:to_s(v:job_data[2])
" To reduce the number of buffer updates " To reduce the number of buffer updates
let job.tick = get(job, 'tick', -1) + 1 let job.tick = get(job, 'tick', -1) + 1
if job.tick % len(s:jobs) == 0 if job.tick % len(s:jobs) == 0
call s:log(job.new ? '+' : '*', name, job.result) call s:log(job.new ? '+' : '*', a:name, job.result)
endif endif
endif endif
endfunction endfunction
@@ -791,10 +812,9 @@ function! s:spawn(name, cmd, opts)
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) \ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd)
\ . ' || echo Error']) \ . ' || echo Error'])
if x > 0 if x > 0
let s:jobs_idx[x] = a:name
let job.jobid = x let job.jobid = x
augroup PlugJobControl augroup PlugJobControl
execute 'autocmd JobActivity' a:name 'call s:job_handler()' execute 'autocmd JobActivity' a:name printf('call s:job_handler(%s)', string(a:name))
augroup END augroup END
else else
let job.running = 0 let job.running = 0
@@ -865,8 +885,7 @@ function! s:log(bullet, name, lines)
endfunction endfunction
function! s:update_vim() function! s:update_vim()
let s:jobs = {} let s:jobs = {}
let s:jobs_idx = {}
call s:bar() call s:bar()
call s:tick() call s:tick()
@@ -1247,7 +1266,7 @@ function! s:clean(force)
call append(line('$'), 'Already clean.') call append(line('$'), 'Already clean.')
else else
call inputsave() call inputsave()
let yes = a:force || (input('Proceed? (Y/N) ') =~? '^y') let yes = a:force || (input('Proceed? (y/N) ') =~? '^y')
call inputrestore() call inputrestore()
if yes if yes
for dir in todo for dir in todo
@@ -1464,7 +1483,7 @@ endfunction
function! s:revert() function! s:revert()
let name = s:find_name(line('.')) let name = s:find_name(line('.'))
if empty(name) || !has_key(g:plugs, name) || if empty(name) || !has_key(g:plugs, name) ||
\ input(printf('Revert the update of %s? (Y/N) ', name)) !~? '^y' \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y'
return return
endif endif

View File

@@ -304,7 +304,8 @@ Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
" ]] motion " ]] motion
execute 'normal $]]' execute 'normal $]]'
AssertEqual lnum + 4, line('.') Assert index([lnum + 4, lnum + 5], line('.')) >= 0
" +5 for merge commit
AssertEqual 3, col('.') AssertEqual 3, col('.')
" [[ motion " [[ motion
@@ -451,6 +452,7 @@ Execute (Plug block for following tests):
call plug#end() call plug#end()
" Remove plugins from previous tests " Remove plugins from previous tests
PlugClean! PlugClean!
q
Execute (PlugInstall will only install vim-easy-align): Execute (PlugInstall will only install vim-easy-align):
PlugInstall PlugInstall
@@ -619,6 +621,7 @@ Execute (Cleanup):
call plug#begin() call plug#begin()
call plug#end() call plug#end()
PlugClean! PlugClean!
q
Execute (On install): Execute (On install):
call plug#begin() call plug#begin()
@@ -1074,6 +1077,7 @@ Execute (PlugSnapshot):
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
call plug#end() call plug#end()
PlugClean!
PlugInstall PlugInstall
PlugSnapshot PlugSnapshot
AssertEqual '#!/bin/bash', getline(1) AssertEqual '#!/bin/bash', getline(1)
@@ -1099,6 +1103,52 @@ Execute (#114 Should not contain empty path in &rtp):
Assert &rtp !~ '^,', 'Comma prefix' Assert &rtp !~ '^,', 'Comma prefix'
Assert &rtp !~ ',$', 'Comma suffix' Assert &rtp !~ ',$', 'Comma suffix'
**********************************************************************
Execute (#130 Proper cleanup of on-demand loading triggers):
augroup PlugLOD
autocmd!
augroup END
" Cleared on command
call plug#begin('$TMPDIR/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
call plug#end()
PlugInstall | q
Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'
Assert !empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) not defined'
silent! EmojiCommand
Assert !exists(':EmojiCommand'), 'EmojiCommand defined'
Assert !exists(':EmojiCommand2'), 'EmojiCommand2 defined'
Assert empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) defined'
" Cleared on FileType
call plug#begin('$TMPDIR/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
call plug#end()
Assert exists(':EmojiCommandExtra'), 'EmojiCommandExtra not defined'
Assert !empty(mapcheck('<Plug>(EmojiMappingExtra)')), '<Plug>(EmojiMappingExtra) not defined'
setf emoji
Assert !exists(':EmojiCommandExtra'), 'EmojiCommandExtra defined'
Assert empty(mapcheck('<Plug>(EmojiMappingExtra)')), '<Plug>(EmojiMappingExtra) defined'
**********************************************************************
Execute (#131 Syntax error):
call plug#begin('/no-permission')
Plug 'junegunn/vim-emoji'
call plug#end()
redir => out
silent PlugInstall
redir END
Assert out =~ 'Invalid plug directory: /no-permission'
Execute (Cleanup): Execute (Cleanup):
silent! call system('rm -rf '.temp_plugged) silent! call system('rm -rf '.temp_plugged)
silent! call system('rm -rf '.temp_plugged) silent! call system('rm -rf '.temp_plugged)