aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/remote/host.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload/remote/host.vim')
-rw-r--r--runtime/autoload/remote/host.vim58
1 files changed, 50 insertions, 8 deletions
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index eb5e87d7e1..110f80297a 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
@@ -137,7 +178,9 @@ endfunction
function! remote#host#LoadRemotePluginsEvent(event, pattern) abort
autocmd! nvim-rplugin
call remote#host#LoadRemotePlugins()
- execute 'silent doautocmd <nomodeline>' a:event a:pattern
+ if exists('#'.a:event.'#'.a:pattern) " Avoid 'No matching autocommands'.
+ execute 'silent doautocmd <nomodeline>' a:event a:pattern
+ endif
endfunction
@@ -202,7 +245,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
@@ -220,9 +263,8 @@ function! remote#host#LoadErrorForHost(host, log) abort
\ 'You can try to see what happened '.
\ 'by starting Neovim with the environment variable '.
\ a:log . ' set to a file and opening the generated '.
- \ 'log file. Also, the host stderr will be available '.
- \ 'in Neovim log, so it may contain useful information. '.
- \ 'See also ~/.nvimlog.'
+ \ 'log file. Also, the host stderr is available '.
+ \ 'in messages.'
endfunction