diff options
-rw-r--r-- | runtime/CMakeLists.txt | 1 | ||||
-rw-r--r-- | runtime/autoload/health/provider.vim | 62 | ||||
-rw-r--r-- | runtime/autoload/provider/node.vim | 76 | ||||
-rw-r--r-- | runtime/autoload/remote/host.vim | 4 | ||||
-rw-r--r-- | runtime/doc/pi_health.txt | 10 | ||||
-rw-r--r-- | src/nvim/eval.c | 10 | ||||
-rw-r--r-- | src/nvim/event/libuv_process.c | 2 | ||||
-rw-r--r-- | src/nvim/event/process.c | 7 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/fileio.c | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 38 | ||||
-rw-r--r-- | src/nvim/testdir/test_usercommands.vim | 104 | ||||
-rw-r--r-- | src/nvim/version.c | 10 | ||||
-rw-r--r-- | test/functional/plugin/health_spec.lua | 7 |
15 files changed, 329 insertions, 21 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index f81d8541b5..6dbe049232 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -137,6 +137,7 @@ endforeach() file(GLOB_RECURSE RUNTIME_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + rgb.txt *.vim *.dict *.py *.rb *.ps *.tutor) foreach(F ${RUNTIME_FILES}) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 0eaa678459..806a9d043b 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -487,9 +487,71 @@ function! s:check_ruby() abort endif endfunction +function! s:check_node() abort + call health#report_start('Node provider (optional)') + + let loaded_var = 'g:loaded_node_provider' + if exists(loaded_var) && !exists('*provider#node#Call') + call health#report_info('Disabled. '.loaded_var.'='.eval(loaded_var)) + return + endif + + if !executable('node') || !executable('npm') || !executable('yarn') + call health#report_warn( + \ '`node` and `npm` must be in $PATH.', + \ ['Install Node.js and verify that `node` and `npm` commands work.']) + return + endif + call health#report_info('Node: '. s:system('node -v')) + + let host = provider#node#Detect() + if empty(host) + call health#report_warn('Missing "neovim" npm package.', + \ ['Run in shell: npm install -g neovim', + \ 'Is the npm bin directory in $PATH?']) + return + endif + call health#report_info('Host: '. host) + + let latest_npm_cmd = has('win32') ? 'cmd /c npm info neovim --json' : 'npm info neovim --json' + let latest_npm = s:system(split(latest_npm_cmd)) + if s:shell_error || empty(latest_npm) + call health#report_error('Failed to run: '. latest_npm_cmd, + \ ["Make sure you're connected to the internet.", + \ 'Are you behind a firewall or proxy?']) + return + endif + if !empty(latest_npm) + try + let pkg_data = json_decode(latest_npm) + catch /E474/ + return 'error: '.latest_npm + endtry + let latest_npm = get(get(pkg_data, 'dist-tags', {}), 'latest', 'unable to parse') + endif + + let current_npm_cmd = host .' --version' + let current_npm = s:system(current_npm_cmd) + if s:shell_error + call health#report_error('Failed to run: '. current_npm_cmd, + \ ['Report this issue with the output of: ', current_npm_cmd]) + return + endif + + if s:version_cmp(current_npm, latest_npm) == -1 + call health#report_warn( + \ printf('Package "neovim" is out-of-date. Installed: %s, latest: %s', + \ current_npm, latest_npm), + \ ['Run in shell: npm update neovim']) + else + call health#report_ok('Latest "neovim" npm is installed: '. current_npm) + endif +endfunction + function! health#provider#check() abort call s:check_clipboard() call s:check_python(2) call s:check_python(3) call s:check_ruby() + call s:check_node() endfunction diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim new file mode 100644 index 0000000000..ce2740e813 --- /dev/null +++ b/runtime/autoload/provider/node.vim @@ -0,0 +1,76 @@ +if exists('g:loaded_node_provider') + finish +endif +let g:loaded_node_provider = 1 + +let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} + +function! provider#node#Detect() abort + return exepath('neovim-node-host') +endfunction + +function! provider#node#Prog() + return s:prog +endfunction + +function! provider#node#Require(host) abort + if s:err != '' + echoerr s:err + return + endif + + let args = ['node'] + + if !empty($NVIM_NODE_HOST_DEBUG) + call add(args, '--inspect-brk') + endif + + call add(args , provider#node#Prog()) + + try + let channel_id = jobstart(args, s:job_opts) + if rpcrequest(channel_id, 'poll') ==# 'ok' + return channel_id + endif + catch + echomsg v:throwpoint + echomsg v:exception + for row in provider#get_stderr(channel_id) + echomsg row + endfor + endtry + finally + call provider#clear_stderr(channel_id) + endtry + throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_NODE_LOG_FILE') +endfunction + +function! provider#node#Call(method, args) + if s:err != '' + echoerr s:err + return + endif + + if !exists('s:host') + try + let s:host = remote#host#Require('node') + catch + let s:err = v:exception + echohl WarningMsg + echomsg v:exception + echohl None + return + endtry + endif + return call('rpcrequest', insert(insert(a:args, 'node_'.a:method), s:host)) +endfunction + + +let s:err = '' +let s:prog = provider#node#Detect() + +if empty(s:prog) + let s:err = 'Cannot find the "neovim" node package. Try :CheckHealth' +endif + +call remote#host#RegisterPlugin('node-provider', 'node', []) diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index e695fb7df7..dfaab7d246 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -199,3 +199,7 @@ call remote#host#Register('python3', '*', " Ruby call remote#host#Register('ruby', '*.rb', \ function('provider#ruby#Require')) + +" nodejs +call remote#host#Register('node', '*', + \ function('provider#node#Require')) diff --git a/runtime/doc/pi_health.txt b/runtime/doc/pi_health.txt index 99ff519bb9..bb688770fc 100644 --- a/runtime/doc/pi_health.txt +++ b/runtime/doc/pi_health.txt @@ -23,11 +23,11 @@ Commands *health-commands* *:checkhealth* *:CheckHealth* :checkhealth Run all healthchecks. *E5009* - Nvim depends on the |$VIMRUNTIME| environment variable - to find the standard "runtime files" for syntax - highlighting, filetype-specific behavior, and standard - plugins such as :checkhealth. If $VIMRUNTIME is invalid - then those features will not work. + Nvim depends on |$VIMRUNTIME| and 'runtimepath' to find + the standard "runtime files" for syntax highlighting, + filetype-specific behavior, and standard plugins + (including :checkhealth). If the runtime files cannot + be found then those features will not work. :checkhealth {plugins} Run healthcheck(s) for one or more plugins. E.g. to run diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0c0c03c8ed..33bea8ef87 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22883,11 +22883,15 @@ void ex_checkhealth(exarg_T *eap) const char *vimruntime_env = os_getenv("VIMRUNTIME"); if (vimruntime_env == NULL) { EMSG(_("E5009: $VIMRUNTIME is empty or unset")); - return; } else { - EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), os_getenv("VIMRUNTIME")); - return; + bool rtp_ok = NULL != strstr((char *)p_rtp, vimruntime_env); + if (rtp_ok) { + EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env); + } else { + EMSG(_("E5009: Invalid 'runtimepath'")); + } } + return; } size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')"); diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index f6a567a520..758b35796e 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -38,7 +38,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) #endif uvproc->uvopts.exit_cb = exit_cb; uvproc->uvopts.cwd = proc->cwd; - uvproc->uvopts.env = NULL; + uvproc->uvopts.env = NULL; // Inherits the parent (nvim) env. uvproc->uvopts.stdio = uvproc->uvstdio; uvproc->uvopts.stdio_count = 3; uvproc->uvstdio[0].flags = UV_IGNORE; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 8371d3cd48..41e793500a 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -324,6 +324,13 @@ static void process_close(Process *proc) } assert(!proc->closed); proc->closed = true; + + if (proc->detach) { + if (proc->type == kProcessTypeUv) { + uv_unref((uv_handle_t *)&(((LibuvProcess *)proc)->uv)); + } + } + switch (proc->type) { case kProcessTypeUv: libuv_process_close((LibuvProcess *)proc); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 096187b162..7a2b0328df 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3272,6 +3272,12 @@ const char * set_one_cmd_context( case CMD_echoerr: case CMD_call: case CMD_return: + case CMD_cexpr: + case CMD_caddexpr: + case CMD_cgetexpr: + case CMD_lexpr: + case CMD_laddexpr: + case CMD_lgetexpr: set_context_for_expression(xp, (char_u *)arg, ea.cmdidx); break; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 43e7cf457d..9c9ccbca4d 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4147,7 +4147,9 @@ addstar ( || context == EXPAND_OWNSYNTAX || context == EXPAND_FILETYPE || context == EXPAND_PACKADD - || (context == EXPAND_TAGS && fname[0] == '/')) + || ((context == EXPAND_TAGS_LISTFILES + || context == EXPAND_TAGS) + && fname[0] == '/')) retval = vim_strnsave(fname, len); else { new_len = len + 2; /* +2 for '^' at start, NUL at end */ diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c3a0a33378..a7676e88f0 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -304,9 +304,6 @@ readfile ( int msg_save = msg_scroll; linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of // last read was missing the eol - int try_mac; - int try_dos; - int try_unix; int file_rewind = false; int can_retry; linenr_T conv_error = 0; /* line nr with conversion error */ @@ -639,9 +636,9 @@ readfile ( curbuf->b_op_start.lnum = ((from == 0) ? 1 : from); curbuf->b_op_start.col = 0; - try_mac = (vim_strchr(p_ffs, 'm') != NULL); - try_dos = (vim_strchr(p_ffs, 'd') != NULL); - try_unix = (vim_strchr(p_ffs, 'x') != NULL); + int try_mac = (vim_strchr(p_ffs, 'm') != NULL); + int try_dos = (vim_strchr(p_ffs, 'd') != NULL); + int try_unix = (vim_strchr(p_ffs, 'x') != NULL); if (!read_buffer) { int m = msg_scroll; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c0f04f4730..5fc519f822 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -25,6 +25,34 @@ func Test_complete_wildmenu() set nowildmenu endfunc +func Test_expr_completion() + if !(has('cmdline_compl') && has('eval')) + return + endif + for cmd in [ + \ 'let a = ', + \ 'if', + \ 'elseif', + \ 'while', + \ 'for', + \ 'echo', + \ 'echon', + \ 'execute', + \ 'echomsg', + \ 'echoerr', + \ 'call', + \ 'return', + \ 'cexpr', + \ 'caddexpr', + \ 'cgetexpr', + \ 'lexpr', + \ 'laddexpr', + \ 'lgetexpr'] + call feedkeys(":" . cmd . " getl\<Tab>\<Home>\"\<CR>", 'xt') + call assert_equal('"' . cmd . ' getline(', getreg(':')) + endfor +endfunc + func Test_getcompletion() if !has('cmdline_compl') return @@ -268,3 +296,13 @@ func Test_illegal_address2() call delete('Xtest.vim') endfunc +func Test_cmdline_complete_wildoptions() + help + call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') + let a = join(sort(split(@:)),' ') + set wildoptions=tagfile + call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') + let b = join(sort(split(@:)),' ') + call assert_equal(a, b) + bw! +endfunc diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index d0864ec64c..db603610da 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -102,3 +102,107 @@ func Test_CmdUndefined() call assert_fails('Dothat', 'E492:') call assert_equal('yes', g:didnot) endfunc + +func Test_CmdErrors() + call assert_fails('com! docmd :', 'E183:') + call assert_fails('com! \<Tab> :', 'E182:') + call assert_fails('com! _ :', 'E182:') + call assert_fails('com! X :', 'E841:') + call assert_fails('com! - DoCmd :', 'E175:') + call assert_fails('com! -xxx DoCmd :', 'E181:') + call assert_fails('com! -addr DoCmd :', 'E179:') + call assert_fails('com! -complete DoCmd :', 'E179:') + call assert_fails('com! -complete=xxx DoCmd :', 'E180:') + call assert_fails('com! -complete=custom DoCmd :', 'E467:') + call assert_fails('com! -complete=customlist DoCmd :', 'E467:') + call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:') + call assert_fails('com! -nargs=x DoCmd :', 'E176:') + call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:') + call assert_fails('com! -count=x DoCmd :', 'E178:') + call assert_fails('com! -range=x DoCmd :', 'E178:') + + com! -nargs=0 DoCmd : + call assert_fails('DoCmd x', 'E488:') + + com! -nargs=1 DoCmd : + call assert_fails('DoCmd', 'E471:') + + com! -nargs=+ DoCmd : + call assert_fails('DoCmd', 'E471:') + + call assert_fails('com DoCmd :', 'E174:') + comclear + call assert_fails('delcom DoCmd', 'E184:') +endfunc + +func CustomComplete(A, L, P) + return "January\nFebruary\nMars\n" +endfunc + +func CustomCompleteList(A, L, P) + return [ "Monday", "Tuesday", "Wednesday" ] +endfunc + +func Test_CmdCompletion() + call feedkeys(":com -\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=0 -\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -nargs=* + 0 1 ?', @:) + + call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:) + + call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -complete=color command compiler', @:) + + command! DoCmd1 : + command! DoCmd2 : + call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoCmd1 DoCmd2', @:) + + call feedkeys(":DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd1 DoCmd2', @:) + + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoCmd1 DoCmd2', @:) + + delcom DoCmd1 + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoCmd2', @:) + + call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoCmd2', @:) + + delcom DoCmd2 + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoC', @:) + + call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoC', @:) + + com! -complete=behave DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd mswin xterm', @:) + + " This does not work. Why? + "call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx') + "call assert_equal('"DoCmd xterm', @:) + + com! -complete=custom,CustomComplete DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd January February Mars', @:) + + com! -complete=customlist,CustomCompleteList DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd Monday Tuesday Wednesday', @:) + + com! -complete=custom,CustomCompleteList DoCmd : + call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:') + + com! -complete=customlist,CustomComp DoCmd : + call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index ae1c85d8e2..5accf8f1d6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -856,18 +856,18 @@ static const int included_patches[] = { // 251, 250, // 249 NA - // 248, + // 248 NA 247, // 246 NA - // 245, + 245, // 244, 243, - // 242, + 242, // 241 NA // 240 NA // 239 NA // 238, - // 237, + 237, // 236, 235, // 234, @@ -886,7 +886,7 @@ static const int included_patches[] = { // 221 NA // 220, 219, - // 218, + 218, // 217 NA // 216, // 215, diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index b5374210e6..8ee0f258d0 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -16,6 +16,13 @@ describe(':checkhealth', function() eq(false, status) eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) end) + it("detects invalid 'runtimepath'", function() + clear() + command('set runtimepath=bogus') + local status, err = pcall(command, 'checkhealth') + eq(false, status) + eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*')) + end) it("detects invalid $VIM", function() clear() -- Do this after startup, otherwise it just breaks $VIMRUNTIME. |