From 9f5e635250cb6438ec200078ff9d31ef21b2e436 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 12 Jan 2022 21:55:49 +0800 Subject: [PATCH] fix(core): add spacevim root dir to rtp close https://github.com/SpaceVim/SpaceVim/issues/4558 --- main.vim | 51 +++++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/main.vim b/main.vim index 7e8cdc6c4..b9ea05f43 100644 --- a/main.vim +++ b/main.vim @@ -6,7 +6,21 @@ " License: GPLv3 "============================================================================= -call SpaceVim#logger#info('start to loading SpaceVim!') +let g:_spacevim_root_dir = escape(fnamemodify(resolve(fnamemodify(expand(''), + \ ':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 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(''), - \ ':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()