From 6afcc76a4977c9b0387324906b14de2086876b86 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 13 Nov 2022 00:02:20 +0800 Subject: [PATCH] fix(startup): fix startify close https://github.com/SpaceVim/SpaceVim/issues/4706 --- autoload/SpaceVim.vim | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 897858267..645426660 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -1603,9 +1603,25 @@ function! s:parser_argv() abort " if use embed nvim " for exmaple: neovim-qt " or only run vim/neovim without argvs - if index(v:argv, '--embed') !=# -1 - \ || len(v:argv) == 1 + if len(v:argv) == 1 return [0] + elseif index(v:argv, '--embed') !=# -1 + if v:argv[-1] =~# '/$' + let f = fnamemodify(expand(v:argv[-1]), ':p') + if isdirectory(f) + return [1, f] + else + return [1, getcwd()] + endif + elseif v:argv[-1] ==# '.' + return [1, getcwd()] + elseif isdirectory(expand(v:argv[-1])) + return [1, fnamemodify(expand(v:argv[-1]), ':p')] + elseif filereadable(v:argv[-1]) + return [2, get(v:, 'argv', ['failed to get v:argv'])] + else + return [0] + endif elseif index(v:argv, '-d') !=# -1 " this is diff mode return [2] @@ -1619,7 +1635,7 @@ function! s:parser_argv() abort elseif v:argv[-1] ==# '.' return [1, getcwd()] elseif isdirectory(expand(v:argv[-1])) - return [1, fnamemodify(expand(v:argv[1]), ':p')] + return [1, fnamemodify(expand(v:argv[-1]), ':p')] else return [2, get(v:, 'argv', ['failed to get v:argv'])] endif @@ -1741,7 +1757,9 @@ function! SpaceVim#welcome() abort endif if exists(':Startify') == 2 Startify - if isdirectory(bufname(1)) + if isdirectory(bufname(1)) && bufnr() !=# 1 + " startify will not change the buffer name + " if you run `nvim test/`, the buffer name is `test/`. bwipeout! 1 endif endif