mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 23:49:19 +08:00
Update runtime log for startup (#2219)
This commit is contained in:
parent
ee02a29869
commit
34a3c4d64e
@ -863,39 +863,54 @@ function! SpaceVim#end() abort
|
||||
endfunction
|
||||
|
||||
|
||||
" return [status, dir]
|
||||
" status: 0 : no argv
|
||||
" 1 : dir
|
||||
" 2 : filename
|
||||
function! s:parser_argv() abort
|
||||
if !argc()
|
||||
return [0]
|
||||
elseif argv(0) =~# '/$'
|
||||
let f = fnamemodify(expand(argv(0)), ':p')
|
||||
if isdirectory(f)
|
||||
return [1, f]
|
||||
else
|
||||
return [1, getcwd()]
|
||||
endif
|
||||
elseif argv(0) ==# '.'
|
||||
return [1, getcwd()]
|
||||
elseif isdirectory(expand(argv(0)))
|
||||
return [1, fnamemodify(expand(argv(0)), ':p')]
|
||||
else
|
||||
return [2, argv()]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#begin() abort
|
||||
|
||||
call zvim#util#source_rc('functions.vim')
|
||||
call zvim#util#source_rc('init.vim')
|
||||
|
||||
" Before loading SpaceVim, We need to parser argvs.
|
||||
function! s:parser_argv() abort
|
||||
if !argc()
|
||||
return [1, getcwd()]
|
||||
elseif argv(0) =~# '/$'
|
||||
let f = fnamemodify(expand(argv(0)), ':p')
|
||||
if isdirectory(f)
|
||||
return [1, f]
|
||||
else
|
||||
return [1, getcwd()]
|
||||
endif
|
||||
elseif argv(0) ==# '.'
|
||||
return [1, getcwd()]
|
||||
elseif isdirectory(expand(argv(0)))
|
||||
return [1, fnamemodify(expand(argv(0)), ':p')]
|
||||
else
|
||||
return [0]
|
||||
endif
|
||||
endfunction
|
||||
let s:status = s:parser_argv()
|
||||
call SpaceVim#logger#info('SpaceVim startup status is: ' . string(s:status) )
|
||||
" If do not start Vim with filename, Define autocmd for opening welcome page
|
||||
if s:status[0]
|
||||
let g:_spacevim_enter_dir = s:status[1]
|
||||
if s:status[0] == 0
|
||||
let g:_spacevim_enter_dir = fnamemodify(getcwd(), ':~')
|
||||
call SpaceVim#logger#info('Startup with no argv, current dir is used: ' . g:_spacevim_enter_dir )
|
||||
augroup SPwelcome
|
||||
au!
|
||||
autocmd VimEnter * call SpaceVim#welcome()
|
||||
augroup END
|
||||
elseif s:status[0] == 1
|
||||
let g:_spacevim_enter_dir = fnamemodify(s:status[1], ':~')
|
||||
call SpaceVim#logger#info('Startup with directory: ' . g:_spacevim_enter_dir )
|
||||
augroup SPwelcome
|
||||
au!
|
||||
autocmd VimEnter * call SpaceVim#welcome()
|
||||
augroup END
|
||||
else
|
||||
call SpaceVim#logger#info('Startup with argv: ' . string(s:status[1]) )
|
||||
call SpaceVim#plugins#projectmanager#current_root()
|
||||
endif
|
||||
call SpaceVim#default#options()
|
||||
call SpaceVim#default#layers()
|
||||
|
@ -78,7 +78,7 @@ function! SpaceVim#custom#SPCGroupName(keys, name) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#custom#apply(config) abort
|
||||
function! SpaceVim#custom#apply(config, type) abort
|
||||
if type(a:config) != type({})
|
||||
call SpaceVim#logger#info('config type is wrong!')
|
||||
else
|
||||
@ -124,18 +124,18 @@ function! SpaceVim#custom#load() abort
|
||||
if filereadable('.SpaceVim.d/init.toml')
|
||||
let g:_spacevim_config_path = fnamemodify('.SpaceVim.d/init.toml', ':p')
|
||||
let &rtp = fnamemodify('.SpaceVim.d', ':p:h') . ',' . &rtp
|
||||
let local_conf = fnamemodify('.SpaceVim.d/init.toml', ':p')
|
||||
call SpaceVim#logger#info('find config file: ' . local_conf)
|
||||
let local_conf = g:_spacevim_config_path
|
||||
call SpaceVim#logger#info('find local conf: ' . local_conf)
|
||||
let local_conf_cache = s:path_to_fname(local_conf)
|
||||
if getftime(local_conf) < getftime(local_conf_cache)
|
||||
call SpaceVim#logger#info('loadding cached config: ' . local_conf_cache)
|
||||
call SpaceVim#logger#info('loadding cached local conf: ' . local_conf_cache)
|
||||
let conf = s:JSON.json_decode(join(readfile(local_conf_cache, ''), ''))
|
||||
call SpaceVim#custom#apply(conf)
|
||||
call SpaceVim#custom#apply(conf, 'local')
|
||||
else
|
||||
let conf = s:TOML.parse_file(local_conf)
|
||||
call SpaceVim#logger#info('generate config cache: ' . local_conf_cache)
|
||||
call SpaceVim#logger#info('generate local conf: ' . local_conf_cache)
|
||||
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
|
||||
call SpaceVim#custom#apply(conf)
|
||||
call SpaceVim#custom#apply(conf, 'local')
|
||||
endif
|
||||
if g:spacevim_force_global_config
|
||||
call SpaceVim#logger#info('force loadding global config >>>')
|
||||
@ -144,6 +144,8 @@ function! SpaceVim#custom#load() abort
|
||||
elseif filereadable('.SpaceVim.d/init.vim')
|
||||
let g:_spacevim_config_path = fnamemodify('.SpaceVim.d/init.vim', ':p')
|
||||
let &rtp = fnamemodify('.SpaceVim.d', ':p:h') . ',' . &rtp
|
||||
let local_conf = g:_spacevim_config_path
|
||||
call SpaceVim#logger#info('find local conf: ' . local_conf)
|
||||
exe 'source .SpaceVim.d/init.vim'
|
||||
if g:spacevim_force_global_config
|
||||
call SpaceVim#logger#info('force loadding global config >>>')
|
||||
@ -171,11 +173,11 @@ function! s:load_glob_conf() abort
|
||||
let &rtp = global_dir . ',' . &rtp
|
||||
if getftime(local_conf) < getftime(local_conf_cache)
|
||||
let conf = s:JSON.json_decode(join(readfile(local_conf_cache, ''), ''))
|
||||
call SpaceVim#custom#apply(conf)
|
||||
call SpaceVim#custom#apply(conf, 'glob')
|
||||
else
|
||||
let conf = s:TOML.parse_file(local_conf)
|
||||
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
|
||||
call SpaceVim#custom#apply(conf)
|
||||
call SpaceVim#custom#apply(conf, 'glob')
|
||||
endif
|
||||
elseif filereadable(global_dir . '/init.vim')
|
||||
let g:_spacevim_global_config_path = global_dir . '/init.vim'
|
||||
|
@ -34,12 +34,15 @@ endfunction
|
||||
" master
|
||||
function! s:git_branch() abort
|
||||
if exists('g:loaded_fugitive')
|
||||
try
|
||||
let l:head = fugitive#head()
|
||||
if empty(l:head)
|
||||
call fugitive#detect(getcwd())
|
||||
let l:head = fugitive#head()
|
||||
endif
|
||||
return empty(l:head) ? '' : ' '.l:head . ' '
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
@ -31,7 +31,7 @@ function! SpaceVim#layers#lang#julia#config() abort
|
||||
|
||||
let g:latex_to_unicode_auto = 1
|
||||
let g:latex_to_unicode_tab = 1
|
||||
runtime macros/matchit.vim
|
||||
" runtime macros/matchit.vim
|
||||
|
||||
" julia
|
||||
let g:default_julia_version = '0.7'
|
||||
|
@ -15,6 +15,8 @@
|
||||
"
|
||||
|
||||
|
||||
call add(g:spacevim_project_rooter_patterns, '.SpaceVim.d/')
|
||||
|
||||
let s:project_paths = {}
|
||||
|
||||
function! s:cache_project(prj) abort
|
||||
@ -127,6 +129,7 @@ endif
|
||||
function! s:find_root_directory() abort
|
||||
let fd = expand('%:p')
|
||||
let dirs = []
|
||||
call SpaceVim#logger#info('Start to find root for: ' . fd)
|
||||
for pattern in g:spacevim_project_rooter_patterns
|
||||
if stridx(pattern, '/') != -1
|
||||
let dir = SpaceVim#util#findDirInParent(pattern, fd)
|
||||
@ -134,10 +137,12 @@ function! s:find_root_directory() abort
|
||||
let dir = SpaceVim#util#findFileInParent(pattern, fd)
|
||||
endif
|
||||
let ftype = getftype(dir)
|
||||
if ftype == "dir" || ftype == "file"
|
||||
if ftype == 'dir' || ftype == 'file'
|
||||
let dir = fnamemodify(dir, ':p')
|
||||
call SpaceVim#logger#info("Find project root('" . pattern . "','" . fd . "'):" . dir)
|
||||
call add(dirs, dir)
|
||||
if dir !=# expand('~/.SpaceVim.d/')
|
||||
call SpaceVim#logger#info(" (" . pattern . "):" . dir)
|
||||
call add(dirs, dir)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return s:sort_dirs(deepcopy(dirs))
|
||||
|
@ -8,6 +8,8 @@ The next release is v1.0.0.
|
||||
|
||||
### Improvement
|
||||
|
||||
- Update runtime log for startup ([#2219](https://github.com/SpaceVim/SpaceVim/pull/2219))
|
||||
|
||||
### Changed
|
||||
|
||||
- Do not load language layer ([#2220](https://github.com/SpaceVim/SpaceVim/pull/2220))
|
||||
|
Loading…
x
Reference in New Issue
Block a user