mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #5050 'rplugin manifest: default to XDG dir'
Closes #5152 Closes #5090
This commit is contained in:
commit
ae6db26b09
@ -2,6 +2,9 @@ get_filename_component(BUSTED_DIR ${BUSTED_PRG} PATH)
|
|||||||
set(ENV{PATH} "${BUSTED_DIR}:$ENV{PATH}")
|
set(ENV{PATH} "${BUSTED_DIR}:$ENV{PATH}")
|
||||||
|
|
||||||
set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
|
set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
|
||||||
|
set(ENV{NVIM_RPLUGIN_MANIFEST} ${WORKING_DIR}/Xtest_rplugin_manifest)
|
||||||
|
set(ENV{XDG_CONFIG_HOME} ${WORKING_DIR}/Xtest_xdg/config)
|
||||||
|
set(ENV{XDG_DATA_HOME} ${WORKING_DIR}/Xtest_xdg/share)
|
||||||
|
|
||||||
if(NVIM_PRG)
|
if(NVIM_PRG)
|
||||||
set(ENV{NVIM_PROG} "${NVIM_PRG}")
|
set(ENV{NVIM_PROG} "${NVIM_PRG}")
|
||||||
@ -34,6 +37,9 @@ execute_process(
|
|||||||
RESULT_VARIABLE res
|
RESULT_VARIABLE res
|
||||||
${EXTRA_ARGS})
|
${EXTRA_ARGS})
|
||||||
|
|
||||||
|
file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest)
|
||||||
|
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg)
|
||||||
|
|
||||||
if(NOT res EQUAL 0)
|
if(NOT res EQUAL 0)
|
||||||
message(STATUS "Output to stderr:\n${err}")
|
message(STATUS "Output to stderr:\n${err}")
|
||||||
message(FATAL_ERROR "Running ${TEST_TYPE} tests failed with error: ${res}.")
|
message(FATAL_ERROR "Running ${TEST_TYPE} tests failed with error: ${res}.")
|
||||||
|
@ -118,7 +118,32 @@ function! remote#host#RegisterPlugin(host, path, specs) abort
|
|||||||
endfunction
|
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')
|
let prefix = exists('$MYVIMRC')
|
||||||
\ ? $MYVIMRC
|
\ ? $MYVIMRC
|
||||||
\ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
|
\ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
|
||||||
@ -127,9 +152,25 @@ function! s:GetManifest() abort
|
|||||||
endfunction
|
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
|
function! remote#host#LoadRemotePlugins() abort
|
||||||
if filereadable(s:GetManifest())
|
let manifest = s:GetManifest()
|
||||||
exe 'source '.s:GetManifest()
|
if filereadable(manifest)
|
||||||
|
execute 'source' fnameescape(manifest)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -202,7 +243,7 @@ function! remote#host#UpdateRemotePlugins() abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
call writefile(commands, s:GetManifest())
|
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())
|
\ s:GetManifest())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -93,22 +93,22 @@ approach with |rpcnotify()|, meaning return values or exceptions raised in the
|
|||||||
handler function are ignored.
|
handler function are ignored.
|
||||||
|
|
||||||
To test the above plugin, it must be saved in "rplugin/python" in a
|
To test the above plugin, it must be saved in "rplugin/python" in a
|
||||||
'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
|
'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
|
||||||
Then, the remote plugin manifest must be generated with
|
Then, the remote plugin manifest must be generated with
|
||||||
`:UpdateRemotePlugins`.
|
|:UpdateRemotePlugins|.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. Remote plugin manifest *remote-plugin-manifest*
|
4. Remote plugin manifest *remote-plugin-manifest*
|
||||||
|
*:UpdateRemotePlugins*
|
||||||
|
|
||||||
Just installing remote plugins to "rplugin/{host}" isn't enough for them to be
|
Just installing remote plugins to "rplugin/{host}" isn't enough for them to be
|
||||||
automatically loaded when required. You must execute `:UpdateRemotePlugins`
|
automatically loaded when required. You must execute |:UpdateRemotePlugins|
|
||||||
every time a remote plugin is installed, updated, or deleted.
|
every time a remote plugin is installed, updated, or deleted.
|
||||||
|
|
||||||
`:UpdateRemotePlugins` generates the remote plugin manifest, a special
|
|:UpdateRemotePlugins| generates the remote plugin manifest, a special
|
||||||
Vimscript file containing declarations for all Vimscript entities
|
Vimscript file containing declarations for all Vimscript entities
|
||||||
(commands/autocommands/functions) defined by all remote plugins, with each
|
(commands/autocommands/functions) defined by all remote plugins, with each
|
||||||
entity associated with the host and plugin path. The manifest is a generated
|
entity associated with the host and plugin path.
|
||||||
extension to the user's vimrc (it even has the vimrc filename prepended).
|
|
||||||
|
|
||||||
Manifest declarations are just calls to the `remote#host#RegisterPlugin`
|
Manifest declarations are just calls to the `remote#host#RegisterPlugin`
|
||||||
function, which takes care of bootstrapping the host as soon as the declared
|
function, which takes care of bootstrapping the host as soon as the declared
|
||||||
@ -125,10 +125,20 @@ the example, say the Java plugin is a semantic completion engine for Java code.
|
|||||||
If it defines the autocommand "BufEnter *.java", then the Java host is spawned
|
If it defines the autocommand "BufEnter *.java", then the Java host is spawned
|
||||||
only when Nvim loads a buffer matching "*.java".
|
only when Nvim loads a buffer matching "*.java".
|
||||||
|
|
||||||
If the explicit call to `:UpdateRemotePlugins` seems incovenient, try to see it
|
If the explicit call to |:UpdateRemotePlugins| seems incovenient, try to see it
|
||||||
like this: It's a way to provide IDE capabilities in Nvim while still keeping
|
like this: It's a way to provide IDE capabilities in Nvim while still keeping
|
||||||
it fast and lightweight for general use. It's also analogous to the |:helptags|
|
it fast and lightweight for general use. It's also analogous to the |:helptags|
|
||||||
command.
|
command.
|
||||||
|
|
||||||
|
*$NVIM_RPLUGIN_MANIFEST*
|
||||||
|
Unless $NVIM_RPLUGIN_MANIFEST is set the manifest will be written to a file
|
||||||
|
named `rplugin.vim` at:
|
||||||
|
|
||||||
|
Unix ~
|
||||||
|
$XDG_DATA_HOME/nvim/ or ~/.local/share/nvim/
|
||||||
|
|
||||||
|
Windows ~
|
||||||
|
$LOCALAPPDATA/nvim/ or ~/AppData/Local/nvim/
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -241,6 +241,7 @@ local function clear(...)
|
|||||||
'ASAN_OPTIONS',
|
'ASAN_OPTIONS',
|
||||||
'LD_LIBRARY_PATH', 'PATH',
|
'LD_LIBRARY_PATH', 'PATH',
|
||||||
'NVIM_LOG_FILE',
|
'NVIM_LOG_FILE',
|
||||||
|
'NVIM_RPLUGIN_MANIFEST',
|
||||||
}) do
|
}) do
|
||||||
env_tbl[k] = os.getenv(k)
|
env_tbl[k] = os.getenv(k)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user