1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:20:05 +08:00

Update dein.vim

close https://github.com/SpaceVim/SpaceVim/issues/4070
This commit is contained in:
Shidong Wang 2021-02-10 10:50:27 +08:00
parent 4a6e7f7331
commit 720a0c0a0a
20 changed files with 738 additions and 345 deletions

View File

@ -1,6 +1,7 @@
## Forked repos
- [defx.nvim](https://github.com/Shougo/defx.nvim/commit/df5e6ea6734dc002919ea41786668069fa0b497d)
- [dein.vim](https://github.com/Shougo/dein.vim/commit/772ae08cef5e712b2b31b4aaee908fc853accd94)
### checkers layer

View File

@ -0,0 +1,31 @@
name: Lint & Test
on: [push, pull_request]
jobs:
test:
name: Neovim (${{ matrix.build }})
runs-on: ubuntu-latest
strategy:
matrix:
build:
- nightly
- stable
steps:
- uses: actions/checkout@v2
- name: Initialize Neovim
uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: true
version: ${{ matrix.build }}
- name: Clone vim-themis
uses: actions/checkout@v2
with:
repository: thinca/vim-themis
path: vim-themis
- name: Run Test
run: make --keep-going THEMIS_VIM=${{ steps.vim.outputs.executable }} test

View File

@ -2,13 +2,14 @@
[![Join the chat at https://gitter.im/Shougo/dein.vim](https://badges.gitter.im/Shougo/dein.vim.svg)](https://gitter.im/Shougo/dein.vim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/Shougo/dein.vim.svg?branch=master)](https://travis-ci.org/Shougo/dein.vim)
Please read [help](doc/dein.txt) for details.
Dein.vim is a dark powered Vim/Neovim plugin manager.
<!-- vim-markdown-toc GFM -->
- [Requirements](#requirements)
- [Quick start](#quick-start)
- [Unix/Linux or Mac OS X](#unixlinux-or-mac-os-x)
- [Features](#features)
- [Future works (TODO)](#future-works-todo)
- [Options](#options)
@ -124,15 +125,4 @@ syntax enable
### Options
Some common options. For a more detailed list, run `:h dein-options`
| Option | Type | Description |
| -------- | -------------------- | ------------------------------------------------------------------------------------- |
| `name` | `string` | The name for a plugin. If it is omitted, the tail of the repository name will be used |
| `rev` | `string` | The revision number or branch/tag name for the repo |
| `build` | `string` | Command to run after the plugin is installed |
| `on_ft` | `string` or `list` | Load a plugin for the current filetype |
| `on_cmd` | `string` or `list` | Load the plugin for these commands |
| `rtp` | `string` | You can use this option when the repository has the Vim plugin in a subdirectory |
| `if` | `string` or `number` | If it is String, dein will eval it. |
| `merged` | `number` | If set to 0, dein doesn't merge the plugin directory. |
Please read `:help dein-options`

View File

@ -5,18 +5,16 @@
"=============================================================================
function! dein#_init() abort
let g:dein#_cache_version = 150
let g:dein#_merged_format =
\ "{'repo': v:val.repo, 'rev': get(v:val, 'rev', '')}"
let g:dein#_merged_length = 3
let g:dein#name = ''
let g:dein#plugin = {}
let g:dein#_cache_version = 150
let g:dein#_plugins = {}
let g:dein#_base_path = ''
let g:dein#_cache_path = ''
let g:dein#_runtime_path = ''
let g:dein#_hook_add = ''
let g:dein#_ftplugin = {}
let g:dein#_called_lua = {}
let g:dein#_off1 = ''
let g:dein#_off2 = ''
let g:dein#_vimrcs = []
@ -27,10 +25,19 @@ function! dein#_init() abort
\ && $HOME ==# expand('~'.$SUDO_USER)
let g:dein#_progname = fnamemodify(v:progname, ':r')
let g:dein#_init_runtimepath = &runtimepath
let g:dein#_loaded_rplugins = v:false
if get(g:, 'dein#lazy_rplugins', v:false)
" Disable remote plugin loading
let g:loaded_remote_plugins = 1
endif
augroup dein
autocmd!
autocmd FuncUndefined * call dein#autoload#_on_func(expand('<afile>'))
autocmd FuncUndefined *
\ if stridx(expand('<afile>'), 'remote#') != 0 |
\ call dein#autoload#_on_func(expand('<afile>')) |
\ endif
autocmd BufRead *? call dein#autoload#_on_default_event('BufRead')
autocmd BufNew,BufNewFile *? call dein#autoload#_on_default_event('BufNew')
autocmd VimEnter *? call dein#autoload#_on_default_event('VimEnter')
@ -43,6 +50,16 @@ function! dein#_init() abort
if !exists('##CmdUndefined') | return | endif
autocmd dein CmdUndefined *
\ call dein#autoload#_on_pre_cmd(expand('<afile>'))
if has('nvim-0.5')
lua <<END
table.insert(package.loaders, 1, (function()
return function(mod_name)
vim.fn['dein#autoload#_on_lua'](mod_name)
return nil
end
end)())
END
endif
endfunction
function! dein#load_cache_raw(vimrcs) abort
let g:dein#_vimrcs = a:vimrcs
@ -101,7 +118,7 @@ function! dein#end() abort
return dein#util#_end()
endfunction
function! dein#add(repo, ...) abort
return dein#parse#_add(a:repo, get(a:000, 0, {}))
return dein#parse#_add(a:repo, get(a:000, 0, {}), v:false)
endfunction
function! dein#local(dir, ...) abort
return dein#parse#_local(a:dir, get(a:000, 0, {}), get(a:000, 1, ['*']))
@ -127,8 +144,9 @@ function! dein#update(...) abort
\ 'update', dein#install#_is_async())
endfunction
function! dein#check_update(...) abort
return dein#install#_update(get(a:000, 0, []),
\ 'check_update', dein#install#_is_async())
return dein#install#_check_update(
\ get(a:000, 1, []), get(a:000, 0, v:false),
\ dein#install#_is_async())
endfunction
function! dein#direct_install(repo, ...) abort
call dein#install#_direct_install(a:repo, (a:0 ? a:1 : {}))
@ -189,7 +207,7 @@ function! dein#disable(names) abort
return dein#util#_disable(a:names)
endfunction
function! dein#config(arg, ...) abort
return type(a:arg) != 3 ?
return type(a:arg) != v:t_list ?
\ dein#util#_config(a:arg, get(a:000, 0, {})) :
\ map(copy(a:arg), 'dein#util#_config(v:val, a:1)')
endfunction

View File

@ -4,9 +4,6 @@
" License: MIT license
"=============================================================================
let s:CMP = SpaceVim#api#import('vim#compatible')
function! dein#autoload#_source(...) abort
let plugins = empty(a:000) ? values(g:dein#_plugins) :
\ dein#util#_convert2list(a:1)
@ -14,7 +11,7 @@ function! dein#autoload#_source(...) abort
return
endif
if type(plugins[0]) != 4
if type(plugins[0]) != v:t_dict
let plugins = map(dein#util#_convert2list(a:1),
\ 'get(g:dein#_plugins, v:val, {})')
endif
@ -119,11 +116,11 @@ function! s:source_events(event, plugins) abort
return
endif
let prev_autocmd = s:CMP.execute('autocmd ' . a:event)
let prev_autocmd = execute('autocmd ' . a:event)
call dein#autoload#_source(a:plugins)
let new_autocmd = s:CMP.execute('autocmd ' . a:event)
let new_autocmd = execute('autocmd ' . a:event)
if a:event ==# 'InsertCharPre'
" Queue this key again
@ -155,6 +152,21 @@ function! dein#autoload#_on_func(name) abort
\ || (index(get(v:val, 'on_func', []), a:name) >= 0)"))
endfunction
function! dein#autoload#_on_lua(name) abort
if has_key(g:dein#_called_lua, a:name)
return
endif
" Only use the root of module name.
let mod_root = matchstr(a:name, '^[^./]\+')
" Prevent infinite loop
let g:dein#_called_lua[a:name] = v:true
call dein#autoload#_source(filter(dein#util#_get_lazy_plugins(),
\ "index(get(v:val, 'on_lua', []), mod_root) >= 0"))
endfunction
function! dein#autoload#_on_pre_cmd(name) abort
call dein#autoload#_source(
\ filter(dein#util#_get_lazy_plugins(),
@ -300,6 +312,16 @@ function! s:source_plugin(rtps, index, plugin, sourced) abort
call dein#util#_add_after(a:rtps, a:plugin.rtp.'/after')
endif
endif
if get(g:, 'dein#lazy_rplugins', v:false) && !g:dein#_loaded_rplugins
\ && isdirectory(a:plugin.rtp.'/rplugin')
" Enable remote plugin
unlet! g:loaded_remote_plugins
runtime! plugin/rplugin.vim
let g:dein#_loaded_rplugins = v:true
endif
endfunction
function! s:reset_ftplugin() abort
let filetype_state = dein#util#_redir('filetype')
@ -324,7 +346,7 @@ function! s:get_input() abort
while 1
let char = getchar()
let input .= (type(char) == 0) ? nr2char(char) : char
let input .= (type(char) == v:t_number) ? nr2char(char) : char
let idx = stridx(input, termstr)
if idx >= 1

View File

@ -21,6 +21,10 @@ let g:dein#install_process_timeout =
\ get(g:, 'dein#install_process_timeout', 120)
let g:dein#install_log_filename =
\ get(g:, 'dein#install_log_filename', '')
let g:dein#install_github_api_token =
\ get(g:, 'dein#install_github_api_token', '')
let g:dein#install_curl_command =
\ get(g:, 'dein#install_curl_command', 'curl')
function! s:get_job() abort
if !exists('s:Job')
@ -39,8 +43,6 @@ function! dein#install#_update(plugins, update_type, async) abort
if a:update_type ==# 'install'
let plugins = filter(plugins, '!isdirectory(v:val.path)')
elseif a:update_type ==# 'check_update'
let plugins = filter(plugins, 'isdirectory(v:val.path)')
endif
if a:async && !empty(s:global_context) &&
@ -55,11 +57,9 @@ function! dein#install#_update(plugins, update_type, async) abort
call s:init_variables(context)
if empty(plugins)
if a:update_type !=# 'check_update'
call s:notify('Target plugins are not found.')
call s:notify('You may have used the wrong plugin name,'.
\ ' or all of the plugins are already installed.')
endif
call s:notify('Target plugins are not found.')
call s:notify('You may have used the wrong plugin name,'.
\ ' or all of the plugins are already installed.')
let s:global_context = {}
return
endif
@ -79,8 +79,7 @@ function! dein#install#_update(plugins, update_type, async) abort
unlet s:timer
endif
let s:timer = timer_start(1000,
\ {-> dein#install#_polling()}, {'repeat': -1})
let s:timer = timer_start(50, {-> dein#install#_polling()}, {'repeat': -1})
endfunction
function! s:update_loop(context) abort
let errored = 0
@ -103,6 +102,142 @@ function! s:update_loop(context) abort
return errored
endfunction
function! dein#install#_check_update(plugins, force, async) abort
if g:dein#install_github_api_token ==# ''
call s:error('You need to set g:dein#install_github_api_token' .
\ ' for the feature.')
return
endif
if !executable(g:dein#install_curl_command)
call s:error('curl must be executable for the feature.')
return
endif
if !exists('*strptime') && !has('python3')
call s:error('+python3 is required for the feature.')
return
endif
let s:global_context.progress_type = 'echo'
let query_max = 100
let plugins = dein#util#_get_plugins(a:plugins)
let processes = []
for index in range(0, len(plugins) - 1, query_max)
redraw
call s:print_progress_message(
\s:get_progress_message('', index, len(plugins)))
let query = ''
for plug_index in range(index,
\ min([index + query_max, len(plugins)]) - 1)
let plugin_names = split(plugins[plug_index].repo, '/')
if len(plugin_names) < 2
" Invalid repository name.
continue
endif
" Note: "repository" API is faster than "search" API
let query .= printf('a%d:repository(owner:\"%s\", name: \"%s\")' .
\ '{ pushedAt nameWithOwner }',
\ plug_index, plugin_names[-2], plugin_names[-1])
endfor
let commands = [
\ g:dein#install_curl_command, '-H', 'Authorization: bearer ' .
\ g:dein#install_github_api_token,
\ '-X', 'POST', '-d',
\ '{ "query": "query {' . query . '}" }',
\ 'https://api.github.com/graphql'
\ ]
let process = {'candidates': []}
function! process.on_out(data) abort
let candidates = self.candidates
if empty(candidates)
call add(candidates, a:data[0])
else
let candidates[-1] .= a:data[0]
endif
let candidates += a:data[1:]
endfunction
let process.job = s:get_job().start(
\ s:convert_args(commands),
\ {'on_stdout': function(process.on_out, [], process)})
call add(processes, process)
endfor
" Get outputs
let results = []
for process in processes
call process.job.wait(g:dein#install_process_timeout * 1000)
if !empty(process.candidates)
try
let json = json_decode(process.candidates[0])
let results += filter(values(json['data']),
\ "type(v:val) == v:t_dict && has_key(v:val, 'pushedAt')")
catch
call s:error('json output decode error: ' + string(result))
endtry
endif
endfor
" Get pushed time.
let check_pushed = {}
for node in results
let format = '%Y-%m-%dT%H:%M:%SZ'
let pushed_at = node['pushedAt']
let check_pushed[node['nameWithOwner']] =
\ exists('*strptime') ?
\ strptime(format, pushed_at) :
\ has('nvim') ?
\ msgpack#strptime(format, pushed_at) :
\ s:strptime_py(format, pushed_at)
endfor
" Get the last updated time by rollbackfile timestamp.
" Note: .git timestamp may be changed by git commands.
let rollbacks = reverse(sort(dein#util#_globlist(
\ s:get_rollback_directory() . '/*')))
let rollback_time = empty(rollbacks) ? -1 : getftime(rollbacks[0])
" Compare with .git directory updated time.
let updated = []
for plugin in plugins
if !has_key(check_pushed, plugin.repo)
continue
endif
let git_path = plugin.path . '/.git'
let repo_time = isdirectory(plugin.path) ? getftime(git_path) : -1
if min([repo_time, rollback_time]) < check_pushed[plugin.repo]
call add(updated, plugin)
endif
endfor
redraw | echo ''
" Clear global context
let s:global_context = {}
if empty(updated)
call dein#util#_notify(strftime('Done: (%Y/%m/%d %H:%M:%S)'))
return
endif
call dein#util#_notify('Updated plugins: ' .
\ string(map(copy(updated), 'v:val.name')))
if !a:force && confirm(
\ 'Updated plugins are exists. Update now?', "yes\nNo", 2) != 1
return
endif
call dein#install#_update(updated, 'update', a:async)
endfunction
function! dein#install#_reinstall(plugins) abort
let plugins = dein#util#_get_plugins(a:plugins)
@ -315,9 +450,7 @@ function! s:get_rollback_directory() abort
return parent
endfunction
function! s:check_rollback(plugin) abort
return !has_key(a:plugin, 'local')
\ && !get(a:plugin, 'frozen', 0)
\ && get(a:plugin, 'rev', '') ==# ''
return !has_key(a:plugin, 'local') && !get(a:plugin, 'frozen', 0)
endfunction
function! dein#install#_get_default_ftplugin() abort
@ -492,12 +625,12 @@ function! dein#install#_get_progress() abort
return s:progress
endfunction
function! s:get_progress_message(plugin, number, max) abort
function! s:get_progress_message(name, number, max) abort
return printf('(%'.len(a:max).'d/%'.len(a:max).'d) [%s%s] %s',
\ a:number, a:max,
\ repeat('+', (a:number*20/a:max)),
\ repeat('-', 20 - (a:number*20/a:max)),
\ a:plugin.name)
\ a:name)
endfunction
function! s:get_plugin_message(plugin, number, max, message) abort
return printf('(%'.len(a:max).'d/%d) |%-20s| %s',
@ -509,10 +642,7 @@ endfunction
function! s:get_sync_command(plugin, update_type, number, max) abort "{{{i
let type = dein#util#_get_type(a:plugin.type)
if a:update_type ==# 'check_update'
\ && has_key(type, 'get_fetch_remote_command')
let cmd = type.get_fetch_remote_command(a:plugin)
elseif has_key(type, 'get_sync_command')
if has_key(type, 'get_sync_command')
let cmd = type.get_sync_command(a:plugin)
else
return ['', '']
@ -527,10 +657,17 @@ function! s:get_sync_command(plugin, update_type, number, max) abort "{{{i
return [cmd, message]
endfunction
function! s:get_revision_number(plugin) abort
if !isdirectory(a:plugin.path)
return ''
endif
let type = dein#util#_get_type(a:plugin.type)
if !isdirectory(a:plugin.path)
\ || !has_key(type, 'get_revision_number_command')
if has_key(type, 'get_revision_number')
return type.get_revision_number(a:plugin)
endif
if !has_key(type, 'get_revision_number_command')
return ''
endif
@ -553,23 +690,6 @@ function! s:get_revision_number(plugin) abort
endif
return rev
endfunction
function! s:get_revision_remote(plugin) abort
let type = dein#util#_get_type(a:plugin.type)
if !isdirectory(a:plugin.path)
\ || !has_key(type, 'get_revision_remote_command')
return ''
endif
let cmd = type.get_revision_remote_command(a:plugin)
if empty(cmd)
return ''
endif
let rev = s:system_cd(cmd, a:plugin.path)
" If rev contains spaces, it is error message
return (rev !~# '\s') ? rev : ''
endfunction
function! s:get_updated_log_message(plugin, new_rev, old_rev) abort
let type = dein#util#_get_type(a:plugin.type)
@ -585,8 +705,6 @@ function! s:lock_revision(process, context) abort
let max = a:context.max_plugins
let plugin = a:process.plugin
let plugin.new_rev = s:get_revision_number(plugin)
let type = dein#util#_get_type(plugin.type)
if !has_key(type, 'get_revision_lock_command')
return 0
@ -594,10 +712,10 @@ function! s:lock_revision(process, context) abort
let cmd = type.get_revision_lock_command(plugin)
if empty(cmd) || plugin.new_rev ==# get(plugin, 'rev', '')
if empty(cmd)
" Skipped.
return 0
elseif type(cmd) == 1 && cmd =~# '^E: '
elseif type(cmd) == v:t_string && cmd =~# '^E: '
" Errored.
call s:error(plugin.path)
call s:error(cmd[3:])
@ -628,8 +746,7 @@ function! s:get_updated_message(context, plugins) abort
\ : printf('(%d change%s)',
\ v:val.commit_count,
\ (v:val.commit_count == 1 ? '' : 's')))
\ . ((a:context.update_type !=# 'check_update'
\ && v:val.old_rev !=# ''
\ . ((v:val.old_rev !=# ''
\ && v:val.uri =~# '^\\h\\w*://github.com/') ? \"\\n\"
\ . printf(' %s/compare/%s...%s',
\ substitute(substitute(v:val.uri, '\\.git$', '', ''),
@ -671,7 +788,7 @@ function! dein#install#_system(command) abort
" let job = s:Job.start()
" let exitval = job.wait()
if !has('nvim') && type(a:command) == 3
if !has('nvim') && type(a:command) == v:t_list
" system() does not support List arguments in Vim.
let command = s:args2string(a:command)
else
@ -728,19 +845,17 @@ function! dein#install#_rm(path) abort
return
endif
" Todo: use :python3 instead.
" Note: delete rf is broken
" if has('patch-7.4.1120')
" try
" call delete(a:path, 'rf')
" catch
" call s:error('Error deleting directory: ' . a:path)
" call s:error(v:exception)
" call s:error(v:throwpoint)
" endtry
" return
" endif
" Note: delete rf is broken before Vim 8.1.1378
if has('patch-8.1.1378')
try
call delete(a:path, 'rf')
catch
call s:error('Error deleting directory: ' . a:path)
call s:error(v:exception)
call s:error(v:throwpoint)
endtry
return
endif
" Note: In Windows, ['rmdir', '/S', '/Q'] does not work.
" After Vim 8.0.928, double quote escape does not work in job. Too bad.
@ -793,10 +908,9 @@ function! dein#install#_copy_directories(srcs, dest) abort
call delete(temp)
endtry
" For some baffling reason robocopy almost always returns between 1 and 3
" upon success
" Robocopy returns between 0 and 7 upon success
let status = dein#install#_status()
let status = (status > 3) ? status : 0
let status = (status > 7) ? status : 0
if status
call dein#util#_error('copy command failed.')
@ -864,7 +978,7 @@ function! s:install_async(context) abort
\ && a:context.number < len(a:context.plugins)
let plugin = a:context.plugins[a:context.number]
call s:print_progress_message(
\ s:get_progress_message(plugin,
\ s:get_progress_message(plugin.name,
\ a:context.number, a:context.max_plugins))
let a:context.prev_number = a:context.number
endif
@ -880,7 +994,7 @@ function! s:check_loop(context) abort
if !a:context.async
call s:print_progress_message(
\ s:get_progress_message(plugin,
\ s:get_progress_message(plugin.name,
\ a:context.number, a:context.max_plugins))
endif
endwhile
@ -936,7 +1050,7 @@ function! s:init_variables(context) abort
endfunction
function! s:convert_args(args) abort
let args = s:iconv(a:args, &encoding, 'char')
if type(args) != 3
if type(args) != v:t_list
let args = split(&shell) + split(&shellcmdflag) + [args]
endif
return args
@ -952,15 +1066,16 @@ function! s:done(context) abort
call s:notify(s:get_errored_message(a:context.errored_plugins))
endif
if a:context.update_type !=# 'check_update'
call dein#install#_recache_runtimepath()
endif
call dein#install#_recache_runtimepath()
if !empty(a:context.synced_plugins)
call dein#call_hook('done_update', a:context.synced_plugins)
call dein#source(map(copy(a:context.synced_plugins), 'v:val.name'))
endif
redraw
echo ''
call s:notify(strftime('Done: (%Y/%m/%d %H:%M:%S)'))
" Disable installation handler
@ -997,7 +1112,7 @@ function! s:sync(plugin, context) abort
return
endif
if type(cmd) == 1 && cmd =~# '^E: '
if type(cmd) == v:t_string && cmd =~# '^E: '
" Errored.
call s:print_progress_message(s:get_plugin_message(
@ -1043,9 +1158,10 @@ function! s:init_process(plugin, context, cmd) abort
\ 'installed': isdirectory(a:plugin.path),
\ }
let rev_save = get(a:plugin, 'rev', '')
if isdirectory(a:plugin.path)
\ && !get(a:plugin, 'local', 0)
let rev_save = get(a:plugin, 'rev', '')
\ && rev_save !=# ''
try
" Force checkout HEAD revision.
" The repository may be checked out.
@ -1105,7 +1221,7 @@ function! s:init_job(process, context, cmd) abort
let candidates = get(a:process.job, 'candidates', [])
let output = join((self.eof ? candidates : candidates[: -2]), "\n")
if output !=# ''
let a:process.output .= output
let a:process.output = output
let a:process.start_time = localtime()
call s:log(s:get_short_message(
\ a:process.plugin, a:process.number,
@ -1157,15 +1273,13 @@ function! s:check_output(context, process) abort
let plugin = a:process.plugin
if isdirectory(plugin.path)
\ && get(plugin, 'rev', '') !=# ''
\ && !get(plugin, 'local', 0)
\ && get(plugin, 'rev', '') !=# ''
\ && !get(plugin, 'local', 0)
" Restore revision.
call s:lock_revision(a:process, a:context)
endif
let new_rev = (a:context.update_type ==# 'check_update') ?
\ s:get_revision_remote(plugin) :
\ s:get_revision_number(plugin)
let new_rev = s:get_revision_number(plugin)
if is_timeout || status
call s:log(s:get_plugin_message(plugin, num, max, 'Error'))
@ -1187,23 +1301,16 @@ function! s:check_output(context, process) abort
call add(a:context.errored_plugins,
\ plugin)
elseif a:process.rev ==# new_rev
\ || (a:context.update_type ==# 'check_update' && new_rev ==# '')
if a:context.update_type !=# 'check_update'
call s:log(s:get_plugin_message(
\ plugin, num, max, 'Same revision'))
endif
call s:log(s:get_plugin_message(
\ plugin, num, max, 'Same revision'))
else
call s:log(s:get_plugin_message(plugin, num, max, 'Updated'))
if a:context.update_type !=# 'check_update'
let log_messages = split(s:get_updated_log_message(
\ plugin, new_rev, a:process.rev), '\n')
let plugin.commit_count = len(log_messages)
call s:log(map(log_messages,
\ 's:get_short_message(plugin, num, max, v:val)'))
else
let plugin.commit_count = 0
endif
let log_messages = split(s:get_updated_log_message(
\ plugin, new_rev, a:process.rev), '\n')
let plugin.commit_count = len(log_messages)
call s:log(map(log_messages,
\ 's:get_short_message(plugin, num, max, v:val)'))
let plugin.old_rev = a:process.rev
let plugin.new_rev = new_rev
@ -1239,7 +1346,7 @@ function! s:iconv(expr, from, to) abort
return a:expr
endif
if type(a:expr) == 3
if type(a:expr) == v:t_list
return map(copy(a:expr), 'iconv(v:val, a:from, a:to)')
else
let result = iconv(a:expr, a:from, a:to)
@ -1413,7 +1520,7 @@ function! s:strwidthpart_reverse(str, width) abort
endfunction
function! s:args2string(args) abort
return type(a:args) == 1 ? a:args :
return type(a:args) == v:t_string ? a:args :
\ dein#util#_is_windows() ?
\ dein#install#_args2string_windows(a:args) :
\ dein#install#_args2string_unix(a:args)
@ -1433,3 +1540,13 @@ endfunction
function! dein#install#_args2string_unix(args) abort
return join(map(copy(a:args), 'string(v:val)'))
endfunction
function! s:strptime_py(format, str) abort
python3 << EOF
import datetime
import vim
vim.command('let ret = ' + str(datetime.datetime.strptime(
vim.eval('a:str'), vim.eval('a:format')).timestamp()))
EOF
return ret
endfunction

View File

@ -11,30 +11,38 @@ let g:dein#enable_name_conversion =
let s:git = dein#types#git#define()
function! dein#parse#_add(repo, options) abort
function! dein#parse#_add(repo, options, overwrite) abort
let plugin = dein#parse#_dict(dein#parse#_init(a:repo, a:options))
if (has_key(g:dein#_plugins, plugin.name)
\ && g:dein#_plugins[plugin.name].sourced)
\ || !get(plugin, 'if', 1)
let plugin_check = get(g:dein#_plugins, plugin.name, {})
if get(plugin_check, 'sourced', 0) || !get(plugin, 'if', 1)
" Skip already loaded or not enabled plugin.
return {}
endif
if plugin.lazy && plugin.rtp !=# ''
call s:parse_lazy(plugin)
" Duplicated plugins check
if !a:overwrite && !empty(plugin_check)
" Only warning when starting
if has('vim_starting')
call dein#util#_error(printf(
\ 'Plugin name "%s" is already defined.', plugin.name))
return {}
endif
endif
if has_key(g:dein#_plugins, plugin.name)
\ && g:dein#_plugins[plugin.name].sourced
let plugin.sourced = 1
if plugin.rtp !=# ''
if plugin.lazy
call s:parse_lazy(plugin)
endif
if has_key(plugin, 'hook_add')
call dein#util#_execute_hook(plugin, plugin.hook_add)
endif
if has_key(plugin, 'ftplugin')
call s:merge_ftplugin(plugin.ftplugin)
endif
endif
let g:dein#_plugins[plugin.name] = plugin
if has_key(plugin, 'hook_add')
call dein#util#_execute_hook(plugin, plugin.hook_add)
endif
if has_key(plugin, 'ftplugin')
call s:merge_ftplugin(plugin.ftplugin)
endif
return plugin
endfunction
function! dein#parse#_init(repo, options) abort
@ -104,7 +112,7 @@ function! dein#parse#_dict(plugin) abort
let plugin.path .= '/' . plugin.script_type
endif
if has_key(plugin, 'depends') && type(plugin.depends) != 3
if has_key(plugin, 'depends') && type(plugin.depends) != v:t_list
let plugin.depends = [plugin.depends]
endif
@ -121,6 +129,7 @@ function! dein#parse#_dict(plugin) abort
\ || has_key(plugin, 'on_ft')
\ || has_key(plugin, 'on_cmd')
\ || has_key(plugin, 'on_func')
\ || has_key(plugin, 'on_lua')
\ || has_key(plugin, 'on_map')
\ || has_key(plugin, 'on_path')
\ || has_key(plugin, 'on_if')
@ -134,10 +143,11 @@ function! dein#parse#_dict(plugin) abort
\ && !has_key(plugin, 'local')
\ && !has_key(plugin, 'build')
\ && !has_key(plugin, 'if')
\ && !has_key(plugin, 'hook_post_update')
\ && stridx(plugin.rtp, dein#util#_get_base_path()) == 0
endif
if has_key(plugin, 'if') && type(plugin.if) == 1
if has_key(plugin, 'if') && type(plugin.if) == v:t_string
let plugin.if = eval(a:plugin.if)
endif
@ -145,7 +155,7 @@ function! dein#parse#_dict(plugin) abort
for hook in filter([
\ 'hook_add', 'hook_source',
\ 'hook_post_source', 'hook_post_update',
\ ], 'has_key(plugin, v:val) && type(plugin[v:val]) == 1')
\ ], 'has_key(plugin, v:val) && type(plugin[v:val]) == v:t_string')
let plugin[hook] = substitute(plugin[hook],
\ '\n\s*\\\|\%(^\|\n\)\s*"[^\n]*', '', 'g')
endfor
@ -160,7 +170,7 @@ function! dein#parse#_load_toml(filename, default) abort
call dein#util#_error(v:exception)
return 1
endtry
if type(toml) != 4
if type(toml) != v:t_dict
call dein#util#_error('Invalid toml file: ' . a:filename)
return 1
endif
@ -203,6 +213,7 @@ function! dein#parse#_plugins2toml(plugins) abort
let default.on_ft = []
let default.on_cmd = []
let default.on_func = []
let default.on_lua = []
let default.on_map = []
let default.on_path = []
let default.on_source = []
@ -236,7 +247,7 @@ function! dein#parse#_plugins2toml(plugins) abort
call add(toml, "'''")
else
call add(toml, key . ' = ' . string(
\ (type(val) == 3 && len(val) == 1) ? val[0] : val))
\ (type(val) == v:t_list && len(val) == 1) ? val[0] : val))
endif
unlet! val
endfor
@ -270,7 +281,7 @@ function! dein#parse#_local(localdir, options, includes) abort
if has_key(g:dein#_plugins, options.name)
call dein#config(options.name, options)
else
call dein#add(dir, options)
call dein#parse#_add(dir, options, v:true)
endif
endfor
endfunction
@ -278,10 +289,10 @@ function! s:parse_lazy(plugin) abort
" Auto convert2list.
for key in filter([
\ 'on_ft', 'on_path', 'on_cmd', 'on_func', 'on_map',
\ 'on_source', 'on_event',
\ 'on_lua', 'on_source', 'on_event',
\ ], 'has_key(a:plugin, v:val)
\ && type(a:plugin[v:val]) != 3
\ && type(a:plugin[v:val]) != 4
\ && type(a:plugin[v:val]) != v:t_list
\ && type(a:plugin[v:val]) != v:t_dict
\')
let a:plugin[key] = [a:plugin[key]]
endfor
@ -328,11 +339,11 @@ function! s:generate_dummy_commands(plugin) abort
endfunction
function! s:generate_dummy_mappings(plugin) abort
let a:plugin.dummy_mappings = []
let items = type(a:plugin.on_map) == 4 ?
let items = type(a:plugin.on_map) == v:t_dict ?
\ map(items(a:plugin.on_map),
\ "[split(v:val[0], '\\zs'), dein#util#_convert2list(v:val[1])]") :
\ map(copy(a:plugin.on_map),
\ "type(v:val) == 3 ?
\ "type(v:val) == v:t_list ?
\ [split(v:val[0], '\\zs'), v:val[1:]] :
\ [['n', 'x'], [v:val]]")
for [modes, mappings] in items

View File

@ -212,7 +212,7 @@ endfunction
"
function! s:_boolean(input) abort
let s = s:_consume(a:input, '\%(true\|false\)')
return (s ==# 'true') ? 1 : 0
return (s ==# 'true') ? v:true : v:false
endfunction
"
@ -325,9 +325,9 @@ function! s:_put_dict(dict, key, value) abort
let ref = a:dict
for key in keys[ : -2]
if has_key(ref, key) && type(ref[key]) == 4
if has_key(ref, key) && type(ref[key]) == v:t_dict
let ref = ref[key]
elseif has_key(ref, key) && type(ref[key]) == 3
elseif has_key(ref, key) && type(ref[key]) == v:t_list
let ref = ref[key][-1]
else
let ref[key] = {}
@ -345,7 +345,7 @@ function! s:_put_array(dict, key, value) abort
for key in keys[ : -2]
let ref[key] = get(ref, key, {})
if type(ref[key]) == 3
if type(ref[key]) == v:t_list
let ref = ref[key][-1]
else
let ref = ref[key]

View File

@ -107,6 +107,8 @@ function! s:type.get_sync_command(plugin) abort
let commands = []
call add(commands, self.command)
call add(commands, '-c')
call add(commands, 'credential.helper=')
call add(commands, 'clone')
call add(commands, '--recursive')
@ -124,25 +126,29 @@ function! s:type.get_sync_command(plugin) abort
else
let git = self.command
let cmd = g:dein#types#git#pull_command
let fetch_cmd = git . ' -c credential.helper= fetch '
let remote_origin_cmd = git . ' remote set-head origin -a'
let pull_cmd = git . ' ' . g:dein#types#git#pull_command
let submodule_cmd = git . ' submodule update --init --recursive'
if dein#util#_is_powershell()
let cmd = fetch_cmd
let cmd .= '; if ($?) { ' . remote_origin_cmd . ' }'
let cmd .= '; if ($?) { ' . pull_cmd . ' }'
let cmd .= '; if ($?) { ' . submodule_cmd . ' }'
else
let and = dein#util#_is_fish() ? '; and ' : ' && '
let cmd .= and . submodule_cmd
let cmd = join([
\ fetch_cmd, remote_origin_cmd, pull_cmd, submodule_cmd
\ ], and)
endif
return git . ' ' . cmd
return cmd
endif
endfunction
function! s:type.get_revision_number_command(plugin) abort
if !self.executable
return []
endif
return [self.command, 'rev-parse', 'HEAD']
function! s:type.get_revision_number(plugin) abort
return s:git_get_revision(a:plugin.path)
endfunction
function! s:type.get_log_command(plugin, new_rev, old_rev) abort
if !self.executable || a:new_rev ==# '' || a:old_rev ==# ''
@ -193,25 +199,6 @@ function! s:type.get_rollback_command(plugin, rev) abort
return [self.command, 'reset', '--hard', a:rev]
endfunction
function! s:type.get_revision_remote_command(plugin) abort
if !self.executable
return []
endif
let rev = get(a:plugin, 'rev', '')
if rev ==# ''
let rev = 'HEAD'
endif
return [self.command, 'ls-remote', 'origin', rev]
endfunction
function! s:type.get_fetch_remote_command(plugin) abort
if !self.executable
return []
endif
return [self.command, 'fetch', 'origin']
endfunction
function! s:is_git_dir(path) abort
if isdirectory(a:path)
@ -298,3 +285,105 @@ else
return a:path =~# '^/'
endfunction
endif
" From minpac plugin manager
" https://github.com/k-takata/minpac
" https://github.com/junegunn/vim-plug/pull/937
function! s:isabsolute(dir) abort
return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)')
endfunction
function! s:get_gitdir(dir) abort
let gitdir = a:dir . '/.git'
if isdirectory(gitdir)
return gitdir
endif
try
let line = readfile(gitdir)[0]
if line =~# '^gitdir: '
let gitdir = line[8:]
if !s:isabsolute(gitdir)
let gitdir = a:dir . '/' . gitdir
endif
if isdirectory(gitdir)
return gitdir
endif
endif
catch
endtry
return ''
endfunction
function! s:git_get_remote_origin_url(dir) abort
let gitdir = s:get_gitdir(a:dir)
if gitdir ==# ''
return ''
endif
try
let lines = readfile(gitdir . '/config')
let [n, ll, url] = [0, len(lines), '']
while n < ll
let line = trim(lines[n])
if stridx(line, '[remote "origin"]') != 0
let n += 1
continue
endif
let n += 1
while n < ll
let line = trim(lines[n])
if line ==# '['
break
endif
let url = matchstr(line, '^url\s*=\s*\zs[^ #]\+')
if !empty(url)
break
endif
let n += 1
endwhile
let n += 1
endwhile
return url
catch
return ''
endtry
endfunction
function! s:git_get_revision(dir) abort
let gitdir = s:get_gitdir(a:dir)
if gitdir ==# ''
return ''
endif
try
let line = readfile(gitdir . '/HEAD')[0]
if line =~# '^ref: '
let ref = line[5:]
if filereadable(gitdir . '/' . ref)
return readfile(gitdir . '/' . ref)[0]
endif
for line in readfile(gitdir . '/packed-refs')
if line =~# ' ' . ref
return substitute(line, '^\([0-9a-f]*\) ', '\1', '')
endif
endfor
endif
return line
catch
endtry
return ''
endfunction
function! s:git_get_branch(dir) abort
let gitdir = s:get_gitdir(a:dir)
if gitdir ==# ''
return ''
endif
try
let line = readfile(gitdir . '/HEAD')[0]
if line =~# '^ref: refs/heads/'
return line[16:]
endif
return 'HEAD'
catch
return ''
endtry
endfunction

View File

@ -5,6 +5,7 @@
"=============================================================================
let s:is_windows = has('win32') || has('win64')
let s:merged_length = 3
function! dein#util#_init() abort
endfunction
@ -149,8 +150,8 @@ function! dein#util#_is_powershell() abort
return dein#install#_is_async() && fnamemodify(&shell, ':t:r') =~? 'powershell\|pwsh'
endfunction
function! dein#util#_has_job() abort
return has('nvim')
\ || (has('patch-7.4.1689') && has('job'))
return (has('nvim') && exists('v:t_list'))
\ || (has('patch-8.0.0027') && has('job'))
endfunction
function! dein#util#_check_lazy_plugins() abort
@ -211,7 +212,7 @@ function! dein#util#_save_cache(vimrcs, is_state, is_starting) abort
\ 'hook_add', 'hook_source',
\ 'hook_post_source', 'hook_post_update',
\ ], 'has_key(plugin, v:val)
\ && type(plugin[v:val]) == 2')
\ && type(plugin[v:val]) == v:t_func')
call remove(plugin, hook)
endfor
endfor
@ -235,15 +236,6 @@ function! dein#util#_check_vimrcs() abort
call dein#clear_state()
if get(g:, 'dein#auto_recache', 0)
silent execute 'source' dein#util#_get_myvimrc()
if dein#util#_get_merged_plugins() !=# dein#util#_load_merged_plugins()
call dein#util#_notify('auto recached')
call dein#recache_runtimepath()
endif
endif
return ret
endfunction
function! dein#util#_load_merged_plugins() abort
@ -252,15 +244,15 @@ function! dein#util#_load_merged_plugins() abort
return []
endif
let merged = readfile(path)
if len(merged) != g:dein#_merged_length
if len(merged) != s:merged_length
return []
endif
sandbox return merged[: g:dein#_merged_length - 2] + eval(merged[-1])
sandbox return merged[: s:merged_length - 2] + eval(merged[-1])
endfunction
function! dein#util#_save_merged_plugins() abort
let merged = dein#util#_get_merged_plugins()
call writefile(merged[: g:dein#_merged_length - 2] +
\ [string(merged[g:dein#_merged_length - 1 :])],
call writefile(merged[: s:merged_length - 2] +
\ [string(merged[s:merged_length - 1 :])],
\ dein#util#_get_cache_path() . '/merged')
endfunction
function! dein#util#_get_merged_plugins() abort
@ -268,8 +260,10 @@ function! dein#util#_get_merged_plugins() abort
for ftplugin in values(g:dein#_ftplugin)
let ftplugin_len += len(ftplugin)
endfor
return [g:dein#_merged_format, string(ftplugin_len)] +
\ sort(map(values(g:dein#_plugins), g:dein#_merged_format))
let merged_format =
\ "{'repo': v:val.repo, 'rev': get(v:val, 'rev', '')}"
return [merged_format, string(ftplugin_len)] +
\ sort(map(values(g:dein#_plugins), merged_format))
endfunction
function! dein#util#_save_state(is_starting) abort
@ -283,6 +277,11 @@ function! dein#util#_save_state(is_starting) abort
return 1
endif
if get(g:, 'dein#auto_recache', 0)
call dein#util#_notify('auto recached')
call dein#recache_runtimepath()
endif
let g:dein#_vimrcs = dein#util#_uniq(g:dein#_vimrcs)
let &runtimepath = dein#util#_join_rtp(dein#util#_uniq(
\ dein#util#_split_rtp(&runtimepath)), &runtimepath, '')
@ -328,9 +327,17 @@ function! dein#util#_save_state(is_starting) abort
let lines += s:skipempty(g:dein#_hook_add)
endif
for plugin in dein#util#_tsort(values(dein#get()))
if has_key(plugin, 'hook_add') && type(plugin.hook_add) == 1
if has_key(plugin, 'hook_add') && type(plugin.hook_add) == v:t_string
let lines += s:skipempty(plugin.hook_add)
endif
" Invalid hooks detection
for key in keys(filter(copy(plugin),
\ "stridx(v:key, 'hook_') == 0 && type(v:val) != v:t_string"))
call dein#util#_error(
\ printf('%s: "%s" must be string to save state',
\ plugin.name, key))
endfor
endfor
" Add events
@ -342,6 +349,11 @@ function! dein#util#_save_state(is_starting) abort
\ event, string(plugins)))
endfor
" Add inline vimrcs
for vimrc in get(g:, 'dein#inline_vimrcs', [])
let lines += filter(readfile(vimrc), "v:val !=# '' && v:val !~# '^\\s*\"'")
endfor
call writefile(lines, get(g:, 'dein#cache_directory', g:dein#_base_path)
\ .'/state_' . g:dein#_progname . '.vim')
endfunction
@ -358,14 +370,6 @@ function! dein#util#_begin(path, vimrcs) abort
call dein#_init()
endif
" Reset variables
if has('vim_starting')
let g:dein#_plugins = {}
let g:dein#_event_plugins = {}
endif
let g:dein#_ftplugin = {}
let g:dein#_hook_add = ''
if !dein#util#_has_job()
call dein#util#_error('Does not work in the Vim (' . v:version . ').')
return 1
@ -477,6 +481,10 @@ function! dein#util#_end() abort
\ event, string(plugins))
endfor
for vimrc in get(g:, 'dein#inline_vimrcs', [])
execute 'source' fnameescape(vimrc)
endfor
if !has('vim_starting')
call dein#call_hook('add')
call dein#call_hook('source')
@ -484,9 +492,9 @@ function! dein#util#_end() abort
endif
endfunction
function! dein#util#_config(arg, dict) abort
let name = type(a:arg) == 4 ?
let name = type(a:arg) == v:t_dict ?
\ g:dein#name : a:arg
let dict = type(a:arg) == 4 ?
let dict = type(a:arg) == v:t_dict ?
\ a:arg : a:dict
if !has_key(g:dein#_plugins, name)
\ || g:dein#_plugins[name].sourced
@ -498,7 +506,7 @@ function! dein#util#_config(arg, dict) abort
if has_key(plugin, 'orig_opts')
call extend(options, copy(plugin.orig_opts), 'keep')
endif
return dein#parse#_add(options.repo, options)
return dein#parse#_add(options.repo, options, v:true)
endfunction
function! dein#util#_call_hook(hook_name, ...) abort
@ -517,7 +525,7 @@ function! dein#util#_execute_hook(plugin, hook) abort
try
let g:dein#plugin = a:plugin
if type(a:hook) == 1
if type(a:hook) == v:t_string
call s:execute(a:hook)
else
call call(a:hook, [])
@ -539,7 +547,7 @@ function! dein#util#_set_hook(plugins, hook_name, hook) abort
endif
let plugin = g:dein#_plugins[name]
let plugin[a:hook_name] =
\ type(a:hook) != 1 ? a:hook :
\ type(a:hook) != v:t_string ? a:hook :
\ substitute(a:hook, '\n\s*\\\|\%(^\|\n\)\s*"[^\n]*', '', 'g')
if a:hook_name ==# 'hook_add'
call dein#util#_execute_hook(plugin, plugin[a:hook_name])
@ -597,13 +605,13 @@ function! dein#util#_globlist(path) abort
endfunction
function! dein#util#_convert2list(expr) abort
return type(a:expr) ==# 3 ? copy(a:expr) :
\ type(a:expr) ==# 1 ?
return type(a:expr) ==# v:t_list ? copy(a:expr) :
\ type(a:expr) ==# v:t_string ?
\ (a:expr ==# '' ? [] : split(a:expr, '\r\?\n', 1))
\ : [a:expr]
endfunction
function! dein#util#_split(expr) abort
return type(a:expr) ==# 3 ? copy(a:expr) :
return type(a:expr) ==# v:t_list ? copy(a:expr) :
\ split(a:expr, '\r\?\n')
endfunction
@ -630,7 +638,7 @@ function! dein#util#_get_plugins(plugins) abort
return empty(a:plugins) ?
\ values(dein#get()) :
\ filter(map(dein#util#_convert2list(a:plugins),
\ 'type(v:val) == 4 ? v:val : dein#get(v:val)'),
\ 'type(v:val) == v:t_dict ? v:val : dein#get(v:val)'),
\ '!empty(v:val)')
endfunction
@ -713,7 +721,7 @@ function! dein#util#_check_install(plugins) abort
endfunction
function! s:msg2list(expr) abort
return type(a:expr) ==# 3 ? a:expr : split(a:expr, '\n')
return type(a:expr) ==# v:t_list ? a:expr : split(a:expr, '\n')
endfunction
function! s:skipempty(string) abort
return filter(split(a:string, '\n'), "v:val !=# ''")
@ -725,7 +733,7 @@ function! s:escape(path) abort
endfunction
function! s:sort(list, expr) abort
if type(a:expr) == 2
if type(a:expr) == v:t_func
return sort(a:list, a:expr)
endif
let s:expr = a:expr

View File

@ -1,10 +1,10 @@
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not mofidify the code nor insert new lines before '" ___vital___'
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_dein#System#Job#import() abort', printf("return map({'_vital_depends': '', '_vital_healthcheck': '', 'is_available': '', 'start': '', '_vital_loaded': ''}, \"vital#_dein#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_dein#System#Job#import() abort', printf("return map({'_vital_depends': '', 'is_available': '', 'start': '', '_vital_loaded': ''}, \"vital#_dein#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:t_string = type('')
@ -25,14 +25,6 @@ function! s:_vital_depends() abort
\]
endfunction
function! s:_vital_healthcheck() abort
if has('patch-8.0.0027') || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0027 or Neovim 0.2.0'
endfunction
" Note:
" Vim does not raise E902 on Unix system even the prog is not found so use a
" custom exception instead to make the method compatible.

View File

@ -1,6 +1,6 @@
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not mofidify the code nor insert new lines before '" ___vital___'
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
@ -18,30 +18,54 @@ function! s:start(args, options) abort
if has_key(a:options, 'cwd')
let job_options.cwd = a:options.cwd
endif
if has_key(a:options, 'env')
let job_options.env = a:options.env
endif
if has_key(job, 'on_stdout')
let job_options.on_stdout = function('s:_on_stdout', [job])
let job_options.on_stdout = funcref('s:_on_stdout', [job])
endif
if has_key(job, 'on_stderr')
let job_options.on_stderr = function('s:_on_stderr', [job])
let job_options.on_stderr = funcref('s:_on_stderr', [job])
endif
if has_key(job, 'on_exit')
let job_options.on_exit = function('s:_on_exit', [job])
let job_options.on_exit = funcref('s:_on_exit', [job])
else
let job_options.on_exit = function('s:_on_exit_raw', [job])
let job_options.on_exit = funcref('s:_on_exit_raw', [job])
endif
let job.__job = jobstart(a:args, job_options)
let job.__pid = s:_jobpid_safe(job.__job)
let job.__exitval = v:null
let job.args = a:args
return job
endfunction
function! s:_on_stdout(job, job_id, data, event) abort
call a:job.on_stdout(a:data)
endfunction
if has('nvim-0.3.0')
" Neovim 0.3.0 and over seems to invoke on_stdout/on_stderr with an empty
" string data when the stdout/stderr channel has closed.
" It is different behavior from Vim and Neovim prior to 0.3.0 so remove an
" empty string list to keep compatibility.
function! s:_on_stdout(job, job_id, data, event) abort
if a:data == ['']
return
endif
call a:job.on_stdout(a:data)
endfunction
function! s:_on_stderr(job, job_id, data, event) abort
call a:job.on_stderr(a:data)
endfunction
function! s:_on_stderr(job, job_id, data, event) abort
if a:data == ['']
return
endif
call a:job.on_stderr(a:data)
endfunction
else
function! s:_on_stdout(job, job_id, data, event) abort
call a:job.on_stdout(a:data)
endfunction
function! s:_on_stderr(job, job_id, data, event) abort
call a:job.on_stderr(a:data)
endfunction
endif
function! s:_on_exit(job, job_id, exitval, event) abort
let a:job.__exitval = a:exitval
@ -52,6 +76,17 @@ function! s:_on_exit_raw(job, job_id, exitval, event) abort
let a:job.__exitval = a:exitval
endfunction
function! s:_jobpid_safe(job) abort
try
return jobpid(a:job)
catch /^Vim\%((\a\+)\)\=:E900/
" NOTE:
" Vim does not raise exception even the job has already closed so fail
" silently for 'E900: Invalid job id' exception
return 0
endtry
endfunction
" Instance -------------------------------------------------------------------
function! s:_job_id() abort dict
if &verbose
@ -63,7 +98,7 @@ function! s:_job_id() abort dict
endfunction
function! s:_job_pid() abort dict
return jobpid(self.__job)
return self.__pid
endfunction
function! s:_job_status() abort dict
@ -123,11 +158,11 @@ endfunction
" To make debug easier, use funcref instead.
let s:job = {
\ 'id': function('s:_job_id'),
\ 'pid': function('s:_job_pid'),
\ 'status': function('s:_job_status'),
\ 'send': function('s:_job_send'),
\ 'close': function('s:_job_close'),
\ 'stop': function('s:_job_stop'),
\ 'wait': function('s:_job_wait'),
\ 'id': funcref('s:_job_id'),
\ 'pid': funcref('s:_job_pid'),
\ 'status': funcref('s:_job_status'),
\ 'send': funcref('s:_job_send'),
\ 'close': funcref('s:_job_close'),
\ 'stop': funcref('s:_job_stop'),
\ 'wait': funcref('s:_job_wait'),
\}

View File

@ -1,6 +1,6 @@
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not mofidify the code nor insert new lines before '" ___vital___'
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
@ -20,22 +20,28 @@ function! s:start(args, options) abort
\ 'mode': 'raw',
\ 'timeout': 0,
\}
if has('patch-8.1.889')
let job_options['noblock'] = 1
endif
if has_key(job, 'on_stdout')
let job_options.out_cb = function('s:_out_cb', [job])
let job_options.out_cb = funcref('s:_out_cb', [job])
else
let job_options.out_io = 'null'
endif
if has_key(job, 'on_stderr')
let job_options.err_cb = function('s:_err_cb', [job])
let job_options.err_cb = funcref('s:_err_cb', [job])
else
let job_options.err_io = 'null'
endif
if has_key(job, 'on_exit')
let job_options.exit_cb = function('s:_exit_cb', [job])
let job_options.exit_cb = funcref('s:_exit_cb', [job])
endif
if has_key(job, 'cwd') && has('patch-8.0.0902')
let job_options.cwd = job.cwd
endif
if has_key(job, 'env') && has('patch-8.0.0902')
let job_options.env = job.env
endif
let job.__job = job_start(a:args, job_options)
let job.args = a:args
return job
@ -100,7 +106,7 @@ endfunction
" Neovim can send \0 by using \n splitted list but in Vim.
" So replace all \n in \n splitted list to ''
function! s:_job_send(data) abort dict
let data = type(a:data) == 3
let data = type(a:data) == v:t_list
\ ? join(map(a:data, 'substitute(v:val, "\n", '''', ''g'')'), "\n")
\ : a:data
return ch_sendraw(self.__job, data)
@ -137,11 +143,11 @@ endfunction
" To make debug easier, use funcref instead.
let s:job = {
\ 'id': function('s:_job_id'),
\ 'pid': function('s:_job_pid'),
\ 'status': function('s:_job_status'),
\ 'send': function('s:_job_send'),
\ 'close': function('s:_job_close'),
\ 'stop': function('s:_job_stop'),
\ 'wait': function('s:_job_wait'),
\ 'id': funcref('s:_job_id'),
\ 'pid': funcref('s:_job_pid'),
\ 'status': funcref('s:_job_status'),
\ 'send': funcref('s:_job_send'),
\ 'close': funcref('s:_job_close'),
\ 'stop': funcref('s:_job_stop'),
\ 'wait': funcref('s:_job_wait'),
\}

View File

@ -6,21 +6,6 @@ let s:is_vital_vim = s:plugin_name is# 'vital'
let s:loaded = {}
let s:cache_sid = {}
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort
return function(a:fstr)
endfunction
else
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
function! vital#{s:plugin_name}#new() abort
return s:new(s:plugin_name)
endfunction
@ -48,7 +33,7 @@ function! s:vital_files() abort
endif
return copy(s:vital_files)
endfunction
let s:Vital.vital_files = s:_function('s:vital_files')
let s:Vital.vital_files = function('s:vital_files')
function! s:import(name, ...) abort dict
let target = {}
@ -73,7 +58,7 @@ function! s:import(name, ...) abort dict
endif
return target
endfunction
let s:Vital.import = s:_function('s:import')
let s:Vital.import = function('s:import')
function! s:load(...) abort dict
for arg in a:000
@ -100,14 +85,14 @@ function! s:load(...) abort dict
endfor
return self
endfunction
let s:Vital.load = s:_function('s:load')
let s:Vital.load = function('s:load')
function! s:unload() abort dict
let s:loaded = {}
let s:cache_sid = {}
unlet! s:vital_files
endfunction
let s:Vital.unload = s:_function('s:unload')
let s:Vital.unload = function('s:unload')
function! s:exists(name) abort dict
if a:name !~# '\v^\u\w*%(\.\u\w*)*$'
@ -115,19 +100,19 @@ function! s:exists(name) abort dict
endif
return s:_module_path(a:name) isnot# ''
endfunction
let s:Vital.exists = s:_function('s:exists')
let s:Vital.exists = function('s:exists')
function! s:search(pattern) abort dict
let paths = s:_extract_files(a:pattern, self.vital_files())
let modules = sort(map(paths, 's:_file2module(v:val)'))
return s:_uniq(modules)
return uniq(modules)
endfunction
let s:Vital.search = s:_function('s:search')
let s:Vital.search = function('s:search')
function! s:plugin_name() abort dict
return self._plugin_name
endfunction
let s:Vital.plugin_name = s:_function('s:plugin_name')
let s:Vital.plugin_name = function('s:plugin_name')
function! s:_self_vital_files() abort
let builtin = printf('%s/__%s__/', s:vital_base_dir, s:plugin_name)
@ -164,7 +149,7 @@ function! s:_import(name) abort dict
call module._vital_created(module)
endif
let export_module = filter(copy(module), 'v:key =~# "^\\a"')
" Cache module before calling module.vital_loaded() to avoid cyclic
" Cache module before calling module._vital_loaded() to avoid cyclic
" dependences but remove the cache if module._vital_loaded() fails.
" let s:loaded[a:name] = export_module
let s:loaded[a:name] = export_module
@ -173,19 +158,68 @@ function! s:_import(name) abort dict
call module._vital_loaded(vital#{s:plugin_name}#new())
catch
unlet s:loaded[a:name]
throw 'vital: fail to call ._vital_loaded(): ' . v:exception
throw 'vital: fail to call ._vital_loaded(): ' . v:exception . " from:\n" . s:_format_throwpoint(v:throwpoint)
endtry
endif
return copy(s:loaded[a:name])
endfunction
let s:Vital._import = s:_function('s:_import')
let s:Vital._import = function('s:_import')
function! s:_format_throwpoint(throwpoint) abort
let funcs = []
let stack = matchstr(a:throwpoint, '^function \zs.*, .\{-} \d\+$')
for line in split(stack, '\.\.')
let m = matchlist(line, '^\(.\+\)\%(\[\(\d\+\)\]\|, .\{-} \(\d\+\)\)$')
if !empty(m)
let [name, lnum, lnum2] = m[1:3]
if empty(lnum)
let lnum = lnum2
endif
let info = s:_get_func_info(name)
if !empty(info)
let attrs = empty(info.attrs) ? '' : join([''] + info.attrs)
let flnum = info.lnum == 0 ? '' : printf(' Line:%d', info.lnum + lnum)
call add(funcs, printf('function %s(...)%s Line:%d (%s%s)',
\ info.funcname, attrs, lnum, info.filename, flnum))
continue
endif
endif
" fallback when function information cannot be detected
call add(funcs, line)
endfor
return join(funcs, "\n")
endfunction
function! s:_get_func_info(name) abort
let name = a:name
if a:name =~# '^\d\+$' " is anonymous-function
let name = printf('{%s}', a:name)
elseif a:name =~# '^<lambda>\d\+$' " is lambda-function
let name = printf("{'%s'}", a:name)
endif
if !exists('*' . name)
return {}
endif
let body = execute(printf('verbose function %s', name))
let lines = split(body, "\n")
let signature = matchstr(lines[0], '^\s*\zs.*')
let [_, file, lnum; __] = matchlist(lines[1],
\ '^\t\%(Last set from\|.\{-}:\)\s*\zs\(.\{-}\)\%( \S\+ \(\d\+\)\)\?$')
return {
\ 'filename': substitute(file, '[/\\]\+', '/', 'g'),
\ 'lnum': 0 + lnum,
\ 'funcname': a:name,
\ 'arguments': split(matchstr(signature, '(\zs.*\ze)'), '\s*,\s*'),
\ 'attrs': filter(['dict', 'abort', 'range', 'closure'], 'signature =~# (").*" . v:val)'),
\ }
endfunction
" s:_get_module() returns module object wihch has all script local functions.
function! s:_get_module(name) abort dict
let funcname = s:_import_func_name(self.plugin_name(), a:name)
try
return call(funcname, [])
catch /^Vim\%((\a\+)\)\?:E117/
catch /^Vim\%((\a\+)\)\?:E117:/
return s:_get_builtin_module(a:name)
endtry
endfunction
@ -196,9 +230,9 @@ endfunction
if s:is_vital_vim
" For vital.vim, we can use s:_get_builtin_module directly
let s:Vital._get_module = s:_function('s:_get_builtin_module')
let s:Vital._get_module = function('s:_get_builtin_module')
else
let s:Vital._get_module = s:_function('s:_get_module')
let s:Vital._get_module = function('s:_get_module')
endif
function! s:_import_func_name(plugin_name, module_name) abort
@ -247,7 +281,7 @@ function! s:_sid(path, filter_pattern) abort
if has_key(s:cache_sid, unified_path)
return s:cache_sid[unified_path]
endif
for line in filter(split(s:_execute(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern')
for line in filter(split(execute(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern')
let [_, sid, path; __] = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$')
if s:_unify_path(path) is# unified_path
let s:cache_sid[unified_path] = sid
@ -257,21 +291,6 @@ function! s:_sid(path, filter_pattern) abort
return 0
endfunction
" We want to use a execute() builtin function instead of s:_execute(),
" however there is a bug in execute().
" execute() returns empty string when it is called in
" completion function of user defined ex command.
" https://github.com/vim-jp/issues/issues/1129
function! s:_execute(cmd) abort
let [save_verbose, save_verbosefile] = [&verbose, &verbosefile]
set verbose=0 verbosefile=
redir => res
silent! execute a:cmd
redir END
let [&verbose, &verbosefile] = [save_verbose, save_verbosefile]
return res
endfunction
if filereadable(expand('<sfile>:r') . '.VIM') " is case-insensitive or not
let s:_unify_path_cache = {}
" resolve() is slow, so we cache results.
@ -296,7 +315,7 @@ endif
" copied and modified from Vim.ScriptLocal
let s:SNR = join(map(range(len("\<SNR>")), '"[\\x" . printf("%0x", char2nr("\<SNR>"[v:val])) . "]"'), '')
function! s:sid2sfuncs(sid) abort
let fs = split(s:_execute(printf(':function /^%s%s_', s:SNR, a:sid)), "\n")
let fs = split(execute(printf(':function /^%s%s_', s:SNR, a:sid)), "\n")
let r = {}
let pattern = printf('\m^function\s<SNR>%d_\zs\w\{-}\ze(', a:sid)
for fname in map(fs, 'matchstr(v:val, pattern)')
@ -309,20 +328,3 @@ endfunction
function! s:_sfuncname(sid, funcname) abort
return printf('<SNR>%s_%s', a:sid, a:funcname)
endfunction
if exists('*uniq')
function! s:_uniq(list) abort
return uniq(a:list)
endfunction
else
function! s:_uniq(list) abort
let i = len(a:list) - 1
while 0 < i
if a:list[i] ==# a:list[i - 1]
call remove(a:list, i)
endif
let i -= 1
endwhile
return a:list
endfunction
endif

View File

@ -1,4 +1,4 @@
dein
bc0bd9ae0d48bb12f3909056b311cb489bd9c494
08087a6270f290e8d1974885f6705131b95691d9
System.Job

View File

@ -32,7 +32,7 @@ echo ""
if ! [ -e "$INSTALL_DIR" ]; then
echo "Begin fetching dein..."
mkdir -p "$PLUGIN_DIR"
git clone https://github.com/Shougo/dein.vim "$INSTALL_DIR"
git clone --depth=1 https://github.com/Shougo/dein.vim "$INSTALL_DIR"
echo "Done."
echo ""
fi

View File

@ -117,7 +117,11 @@ dein#add({repo}[, {options}])
path. If {repo} starts with github user name (ex:
"Shougo/dein.vim"), dein will install github plugins.
See |dein-options| for what to set in {options}.
Note: If plugin is already defined, duplicated calls will be
ignored.
Note: You must call it in |dein#begin()| block.
Note: If you install plugins, you need to call
|dein#install()| manually.
*dein#begin()*
dein#begin({base-path}, [{vimrcs}])
@ -149,7 +153,7 @@ dein#call_hook({hook-name})
*dein#check_install()*
dein#check_install({plugins})
Check the plugins installation.
Check {plugins} installation.
If {plugins} are not installed, it will return non-zero.
If {plugins} are invalid, it will return -1.
{plugins} are the plugins name list or the plugin name to
@ -163,12 +167,23 @@ dein#check_lazy_plugins()
"plugin/" directory.
*dein#check_update()*
dein#check_update([{plugins}])
Check the plugins update asynchronously.
{plugins} is the plugins name list to check.
If you omit it, dein will check all plugins update.
dein#check_update([{force}[, {plugins}]])
Check updated {plugins} by github GraphQL API.
https://docs.github.com/en/graphql
If {force} is |v:true|, it call |dein#update()|after updated
check.
{plugins} are the plugins name list or the plugin name to
check.
Note: You can use it for github plugins.
Note: It does not return value instead of
|dein#check_install()|.
Note: You need to set |g:dein#install_github_api_token| to use
the feature.
Note: |+python3| or |strptime()| is required.
Note: The update check is quick but it is not perfect
solution. If "git" command change ".git" directory status(for
example: "git reset"), it cannot detect the update properly.
And github API cannot detect upstream changes immediately.
*dein#check_clean()*
dein#check_clean()
@ -194,7 +209,7 @@ dein#config({options})
>
call dein#add('Shougo/deoplete.nvim')
call dein#config('deoplete.nvim', {
\ 'lazy' : 1, 'on_i' : 1,
\ 'lazy' : 1, 'on_event' : 'InsertEnter',
\ })
<
*dein#direct_install()*
@ -315,7 +330,7 @@ dein#load_toml({filename}, [{options}])
For toml file formats: |dein-toml|
>
let s:toml = '~/test_vim/lazy.toml'
if dein#load_state('~/test_vim/.cache/dein', [$MYVIMRC, s:toml])
if dein#load_state('~/test_vim/.cache/dein')
call dein#begin('~/test_vim/.cache/dein')
call dein#load_toml(s:toml, {'lazy': 1})
@ -422,8 +437,7 @@ VARIABLES *dein-variables*
*g:dein#auto_recache*
g:dein#auto_recache
If you set it to 1, call |dein#recache_runtimepath()|
automatically if necessary when saving the vimrc, toml file.
Note: It reloads your $MYVIMRC.
automatically in |dein#save_state()|.
Default: 0
@ -466,6 +480,20 @@ https://github.com/julienXX/terminal-notifier
Defaults: "0"
*g:dein#inline_vimrcs*
g:dein#inline_vimrcs
The vimrcs are sourced in |dein#end()| or
|dein#load_state()|.
Defaults: []
*g:dein#install_github_api_token*
g:dein#install_github_api_token
github API key to use |dein#check_update()|.
https://github.com/settings/tokens
Defaults: ""
*g:dein#install_max_processes*
g:dein#install_max_processes
The max number of processes used for dein/install source
@ -510,10 +538,18 @@ g:dein#install_message_type
*g:dein#install_log_filename*
g:dein#install_log_filename
The log filename. Set it to "" to disable logging.
Note: This option slows your installation process.
Default: ""
*g:dein#name*
*g:dein#lazy_rplugins*
g:dein#lazy_rplugins
If you set it to 1, neovim remote plugins are lazy loaded.
It is useful to save startup time.
Defaults: "0"
*g:dein#name*
g:dein#name
Current plugin name.
You can only use it in |dein#tap()| block.
@ -580,7 +616,6 @@ build (String)
runtimepath.
Note: In previous versions of dein, build could also be of
type dictionary, but that is now deprecated.
dictionary, but that is now deprecated.
Please use |dein-options-hook_post_update| instead.
Example:
@ -669,6 +704,7 @@ on_event (String) or (List)
on_func (List) or (String)
If it is matched to the called function, dein will call
|dein#source()|.
Note: It does not work when Vim initialised.
*dein-options-on_ft*
on_ft (List) or (String)
@ -702,6 +738,12 @@ on_if (String)
call dein#add('blueyed/vim-diminactive',
\ {'on_event': 'WinEnter', 'on_if': 'winnr("$") > 1'})
<
*dein-options-on_lua*
on_lua (List) or (String)
If it is matched to the required lua module root, dein will
call |dein#source()|.
Note: It is for neovim only.
*dein-options-on_map*
on_map (Dictionary) or (List) or (String)
If it is the Dictionary, the key is {mode} and the items are
@ -827,9 +869,8 @@ HOOKS *dein-hooks*
The string will be split by the lines.
It is useful for the plugins initialization.
Note: The Function hooks cannot be cached. You must
initialize it.
Note: You cannot use function hooks in |dein#save_state()|.
Note: You can use |g:dein#plugin| in the hooks.
Note: The loading order is not guaranteed in non lazy plugins.
Note: The string is executed as Ex commands.
@ -941,7 +982,7 @@ TOML *dein-toml*
[[plugins]]
repo = 'Shougo/neosnippet.vim'
on_i = 1
on_event = 'InsertEnter'
on_ft = 'snippet'
[[plugins]]
@ -1243,6 +1284,10 @@ Other plugin manager adds 'runtimepath' to load external plugins.
But if 'runtimepath' is very big, plugin loading is slower. Because Vim needs
to search all huge 'runtimepath' to load it. Dein.vim has not the problem.
Q: I want to load plugins lazily on requiring lua modules
A: >
call dein#add('neovim/nvim-lsp', {'on_lua': 'nvim_lsp'})
==============================================================================
COMPATIBILITY *dein-compatibility*

View File

@ -47,10 +47,13 @@ endfunction
function! s:suite.add_overwrite() abort
call s:assert.equals(dein#begin(s:path), 0)
call dein#add('foo', {})
call dein#parse#_add('foo', {}, v:true)
call s:assert.equals(g:dein#_plugins.foo.sourced, 0)
call dein#add('foo', { 'sourced': 1 })
call dein#parse#_add('foo', { 'sourced': 1 }, v:true)
call s:assert.equals(g:dein#_plugins.foo.sourced, 1)
call dein#parse#_add('foo', { 'sourced': 2 }, v:false)
call s:assert.equals(g:dein#_plugins.foo.sourced, 1)
call s:assert.equals(dein#end(), 0)

View File

@ -1,4 +1,4 @@
" set verbose=1
"set verbose=1
let s:suite = themis#suite('install')
let s:assert = themis#helper('assert')
@ -24,10 +24,6 @@ function! s:dein_update() abort
return dein#install#_update([], 'update', 0)
endfunction
function! s:dein_check_update() abort
return dein#install#_update([], 'check_update', 0)
endfunction
function! s:suite.before_each() abort
call dein#_init()
let &runtimepath = s:runtimepath_save
@ -37,6 +33,7 @@ function! s:suite.before_each() abort
let g:dein#enable_notification = 0
endfunction
" Note: It must be checked in the first
function! s:suite.install() abort
let g:dein#install_progress_type = 'title'
let g:dein#enable_notification = 1
@ -435,6 +432,31 @@ function! s:suite.lazy_on_pre_cmd() abort
\ 'v:val ==# plugin.rtp')), 1)
endfunction
if has('nvim-0.5')
function! s:suite.lazy_on_lua() abort
call dein#begin(s:path)
call dein#add('Shougo/deoplete.nvim', { 'on_lua': 'vim' })
call s:assert.equals(s:dein_install(), 0)
call dein#end()
let plugin = dein#get('deoplete.nvim')
call s:assert.equals(
\ len(filter(dein#util#_split_rtp(&runtimepath),
\ 'v:val ==# plugin.rtp')), 0)
lua require'vim.highlight'
call s:assert.equals(plugin.sourced, 1)
call s:assert.equals(
\ len(filter(dein#util#_split_rtp(&runtimepath),
\ 'v:val ==# plugin.rtp')), 1)
endfunction
endif
function! s:suite.lazy_on_idle() abort
call dein#begin(s:path)
@ -675,7 +697,6 @@ function! s:suite.build() abort
call s:assert.true(dein#check_install(['vimproc.vim']))
call s:assert.equals(s:dein_install(), 0)
call s:assert.equals(s:dein_check_update(), 0)
call s:assert.equals(g:foobar, 4)

View File

@ -195,10 +195,12 @@ function! s:suite.trusted() abort
let sudo = g:dein#_is_sudo
let g:dein#_is_sudo = 1
let parsed_plugin = dein#parse#_add('Shougo/denite.nvim', {})
let parsed_plugin = dein#parse#_add(
\ 'Shougo/deoplete.nvim', {}, v:false)
call s:assert.equals(parsed_plugin.rtp, '')
let parsed_plugin = dein#parse#_add('Shougo/denite.nvim', {'trusted': 1})
let parsed_plugin = dein#parse#_add(
\ 'Shougo/denite.nvim', {'trusted': 1}, v:false)
call s:assert.not_equals(parsed_plugin.rtp, '')
let g:dein#_is_sudo = sudo