aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/RunTests.cmake6
-rw-r--r--runtime/autoload/remote/host.vim49
-rw-r--r--runtime/doc/remote_plugin.txt26
-rw-r--r--src/nvim/api/buffer.c2
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/testdir/test_cmdline.vim36
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/helpers.lua1
-rw-r--r--test/functional/ui/bufhl_spec.lua8
9 files changed, 115 insertions, 19 deletions
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index 9fa91ffb5d..a045f9f982 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -2,6 +2,9 @@ get_filename_component(BUSTED_DIR ${BUSTED_PRG} PATH)
set(ENV{PATH} "${BUSTED_DIR}:$ENV{PATH}")
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)
set(ENV{NVIM_PROG} "${NVIM_PRG}")
@@ -34,6 +37,9 @@ execute_process(
RESULT_VARIABLE res
${EXTRA_ARGS})
+file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest)
+file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg)
+
if(NOT res EQUAL 0)
message(STATUS "Output to stderr:\n${err}")
message(FATAL_ERROR "Running ${TEST_TYPE} tests failed with error: ${res}.")
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
diff --git a/runtime/doc/remote_plugin.txt b/runtime/doc/remote_plugin.txt
index d906096a86..dddc021d68 100644
--- a/runtime/doc/remote_plugin.txt
+++ b/runtime/doc/remote_plugin.txt
@@ -93,22 +93,22 @@ approach with |rpcnotify()|, meaning return values or exceptions raised in the
handler function are ignored.
To test the above plugin, it must be saved in "rplugin/python" in a
-'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
-Then, the remote plugin manifest must be generated with
-`:UpdateRemotePlugins`.
+'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
+Then, the remote plugin manifest must be generated with
+|:UpdateRemotePlugins|.
==============================================================================
4. Remote plugin manifest *remote-plugin-manifest*
+ *:UpdateRemotePlugins*
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.
-`:UpdateRemotePlugins` generates the remote plugin manifest, a special
+|:UpdateRemotePlugins| generates the remote plugin manifest, a special
Vimscript file containing declarations for all Vimscript entities
(commands/autocommands/functions) defined by all remote plugins, with each
-entity associated with the host and plugin path. The manifest is a generated
-extension to the user's vimrc (it even has the vimrc filename prepended).
+entity associated with the host and plugin path.
Manifest declarations are just calls to the `remote#host#RegisterPlugin`
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
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
it fast and lightweight for general use. It's also analogous to the |:helptags|
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:
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 55b535c78c..c3bc1f52af 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -691,7 +691,7 @@ Integer buffer_add_highlight(Buffer buffer,
col_end = MAXCOL;
}
- int hlg_id = syn_name2id((char_u*)hl_group.data);
+ int hlg_id = syn_name2id((char_u *)(hl_group.data ? hl_group.data : ""));
src_id = bufhl_add_hl(buf, (int)src_id, hlg_id, (linenr_T)line+1,
(colnr_T)col_start+1, (colnr_T)col_end);
return src_id;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f6545a5ca9..d936c9572a 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9994,8 +9994,8 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv)
{
char_u *pat;
expand_T xpc;
- int options = WILD_KEEP_ALL | WILD_SILENT | WILD_USE_NL
- | WILD_LIST_NOTFOUND | WILD_NO_BEEP;
+ int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
+ | WILD_NO_BEEP;
if (p_wic) {
options |= WILD_ICASE;
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 438b20cc5e..902ec1c05d 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -47,45 +47,79 @@ func Test_getcompletion()
let l = getcompletion('v:n', 'var')
call assert_true(index(l, 'v:null') >= 0)
+ let l = getcompletion('v:notexists', 'var')
+ call assert_equal([], l)
let l = getcompletion('', 'augroup')
call assert_true(index(l, 'END') >= 0)
+ let l = getcompletion('blahblah', 'augroup')
+ call assert_equal([], l)
let l = getcompletion('', 'behave')
call assert_true(index(l, 'mswin') >= 0)
+ let l = getcompletion('not', 'behave')
+ call assert_equal([], l)
let l = getcompletion('', 'color')
call assert_true(index(l, 'default') >= 0)
+ let l = getcompletion('dirty', 'color')
+ call assert_equal([], l)
let l = getcompletion('', 'command')
call assert_true(index(l, 'sleep') >= 0)
+ let l = getcompletion('awake', 'command')
+ call assert_equal([], l)
let l = getcompletion('', 'dir')
- call assert_true(index(l, 'sautest') >= 0)
+ call assert_true(index(l, 'sautest/') >= 0)
+ let l = getcompletion('NoMatch', 'dir')
+ call assert_equal([], l)
let l = getcompletion('exe', 'expression')
call assert_true(index(l, 'executable(') >= 0)
+ let l = getcompletion('kill', 'expression')
+ call assert_equal([], l)
let l = getcompletion('tag', 'function')
call assert_true(index(l, 'taglist(') >= 0)
+ let l = getcompletion('paint', 'function')
+ call assert_equal([], l)
let l = getcompletion('run', 'file')
call assert_true(index(l, 'runtest.vim') >= 0)
+ let l = getcompletion('walk', 'file')
+ call assert_equal([], l)
let l = getcompletion('ha', 'filetype')
call assert_true(index(l, 'hamster') >= 0)
+ let l = getcompletion('horse', 'filetype')
+ call assert_equal([], l)
let l = getcompletion('z', 'syntax')
call assert_true(index(l, 'zimbu') >= 0)
+ let l = getcompletion('emacs', 'syntax')
+ call assert_equal([], l)
let l = getcompletion('jikes', 'compiler')
call assert_true(index(l, 'jikes') >= 0)
+ let l = getcompletion('break', 'compiler')
+ call assert_equal([], l)
+
+ helptags ALL
+ let l = getcompletion('last', 'help')
+ call assert_true(index(l, ':tablast') >= 0)
+ let l = getcompletion('giveup', 'help')
+ call assert_equal([], l)
let l = getcompletion('time', 'option')
call assert_true(index(l, 'timeoutlen') >= 0)
+ let l = getcompletion('space', 'option')
+ call assert_equal([], l)
let l = getcompletion('er', 'highlight')
call assert_true(index(l, 'ErrorMsg') >= 0)
+ let l = getcompletion('dark', 'highlight')
+ call assert_equal([], l)
" For others test if the name is recognized.
let names = ['buffer', 'environment', 'file_in_path',
diff --git a/src/nvim/version.c b/src/nvim/version.c
index aa337f9fae..1cb8d128aa 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -163,7 +163,7 @@ static int included_patches[] = {
// 2115,
// 2114,
// 2113,
- // 2112,
+ 2112,
// 2111,
// 2110,
// 2109,
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 6f43ec817c..2d54d23254 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -241,6 +241,7 @@ local function clear(...)
'ASAN_OPTIONS',
'LD_LIBRARY_PATH', 'PATH',
'NVIM_LOG_FILE',
+ 'NVIM_RPLUGIN_MANIFEST',
}) do
env_tbl[k] = os.getenv(k)
end
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index a8006e1ac6..80d413a455 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -111,12 +111,16 @@ describe('Buffer highlighting', function()
add_hl(id1, "ImportantWord", 2, 0, 9)
add_hl(id1, "ImportantWord", 3, 5, 14)
- id2 = add_hl(0, "Special", 0, 2, 8)
+ -- add_highlight can be called like this to get a new source
+ -- without adding any highlight
+ id2 = add_hl(0, "", 0, 0, 0)
+ neq(id1, id2)
+
+ add_hl(id2, "Special", 0, 2, 8)
add_hl(id2, "Identifier", 1, 3, 8)
add_hl(id2, "Special", 1, 14, 20)
add_hl(id2, "Underlined", 2, 6, 12)
add_hl(id2, "Underlined", 3, 0, 9)
- neq(id1, id2)
screen:expect([[
a {5:longer} example |