mirror of
https://github.com/neovim/neovim.git
synced 2025-12-10 16:42:42 +00:00
rplugin.vim: Add migration support for Windows, nvim/ -> nvim-data/
This commit is contained in:
@@ -23,22 +23,32 @@ function! s:GetManifestPath() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Old manifest file based on known script locations.
|
" Old manifest file based on known script locations.
|
||||||
function! s:GetOldManifestPath() abort
|
function! s:GetOldManifestPaths() abort
|
||||||
let prefix = exists('$MYVIMRC')
|
let prefix = exists('$MYVIMRC')
|
||||||
\ ? $MYVIMRC
|
\ ? $MYVIMRC
|
||||||
\ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
|
\ : 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~'
|
\.'/.'.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
|
endfunction
|
||||||
|
|
||||||
function! s:GetManifest() abort
|
function! s:GetManifest() abort
|
||||||
let manifest = s:GetManifestPath()
|
let manifest = s:GetManifestPath()
|
||||||
if !filereadable(manifest)
|
if !filereadable(manifest)
|
||||||
" Check if an old manifest file exists and move it to the new location.
|
" Check if an old manifest file exists and move it to the new location.
|
||||||
let old_manifest = s:GetOldManifestPath()
|
for old_manifest in s:GetOldManifestPaths()
|
||||||
if filereadable(old_manifest)
|
if filereadable(old_manifest)
|
||||||
call rename(old_manifest, manifest)
|
call rename(old_manifest, manifest)
|
||||||
endif
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
return manifest
|
return manifest
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user