Skip to content

Commit 877e572

Browse files
Use dein instead of vim-plug
1 parent 953d9ba commit 877e572

File tree

56 files changed

+261
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+261
-209
lines changed

README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,7 @@ The easist way is to download [`install.cmd`](https://raw.githubusercontent.com/
125125
$ git clone https://github.com/liuchengxu/space-vim.git --single-branch /path/to/space-vim
126126
```
127127

128-
2. Install [vim-plug](https://github.com/junegunn/vim-plug#installation), refer to vim-plug installation section for more information:
129-
```bash
130-
# For Vim
131-
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
132-
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
133-
134-
# For NeoVim
135-
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
136-
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
137-
```
138-
139-
3. Create the symlinks and install plugins:
128+
2. Create the symlinks and install plugins:
140129

141130
**Linux and macOS**
142131

@@ -201,10 +190,10 @@ Basically, `g:spacevim_layers` almost takes the place of `Layer` command. As far
201190
202191
```vim
203192
" Manage your own plugins.
204-
" Refer to https://github.com/junegunn/vim-plug for more detials.
193+
" Refer to https://github.com/Shougo/dein.vim for more detials.
205194
function! UserInit()
206195
207-
" Add your own plugin via Plug command.
196+
" Add your own plugin via Plug command (wrapper around dein#add)
208197
Plug 'junegunn/seoul256.vim'
209198
210199
endfunction

core/autoload/spacevim.vim

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ let s:plug_options = {}
1717
let s:dot_spacevim = $HOME.'/.spacevim'
1818
let s:private_config = g:spacevim.base.'/private/config.vim'
1919
let 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
2022
let s:TYPE = {
2123
\ 'string': type(''),
2224
\ 'list': type([]),
@@ -30,18 +32,16 @@ function! spacevim#bootstrap() abort
3032
endfunction
3133

3234
function! 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()
4039
endfunction
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")
4545
endfunction
4646

4747
function! 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()
5457
endfunction
5558

5659
function! 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
122118
endfunction
123119

@@ -151,26 +147,33 @@ function! spacevim#end() abort
151147
silent doautocmd <nomodeline> User SpacevimAfterUserConfig
152148
endfunction
153149

154-
" Initialize vim-plug system
150+
" Initialize dein system
155151
function! 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
174177
endfunction
175178

176179
function! s:packages() abort
@@ -247,11 +250,3 @@ function! spacevim#load_any(...) abort
247250
endfor
248251
return 0
249252
endfunction
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

core/autoload/spacevim/autocmd/go.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function s:ctagsbin()
22
if spacevim#load('go')
33
if !exists('*go#path#CheckBinPath')
4-
call plug#load('vim-go')
4+
call dein#source('vim-go')
55
endif
66
if exists('*go#path#CheckBinPath')
77
return go#path#CheckBinPath(get(g:, 'go_gotags_bin', 'gotags'))

core/autoload/spacevim/autocmd/unite.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ let s:menus.p = {
5454
\ 'description' : ' plugins ⌘ [menu]s',
5555
\}
5656
let s:menus.p.command_candidates = [
57-
\['► install-plugin (vim-plug)',
58-
\'PlugInstall'],
59-
\['► clean-plugin (vim-plug)',
60-
\'PlugClean'],
61-
\['► update-plugin (vim-plug)',
62-
\'PlugUpdate'],
63-
\['► show-plugin-status (vim-plug)',
64-
\'PlugStatus'],
57+
\['► install-plugin (dein)',
58+
\'call dein#install()'],
59+
\['► clean-plugin (dein)',
60+
\'call map(dein#check_clean(), { _, val -> delete(val, 'rf') }) | call dein#recache_runtimepath()'],
61+
\['► update-plugin (dein)',
62+
\'call dein#update()'],
63+
\['► show-plugin-status (dein)',
64+
\'Unite dein-unite-source-dein!'],
6565
\['► ycm-restart-server (ycmd)',
6666
\'YcmRestartServer'],
6767
\['► generate-markdown-toc (markdown-toc)',

core/autoload/spacevim/cache.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function! spacevim#cache#init() abort
99
else
1010
call s:init()
1111
endif
12+
let g:dein_recache_needed = v:true
1213
endfunction
1314

1415
function! s:init()

core/autoload/spacevim/defer.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
function! s:lod(...)
2-
" Ignore unknown plugins from vim-plug due to the excluded plugins
32
for l:plug in a:000
4-
silent! call plug#load(l:plug)
3+
silent! call dein#source(l:plug)
54
endfor
65
endfunction
76

core/autoload/spacevim/lang/python.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function! spacevim#lang#python#run()
2-
let l:cmd = has_key(g:plugs, 'asyncrun.vim') ? 'AsyncRun!' : '!'
2+
let l:cmd = dein#is_available('asyncrun.vim') ? 'AsyncRun!' : '!'
33
let l:exe = spacevim#lang#util#InferExecutable()
44
let l:py = l:exe != '' ? l:exe : get(g:, 'spacevim_python_run', 'python')
55
let l:fname = shellescape(@%, 1)

core/autoload/spacevim/lang/rust.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function! spacevim#lang#rust#Run() abort
2-
if has_key(g:plugs, 'asyncrun.vim')
2+
if dein#is_available('asyncrun.vim')
33
AsyncRun cargo run
44
else
55
!cargo run
@@ -9,7 +9,7 @@ endfunction
99
function! spacevim#lang#rust#Build() abort
1010
if has('terminal')
1111
call spacevim#vim#term#Run('cargo', 'build')
12-
elseif has_key(g:plugs, 'asyncrun.vim')
12+
elseif dein#is_available('asyncrun.vim')
1313
AsyncRun cargo build
1414
else
1515
!cargo build

core/autoload/spacevim/map/manager.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ function! spacevim#map#manager#BufTags() abort
3131

3232
" fzf
3333
elseif exists(':BTags')
34-
if !exists('g:loaded_fzf')
35-
call plug#load('fzf', 'fzf.vim')
34+
if !dein#is_sourced('fzf')
35+
call dein#source('fzf')
36+
endif
37+
if !dein#is_sourced('fzf.vim')
38+
call dein#source('fzf.vim')
3639
endif
3740
BTags
3841

core/autoload/spacevim/plug/youcompleteme.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ function! s:load_ycm()
3535
\ ]
3636
let l:cur_ft = &filetype
3737
if index(l:supported, l:cur_ft) > -1
38-
call plug#load('YouCompleteMe')
38+
call dein#source('YouCompleteMe')
3939
endif
4040
endfunction
4141

4242
" Load for supported types when loading via timer
4343
function! spacevim#plug#youcompleteme#invoke(timer) abort
4444
if !exists('g:loaded_youcompleteme')
45-
call plug#load('YouCompleteMe')
45+
call dein#source('YouCompleteMe')
4646
endif
4747
endfunction
4848

0 commit comments

Comments
 (0)