diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-08-17 18:34:37 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-08-17 18:39:25 -0400 |
commit | ae6db26b0956f4a30185cfe0294143e73a37052e (patch) | |
tree | 6ccd93de430fd39162e257a370656a9aeaa66b6e /runtime/autoload | |
parent | dfb6a5133b92ffb38bfb7201e91f3de328652558 (diff) | |
parent | f9aa029a8b5b9dd93b4af56c995337bd853dc5c0 (diff) | |
download | rneovim-ae6db26b0956f4a30185cfe0294143e73a37052e.tar.gz rneovim-ae6db26b0956f4a30185cfe0294143e73a37052e.tar.bz2 rneovim-ae6db26b0956f4a30185cfe0294143e73a37052e.zip |
Merge #5050 'rplugin manifest: default to XDG dir'
Closes #5152
Closes #5090
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/remote/host.vim | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index eb5e87d7e1..5948de2b3d 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -118,7 +118,32 @@ function! remote#host#RegisterPlugin(host, path, specs) abort endfunction -function! s:GetManifest() abort +" Get the path to the rplugin manifest file. +function! s:GetManifestPath() abort + let manifest_base = '' + + if exists('$NVIM_RPLUGIN_MANIFEST') + 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') + if !empty(dest) && !filereadable(dest) + let dest .= ('/' ==# dest[-1:] ? '' : '/') . 'nvim' + call mkdir(dest, 'p', 0700) + let manifest_base = dest + endif + + return manifest_base.'/rplugin.vim' +endfunction + + +" Old manifest file based on known script locations. +function! s:GetOldManifestPath() abort let prefix = exists('$MYVIMRC') \ ? $MYVIMRC \ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$') @@ -127,9 +152,25 @@ function! s:GetManifest() abort 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 + endif + + return manifest +endfunction + + function! remote#host#LoadRemotePlugins() abort - if filereadable(s:GetManifest()) - exe 'source '.s:GetManifest() + let manifest = s:GetManifest() + if filereadable(manifest) + execute 'source' fnameescape(manifest) endif endfunction @@ -202,7 +243,7 @@ function! remote#host#UpdateRemotePlugins() abort endif endfor call writefile(commands, s:GetManifest()) - echomsg printf('remote/host: generated the manifest file in "%s"', + echomsg printf('remote/host: generated rplugin manifest: %s', \ s:GetManifest()) endfunction |