aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-12-28 15:01:41 +0100
committerGitHub <noreply@github.com>2018-12-28 15:01:41 +0100
commit4a7f6dafe9e58315f90167ee41d279f3fa65eebb (patch)
tree0ced2fffde24604f3aa759de17dc52cedab9d46e
parente1876c7ad1b5e30c0a9919e2c4587d11550c8507 (diff)
parent135991712a360c34ca14a3e95cf61ca5263d7a71 (diff)
downloadrneovim-4a7f6dafe9e58315f90167ee41d279f3fa65eebb.tar.gz
rneovim-4a7f6dafe9e58315f90167ee41d279f3fa65eebb.tar.bz2
rneovim-4a7f6dafe9e58315f90167ee41d279f3fa65eebb.zip
Merge #9383 from jamessan/stdpath-rplugin
Use stdpath() to determine rplugin manifest path
-rw-r--r--runtime/plugin/rplugin.vim30
1 files changed, 17 insertions, 13 deletions
diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim
index 56163c894e..122d8d47f8 100644
--- a/runtime/plugin/rplugin.vim
+++ b/runtime/plugin/rplugin.vim
@@ -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