1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:40:06 +08:00

fix(core): add spacevim root dir to rtp

close https://github.com/SpaceVim/SpaceVim/issues/4558
This commit is contained in:
wsdjeg 2022-01-12 21:55:49 +08:00
parent 039d5187e9
commit 9f5e635250

View File

@ -6,7 +6,21 @@
" License: GPLv3
"=============================================================================
call SpaceVim#logger#info('start to loading SpaceVim!')
let g:_spacevim_root_dir = escape(fnamemodify(resolve(fnamemodify(expand('<sfile>'),
\ ':p:h:gs?\\?'.((has('win16') || has('win32')
\ || has('win64'))?'\':'/') . '?')), ':p:gs?[\\/]?/?'), ' ')
lockvar g:_spacevim_root_dir
if has('nvim')
let s:qtdir = split(&rtp, ',')[-1]
if s:qtdir =~# 'nvim-qt'
let &rtp = s:qtdir . ',' . g:_spacevim_root_dir . ',' . $VIMRUNTIME
else
let &rtp = g:_spacevim_root_dir . ',' . $VIMRUNTIME
endif
else
let &rtp = g:_spacevim_root_dir . ',' . $VIMRUNTIME
endif
call SpaceVim#logger#info('Loading SpaceVim from: ' . g:_spacevim_root_dir)
" Enable nocompatible
if has('vim_starting')
@ -38,41 +52,6 @@ if has('vim_starting')
endif
endif
endif
" Detect root directory of SpaceVim
if has('win16') || has('win32') || has('win64')
" this function is too slow.
" and will be deleted soon.
function! s:resolve(path) abort
let cmd = 'dir /a "' . a:path . '" | findstr SYMLINK'
" 2018/12/07 周五 下午 10:23 <SYMLINK> vimfiles [C:\Users\Administrator\.SpaceVim]
" ref: https://superuser.com/questions/524669/checking-where-a-symbolic-link-points-at-in-windows-7
silent let rst = system(cmd)
if !v:shell_error
let dir = split(rst)[-1][1:-2]
return dir
endif
return a:path
endfunction
else
function! s:resolve(path) abort
return resolve(a:path)
endfunction
endif
let g:_spacevim_root_dir = escape(fnamemodify(resolve(fnamemodify(expand('<sfile>'),
\ ':p:h:gs?\\?'.((has('win16') || has('win32')
\ || has('win64'))?'\':'/') . '?')), ':p:gs?[\\/]?/?'), ' ')
call SpaceVim#logger#info('init spacevim root dir:' . g:_spacevim_root_dir)
lockvar g:_spacevim_root_dir
if has('nvim')
let s:qtdir = split(&rtp, ',')[-1]
if s:qtdir =~# 'nvim-qt'
let &rtp = s:qtdir . ',' . g:_spacevim_root_dir . ',' . $VIMRUNTIME
else
let &rtp = g:_spacevim_root_dir . ',' . $VIMRUNTIME
endif
else
let &rtp = g:_spacevim_root_dir . ',' . $VIMRUNTIME
endif
call SpaceVim#begin()