diff options
| author | Tommy Allen <tommy@esdf.io> | 2016-07-12 02:17:58 -0400 | 
|---|---|---|
| committer | Tommy Allen <tommy@esdf.io> | 2016-08-17 16:22:15 -0400 | 
| commit | 01e33e1c74619fc8d262e2dedbd45a20bdb24245 (patch) | |
| tree | 1f053d05a71a94ec4a57e122b073cb2728d0f22c /runtime/autoload | |
| parent | dfb6a5133b92ffb38bfb7201e91f3de328652558 (diff) | |
| download | rneovim-01e33e1c74619fc8d262e2dedbd45a20bdb24245.tar.gz rneovim-01e33e1c74619fc8d262e2dedbd45a20bdb24245.tar.bz2 rneovim-01e33e1c74619fc8d262e2dedbd45a20bdb24245.zip | |
runtime: rplugin manifest written to $XDG_DATA_HOME
Uses $NVIM_RPLUGIN_MANIFEST if available
Diffstat (limited to 'runtime/autoload')
| -rw-r--r-- | runtime/autoload/remote/host.vim | 55 | 
1 files changed, 51 insertions, 4 deletions
| diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index eb5e87d7e1..104a27f357 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -118,7 +118,38 @@ 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 preferred = has('win32') +        \ ? ['$LOCALAPPDATA', '~/AppData/Local'] +        \ : ['$XDG_DATA_HOME', '~/.local/share'] + +  for dest in preferred +    if dest[0] == '$' && !exists(dest) +      continue +    endif + +    let dest = fnamemodify(expand(dest), ':p') +    if !empty(dest) && isdirectory(dest) +      let dest .= 'nvim/' +      call mkdir(dest, 'p', 700) +      let manifest_base = dest +      break +    endif +  endfor + +  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 +158,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 +249,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 | 
