@@ -17,6 +17,8 @@ let s:plug_options = {}
1717let s: dot_spacevim = $HOME .' /.spacevim'
1818let s: private_config = g: spacevim .base.' /private/config.vim'
1919let s: private_packages = g: spacevim .base.' /private/packages.vim'
20+ let g: dein_recache_needed = v: false
21+ let g: dein #types#git#clone_depth = 1
2022let s: TYPE = {
2123\ ' string' : type (' ' ),
2224\ ' list' : type ([]),
@@ -30,18 +32,16 @@ function! spacevim#bootstrap() abort
3032endfunction
3133
3234function ! spacevim#begin () abort
33- " Download vim-plug if unavailable
34- if ! g: spacevim .os.windows
35- call s: check_vim_plug ()
36- endif
3735 call s: define_command ()
3836 call s: cache ()
3937 call s: check_dot_spacevim ()
38+ call s: check_dein_vim ()
4039endfunction
4140
42- function ! s: check_vim_plug () abort
43- let l: plug_path = g: spacevim .nvim ? ' ~/.local/share/nvim/site/autoload/plug.vim' : ' ~/.vim/autoload/plug.vim'
44- if empty (glob (l: plug_path )) | call spacevim#vim#plug#download (l: plug_path ) | endif
41+ function ! s: check_dein_vim () abort
42+ let s: dein_path = g: spacevim_plug_home . ' /repos/github.com/Shougo/dein.vim'
43+ if empty (glob (s: dein_path .' /.git' )) | call spacevim#vim#plug#download (s: dein_path ) | endif
44+ let &runtimepath .= ' ,' .fnamemodify (s: dein_path , " :p:h" )
4545endfunction
4646
4747function ! s: define_command () abort
@@ -51,6 +51,9 @@ function! s:define_command() abort
5151 command ! -nargs =0 - bar SpaceInfo call spacevim#debugging#Info ()
5252 command ! -nargs =0 - bar LayerCache call spacevim#cache#init ()
5353 command ! -nargs =0 - bar LayerStatus call spacevim#layer#status ()
54+ command ! -nargs =+ - bar Plug call spacevim#vim#plug#Plug (<args> )
55+ command ! -nargs =* - bar PlugInstall call dein#install (<args> ) | call dein#recache_runtimepath ()
56+ command ! -nargs =* - bar PlugUpdate call dein#update (<args> ) | call dein#recache_runtimepath ()
5457endfunction
5558
5659function ! s: check_dot_spacevim () abort
@@ -59,6 +62,9 @@ function! s:check_dot_spacevim() abort
5962 call extend (g: spacevim .loaded, get (g: , ' spacevim_layers' , []))
6063 let g: mapleader = get (g: , ' spacevim_leader' , " \<Space> " )
6164 let g: maplocalleader = get (g: , ' spacevim_localleader' , ' ,' )
65+ let g: spacevim_plug_home = get (g: , ' spacevim_plug_home' ,
66+ \ g: spacevim .nvim ? ' ~/.local/share/nvim/plugged' : ' ~/.vim/plugged' )
67+ let g: spacevim_merge_layer_rtp = get (g: , ' spacevim_merge_layer_rtp' , 1 )
6268 else
6369 call spacevim#util#err (' .spacevim does not exist! Exiting...' )
6470 endif
@@ -108,16 +114,6 @@ function! s:my_plugin(plugin, ...) abort
108114 endif
109115 if a: 0 == 1
110116 let s: plug_options [a: plugin ] = a: 1
111- if has_key (a: 1 , ' on_event' )
112- let l: group = ' load/' .a: plugin
113- let l: name = split (a: plugin , ' /' )[1 ]
114- let l: events = join (s: to_a (a: 1 .on_event), ' ,' )
115- let l: load = printf (" call plug#load('%s')" , l: name )
116- execute " augroup" l: group
117- autocmd !
118- execute ' autocmd' l: events ' *' l: load ' |' ' autocmd!' l: group
119- execute ' augroup END'
120- endif
121117 endif
122118endfunction
123119
@@ -151,26 +147,33 @@ function! spacevim#end() abort
151147 silent doautocmd <nomodeline> User SpacevimAfterUserConfig
152148endfunction
153149
154- " Initialize vim-plug system
150+ " Initialize dein system
155151function ! s: register_plugin () abort
156- " https://github.com/junegunn/vim-plug/issues/559
157- call plug#begin (get (g: , ' spacevim_plug_home' ,
158- \ g: spacevim .nvim ? ' ~/.local/share/nvim/plugged' : ' ~/.vim/plugged/' ))
152+ if g: spacevim_merge_layer_rtp == 0
153+ let g: dein #default_options = { ' merged' : v: false }
154+ endif
155+ call dein#begin (g: spacevim_plug_home )
156+ call dein#add (s: dein_path )
159157 call s: packages ()
160- " Register non-excluded plugins
161- function ! s: filter_and_register (val) abort
162- if index (g: spacevim .excluded, a: val ) < 0
163- if has_key (s: plug_options , a: val )
164- call plug# (a: val , s: plug_options [a: val ])
165- else
166- call plug# (a: val )
167- endif
158+ function ! s: register (val) abort
159+ if has_key (s: plug_options , a: val )
160+ call dein#add (a: val , s: plug_options [a: val ])
161+ else
162+ call dein#add (a: val )
168163 endif
169164 endfunction
170165 call extend (g: spacevim .excluded, get (g: , ' spacevim_excluded' , []))
171- call map (copy (g: spacevim .plugins), ' s:filter_and_register(v:val)' )
166+ call dein#disable (g: spacevim .excluded)
167+ call map (copy (g: spacevim .plugins), {i ,v - > s: register (v )})
172168 if exists (' *UserInit' ) | call UserInit () | endif
173- call plug#end ()
169+ if g: dein_recache_needed == v: true && g: spacevim_merge_layer_rtp == 1
170+ call dein#recache_runtimepath ()
171+ endif
172+ call dein#end ()
173+ filetype plugin indent on
174+ syntax enable
175+ delcommand Plug
176+ delcommand MP
174177endfunction
175178
176179function ! s: packages () abort
@@ -247,11 +250,3 @@ function! spacevim#load_any(...) abort
247250 endfor
248251 return 0
249252endfunction
250-
251- function ! spacevim#VimPlugPostUpdateHook (make , cmd, info) abort
252- if spacevim#load (' programming' )
253- execute (' AsyncRun -mode=term -pos=tab ' .(a: make ?' -program=make ' :' ' ).' @ ' .a: cmd )
254- else
255- call system (a: cmd )
256- endif
257- endfunction
0 commit comments