mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge #9383 from jamessan/stdpath-rplugin
Use stdpath() to determine rplugin manifest path
This commit is contained in:
commit
4a7f6dafe9
@ -11,14 +11,8 @@ function! s:GetManifestPath() abort
|
||||
return fnamemodify($NVIM_RPLUGIN_MANIFEST, ':p')
|
||||
endif
|
||||
|
||||
let dest = has('win32') ? '$LOCALAPPDATA' : '$XDG_DATA_HOME'
|
||||
if !exists(dest)
|
||||
let dest = has('win32') ? '~/AppData/Local' : '~/.local/share'
|
||||
endif
|
||||
|
||||
let dest = fnamemodify(expand(dest), ':p')
|
||||
let dest = stdpath('data')
|
||||
if !empty(dest)
|
||||
let dest .= ('/' ==# dest[-1:] ? '' : '/') . 'nvim'
|
||||
if !isdirectory(dest)
|
||||
call mkdir(dest, 'p', 0700)
|
||||
endif
|
||||
@ -29,22 +23,32 @@ function! s:GetManifestPath() abort
|
||||
endfunction
|
||||
|
||||
" Old manifest file based on known script locations.
|
||||
function! s:GetOldManifestPath() abort
|
||||
function! s:GetOldManifestPaths() abort
|
||||
let prefix = exists('$MYVIMRC')
|
||||
\ ? $MYVIMRC
|
||||
\ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
|
||||
return fnamemodify(expand(prefix, 1), ':h')
|
||||
let origpath = fnamemodify(expand(prefix, 1), ':h')
|
||||
\.'/.'.fnamemodify(prefix, ':t').'-rplugin~'
|
||||
if !has('win32')
|
||||
return [origpath]
|
||||
endif
|
||||
" Windows used to use $APPLOCALDATA/nvim but stdpath('data') is
|
||||
" $XDG_DATA_DIR/nvim-data
|
||||
let pseudostdpath = exists('$LOCALAPPDATA') ? '$LOCALAPPDATA' : '~/AppData/Local'
|
||||
let pseudostdpath = fnamemodify(expand(pseudostdpath), ':p')
|
||||
return [substitute(pseudostdpath, '[/\\]\=$', '/', '') . 'nvim/rplugin.vim', origpath]
|
||||
endfunction
|
||||
|
||||
function! s:GetManifest() abort
|
||||
let manifest = s:GetManifestPath()
|
||||
if !filereadable(manifest)
|
||||
" Check if an old manifest file exists and move it to the new location.
|
||||
let old_manifest = s:GetOldManifestPath()
|
||||
if filereadable(old_manifest)
|
||||
call rename(old_manifest, manifest)
|
||||
endif
|
||||
for old_manifest in s:GetOldManifestPaths()
|
||||
if filereadable(old_manifest)
|
||||
call rename(old_manifest, manifest)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return manifest
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user