diff options
author | James McCoy <jamessan@jamessan.com> | 2018-12-22 21:53:09 -0500 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2018-12-27 21:07:28 -0500 |
commit | 135991712a360c34ca14a3e95cf61ca5263d7a71 (patch) | |
tree | 5e553637fd77d4d09379dc2c07cf6c244b3d213f | |
parent | 15cc17521ef01f33af4930574099a1d8b930461e (diff) | |
download | rneovim-135991712a360c34ca14a3e95cf61ca5263d7a71.tar.gz rneovim-135991712a360c34ca14a3e95cf61ca5263d7a71.tar.bz2 rneovim-135991712a360c34ca14a3e95cf61ca5263d7a71.zip |
rplugin.vim: Add migration support for Windows, nvim/ -> nvim-data/
-rw-r--r-- | runtime/plugin/rplugin.vim | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim index b9e872a0d6..122d8d47f8 100644 --- a/runtime/plugin/rplugin.vim +++ b/runtime/plugin/rplugin.vim @@ -23,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 |