1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 22:59:15 +08:00

Add cmdline menu

This commit is contained in:
wsdjeg 2017-04-19 22:06:08 +08:00
parent 2a0165429f
commit 70c465086e
2 changed files with 37 additions and 0 deletions

View File

@ -371,6 +371,13 @@ function! SpaceVim#loadCustomConfig() abort
let custom_confs = SpaceVim#util#globpath(getcwd(), '.SpaceVim.d/init.vim')
let custom_glob_conf_old = expand('~/.local.vim')
let custom_glob_conf = expand('~/.SpaceVim.d/init.vim')
if !filereadable(custom_glob_conf_old) && !filereadable(custom_glob_conf)
" if there is no custom config auto generate it.
augroup SpaceVimBootstrap
au!
au VimEnter * call timer_start(10, function('SpaceVim#custom#autoconfig'))
augroup END
endif
" the old value will be remove
if filereadable(custom_glob_conf_old)
exe 'source ' . custom_glob_conf_old

View File

@ -20,3 +20,33 @@ endfunction
" What distribution of spacemacs would you like to start with?
" The standard distribution, recommended (spacemacs)
" A minimalist distribution that you can build on (spacemacs-base)
function! SpaceVim#custom#autoconfig(...) abort
let menu = SpaceVim#api#import('cmdlinemenu')
let ques = [
\ ['dark powered mode', function('s:awesome_mode')],
\ ['basic mode', function('s:basic_mode')],
\ ]
call menu.menu(ques)
endfunction
function! s:awesome_mode() abort
let config = []
call s:write_to_config(config)
endfunction
function! s:basic_mode() abort
let config = []
call s:write_to_config(config)
endfunction
function! s:write_to_config(config) abort
let cf = expand('~/.SpaceVim.d/init.vim')
if filereadable(cf)
return
endif
if !isdirectory(fnamemodify(cf, ':p:h'))
call mkdir(expand(fnamemodify(cf, ':p:h')), 'p')
endif
call writefile(a:config, cf, '')
endfunction