mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 10:50:07 +08:00
Merge branch 'fix_issue_232' into dev
This commit is contained in:
commit
45a8f52809
@ -66,7 +66,7 @@ let g:spacevim_vim_plug_installed = 0
|
|||||||
" >
|
" >
|
||||||
" let g:spacevim_plugin_bundle_dir = '~/.cache/vimplugs'
|
" let g:spacevim_plugin_bundle_dir = '~/.cache/vimplugs'
|
||||||
" <
|
" <
|
||||||
let g:spacevim_plugin_bundle_dir = $HOME. join(['', '.cache', 'vimfiles', ''], '/')
|
let g:spacevim_plugin_bundle_dir = $HOME. join(['', '.cache', 'vimfiles', ''], SpaceVim#api#import('file').separator)
|
||||||
""
|
""
|
||||||
" Disable/Enable realtime leader guide, by default it is 0.
|
" Disable/Enable realtime leader guide, by default it is 0.
|
||||||
" to enable this feature:
|
" to enable this feature:
|
||||||
|
8
autoload/SpaceVim/api.vim
Normal file
8
autoload/SpaceVim/api.vim
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
function! SpaceVim#api#import(name) abort
|
||||||
|
let p = {}
|
||||||
|
try
|
||||||
|
let p = SpaceVim#api#{a:name}#get()
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E117/
|
||||||
|
endtry
|
||||||
|
return p
|
||||||
|
endfunction
|
15
autoload/SpaceVim/api/file.vim
Normal file
15
autoload/SpaceVim/api/file.vim
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
let s:file = {}
|
||||||
|
let s:system = SpaceVim#api#import('system')
|
||||||
|
|
||||||
|
if s:system.isWindows
|
||||||
|
let s:file['separator'] = '\'
|
||||||
|
else
|
||||||
|
let s:file['separator'] = '/'
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! SpaceVim#api#file#get() abort
|
||||||
|
return deepcopy(s:file)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
12
autoload/SpaceVim/api/system.vim
Normal file
12
autoload/SpaceVim/api/system.vim
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
let s:system = {}
|
||||||
|
|
||||||
|
let s:system['isWindows'] = has('win16') || has('win32') || has('win64')
|
||||||
|
|
||||||
|
let s:system['isLinux'] = has('unix') && !has('macunix') && !has('win32unix')
|
||||||
|
|
||||||
|
let s:system['isOSX'] = has('macunix')
|
||||||
|
|
||||||
|
|
||||||
|
function! SpaceVim#api#system#get() abort
|
||||||
|
return deepcopy(s:system)
|
||||||
|
endfunction
|
@ -1,6 +1,6 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
function! s:install_manager()
|
function! s:install_manager() abort
|
||||||
" Fsep && Psep
|
" Fsep && Psep
|
||||||
if has('win16') || has('win32') || has('win64')
|
if has('win16') || has('win32') || has('win64')
|
||||||
let s:Psep = ';'
|
let s:Psep = ';'
|
||||||
@ -21,19 +21,19 @@ function! s:install_manager()
|
|||||||
\ .'https://github.com/'
|
\ .'https://github.com/'
|
||||||
\ .'Shougo/neobundle.vim'
|
\ .'Shougo/neobundle.vim'
|
||||||
\ . ' '
|
\ . ' '
|
||||||
\ . g:spacevim_plugin_bundle_dir
|
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||||
\ . 'neobundle.vim'
|
\ . 'neobundle.vim'
|
||||||
let g:spacevim_neobundle_installed = 1
|
let g:spacevim_neobundle_installed = 1
|
||||||
else
|
else
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom "You need install git!"
|
echom 'You need install git!'
|
||||||
echohl None
|
echohl None
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
exec 'set runtimepath+='
|
exec 'set runtimepath+='
|
||||||
\ . g:spacevim_plugin_bundle_dir
|
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||||
\ . 'neobundle.vim'
|
\ . 'neobundle.vim'
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
"auto install dein
|
"auto install dein
|
||||||
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
||||||
\ . join(['repos', 'github.com',
|
\ . join(['repos', 'github.com',
|
||||||
@ -42,21 +42,21 @@ function! s:install_manager()
|
|||||||
let g:spacevim_dein_installed = 1
|
let g:spacevim_dein_installed = 1
|
||||||
else
|
else
|
||||||
if executable('git')
|
if executable('git')
|
||||||
exec '!git clone https://github.com/Shougo/dein.vim '
|
exec '!git clone https://github.com/Shougo/dein.vim "'
|
||||||
\ . g:spacevim_plugin_bundle_dir
|
\ . g:spacevim_plugin_bundle_dir
|
||||||
\ . join(['repos', 'github.com',
|
\ . join(['repos', 'github.com',
|
||||||
\ 'Shougo', 'dein.vim'], s:Fsep)
|
\ 'Shougo', 'dein.vim"'], s:Fsep)
|
||||||
let g:spacevim_dein_installed = 1
|
let g:spacevim_dein_installed = 1
|
||||||
else
|
else
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom "You need install git!"
|
echom 'You need install git!'
|
||||||
echohl None
|
echohl None
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
exec 'set runtimepath+='.g:spacevim_plugin_bundle_dir
|
exec 'set runtimepath+='. fnameescape(g:spacevim_plugin_bundle_dir)
|
||||||
\ . join(['repos', 'github.com', 'Shougo',
|
\ . join(['repos', 'github.com', 'Shougo',
|
||||||
\ 'dein.vim'], s:Fsep)
|
\ 'dein.vim'], s:Fsep)
|
||||||
elseif g:spacevim_plugin_manager == 'vim-plug'
|
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||||
"auto install vim-plug
|
"auto install vim-plug
|
||||||
if filereadable(expand('~/.cache/vim-plug/autoload/plug.vim'))
|
if filereadable(expand('~/.cache/vim-plug/autoload/plug.vim'))
|
||||||
let g:spacevim_vim_plug_installed = 1
|
let g:spacevim_vim_plug_installed = 1
|
||||||
@ -70,7 +70,7 @@ function! s:install_manager()
|
|||||||
let g:spacevim_vim_plug_installed = 1
|
let g:spacevim_vim_plug_installed = 1
|
||||||
else
|
else
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echom "You need install curl!"
|
echom 'You need install curl!'
|
||||||
echohl None
|
echohl None
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -90,22 +90,22 @@ function! zvim#plug#begin(path) abort
|
|||||||
let g:unite_source_menu_menus.AddedPlugins.command_candidates = []
|
let g:unite_source_menu_menus.AddedPlugins.command_candidates = []
|
||||||
nnoremap <silent><Leader>lp :Unite -silent
|
nnoremap <silent><Leader>lp :Unite -silent
|
||||||
\ -winheight=17 -start-insert menu:AddedPlugins<CR>
|
\ -winheight=17 -start-insert menu:AddedPlugins<CR>
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
call neobundle#begin(a:path)
|
call neobundle#begin(a:path)
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
call dein#begin(a:path)
|
call dein#begin(a:path)
|
||||||
elseif g:spacevim_plugin_manager == 'vim-plug'
|
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||||
call plug#begin(a:path)
|
call plug#begin(a:path)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#end() abort
|
function! zvim#plug#end() abort
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
call neobundle#end()
|
call neobundle#end()
|
||||||
if g:spacevim_checkinstall == 1
|
if g:spacevim_checkinstall == 1
|
||||||
NeoBundleCheck
|
NeoBundleCheck
|
||||||
endif
|
endif
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
call dein#end()
|
call dein#end()
|
||||||
if g:spacevim_checkinstall == 1
|
if g:spacevim_checkinstall == 1
|
||||||
silent! let flag = dein#check_install()
|
silent! let flag = dein#check_install()
|
||||||
@ -117,18 +117,18 @@ function! zvim#plug#end() abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call dein#call_hook('source')
|
call dein#call_hook('source')
|
||||||
elseif g:spacevim_plugin_manager == 'vim-plug'
|
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#defind_hooks(bundle) abort
|
function! zvim#plug#defind_hooks(bundle) abort
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
let s:hooks = neobundle#get_hooks(a:bundle)
|
let s:hooks = neobundle#get_hooks(a:bundle)
|
||||||
func! s:hooks.on_source(bundle) abort
|
func! s:hooks.on_source(bundle) abort
|
||||||
call zvim#util#source_rc('plugins/' . split(a:bundle['name'],'\.')[0] . '.vim')
|
call zvim#util#source_rc('plugins/' . split(a:bundle['name'],'\.')[0] . '.vim')
|
||||||
endf
|
endf
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
call dein#config(g:dein#name, {
|
call dein#config(g:dein#name, {
|
||||||
\ 'hook_source' : "call zvim#util#source_rc('plugins/" . split(g:dein#name,'\.')[0] . ".vim')"
|
\ 'hook_source' : "call zvim#util#source_rc('plugins/" . split(g:dein#name,'\.')[0] . ".vim')"
|
||||||
\ })
|
\ })
|
||||||
@ -136,32 +136,32 @@ function! zvim#plug#defind_hooks(bundle) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#fetch() abort
|
function! zvim#plug#fetch() abort
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
NeoBundleFetch 'Shougo/neobundle.vim'
|
NeoBundleFetch 'Shougo/neobundle.vim'
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
call dein#add('Shougo/dein.vim')
|
call dein#add('Shougo/dein.vim')
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:plugins = []
|
let s:plugins = []
|
||||||
|
|
||||||
fu! s:parser(args)
|
fu! s:parser(args) abort
|
||||||
return a:args
|
return a:args
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! zvim#plug#add(repo,...) abort
|
function! zvim#plug#add(repo,...) abort
|
||||||
let g:spacevim_plugin_name = ''
|
let g:spacevim_plugin_name = ''
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
exec 'NeoBundle "'.a:repo.'"'.','.join(a:000,',')
|
exec 'NeoBundle "'.a:repo.'"'.','.join(a:000,',')
|
||||||
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
if len(a:000) > 0
|
if len(a:000) > 0
|
||||||
call dein#add(a:repo,s:parser(a:000[0]))
|
call dein#add(a:repo,s:parser(a:000[0]))
|
||||||
else
|
else
|
||||||
call dein#add(a:repo)
|
call dein#add(a:repo)
|
||||||
endif
|
endif
|
||||||
let g:spacevim_plugin_name = g:dein#name
|
let g:spacevim_plugin_name = g:dein#name
|
||||||
elseif g:spacevim_plugin_manager == 'vim-plug'
|
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||||
if len(a:000) > 0
|
if len(a:000) > 0
|
||||||
exec "Plug '".a:repo."', ".join(a:000,',')
|
exec "Plug '".a:repo."', ".join(a:000,',')
|
||||||
else
|
else
|
||||||
@ -185,9 +185,9 @@ function! zvim#plug#add(repo,...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#tap(plugin) abort
|
function! zvim#plug#tap(plugin) abort
|
||||||
if g:spacevim_plugin_manager == 'neobundle'
|
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||||
return neobundle#tap(a:plugin)
|
return neobundle#tap(a:plugin)
|
||||||
elseif g:spacevim_plugin_manager == 'dein'
|
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||||
return dein#tap(a:plugin)
|
return dein#tap(a:plugin)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -199,7 +199,7 @@ function! zvim#plug#enable_plug() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#loadPluginBefore(plugin) abort
|
function! zvim#plug#loadPluginBefore(plugin) abort
|
||||||
if matchend(a:plugin, ".vim") == len(a:plugin)
|
if matchend(a:plugin, '.vim') == len(a:plugin)
|
||||||
call zvim#util#source_rc('plugins_before/' . a:plugin)
|
call zvim#util#source_rc('plugins_before/' . a:plugin)
|
||||||
else
|
else
|
||||||
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
||||||
|
Loading…
Reference in New Issue
Block a user