From d40ca32095c4128152fdf380a3d65946bd080038 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 12 Jul 2017 14:21:24 +0200 Subject: doc: rewrite job-control example Fixes https://github.com/neovim/neovim/issues/7009 --- runtime/doc/job_control.txt | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/job_control.txt b/runtime/doc/job_control.txt index da592d6eb0..edbc1bca81 100644 --- a/runtime/doc/job_control.txt +++ b/runtime/doc/job_control.txt @@ -102,36 +102,30 @@ function. Here's a more object-oriented version of the above: > let Shell = {} - function Shell.on_stdout(job_id, data) dict - call append(line('$'), self.get_name().' stdout: '.join(a:data)) + function Shell.on_stdout(_job_id, data, event) + call append(line('$'), + \ printf('[%s] %s: %s', a:event, self.name, join(a:data[:-2]))) endfunction - function Shell.on_stderr(job_id, data) dict - call append(line('$'), self.get_name().' stderr: '.join(a:data)) - endfunction - - function Shell.on_exit(job_id, data) dict - call append(line('$'), self.get_name().' exited') - endfunction + let Shell.on_stderr = function(Shell.on_stdout) - function Shell.get_name() dict - return 'shell '.self.name + function Shell.on_exit(job_id, _data, event) + let msg = printf('job %d ("%s") finished', a:job_id, self.name) + call append(line('$'), printf('[%s] BOOM!', a:event)) + call append(line('$'), printf('[%s] %s!', a:event, msg)) endfunction - function Shell.new(name, ...) dict - let instance = extend(copy(g:Shell), {'name': a:name}) - let argv = ['bash'] - if a:0 > 0 - let argv += ['-c', a:1] - endif - let instance.id = jobstart(argv, instance) - return instance + function Shell.new(name, cmd) + let object = extend(copy(g:Shell), {'name': a:name}) + let object.cmd = ['sh', '-c', a:cmd] + let object.id = jobstart(object.cmd, object) + $ + return object endfunction - let s1 = Shell.new('1') - let s2 = Shell.new('2', 'for i in {1..10}; do echo hello $i!; sleep 1; done') - - + let instance = Shell.new('bomb', + \ 'for i in $(seq 9 -1 1); do echo $i 1>&$((i % 2 + 1)); sleep 1; done') +< To send data to the job's stdin, one can use the |jobsend()| function, like this: > -- cgit From 72c38b5cd5af8599090311f8d580136feb0646f1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 15 Jul 2017 15:03:41 +0200 Subject: health.vim: validate g:clipboard Closes #7020 Also fix 'iskeyword' setting, which I fumbled in 440133e0d5d576e46bd5ffa555f6a9c534789b48 --- runtime/autoload/health.vim | 3 ++- runtime/autoload/health/provider.vim | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 1d8cae7d19..f875c8b797 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -33,7 +33,8 @@ function! health#check(plugin_names) abort setlocal wrap breakindent setlocal filetype=markdown setlocal conceallevel=2 concealcursor=nc - setlocal keywordprg=:help iskeyword=@,48-57,_,192-255,-,# + setlocal keywordprg=:help + let &l:iskeyword='!-~,^*,^|,^",192-255' call s:enhance_syntax() if empty(healthchecks) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 31a235a397..ec20615f69 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -125,6 +125,10 @@ function! s:check_clipboard() abort call health#report_warn( \ 'No clipboard tool found. Clipboard registers will not work.', \ [':help clipboard']) + elseif exists('g:clipboard') && (type({}) != type(g:clipboard) + \ || !has_key(g:clipboard, 'copy') || !has_key(g:clipboard, 'paste')) + call health#report_error( + \ 'g:clipboard exists but is malformed. It must be a dictionary with the keys documented at :help g:clipboard') else call health#report_ok('Clipboard tool found: '. clipboard_tool) endif -- cgit From d8fe63199f10c944312e802010bec13b5950120a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 15 Jul 2017 18:13:49 +0200 Subject: intro: change byline to "by al." (#6984) Several people have suggested that the "by Bram" byline is misleading, it implies that Bram is actively involved with the project. Up to now we left it as an homage. Bram agreed that it is misleading, and suggested a mention somewhere other than the intro. --- runtime/doc/intro.txt | 3 +-- runtime/doc/nvim.txt | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index 88d04aa76b..b9cc94ce5f 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -249,8 +249,7 @@ Vi "the original". Without further remarks this is the version of Vi that appeared in Sun OS 4.x. ":version" returns "Version 3.7, 6/7/85". Sometimes other versions are referred to. Only runs under Unix. Source code only available with a - license. More information on Vi can be found through: - http://vi-editor.org [doesn't currently work...] + license. *Nvi* Nvi The "New" Vi. The version of Vi that comes with BSD 4.4 and FreeBSD. Very good compatibility with the original Vi, with a few extensions. diff --git a/runtime/doc/nvim.txt b/runtime/doc/nvim.txt index 29059f83d9..f3f4305ad5 100644 --- a/runtime/doc/nvim.txt +++ b/runtime/doc/nvim.txt @@ -6,6 +6,8 @@ Nvim *nvim* *nvim-intro* +Nvim is based on Vim by Bram Moolenaar. + If you are new to Vim see |help.txt|, or type ":Tutor". If you already use Vim see |nvim-from-vim| for a quickstart. -- cgit From 4dee942e732d41ad62b732c0a39719d9405bc928 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 15 Jul 2017 14:51:51 -0400 Subject: provider/clipboard.vim: capture/display errors (#6684) TODO: handle errors in the `get`. systemlist() should take an options dictionary like jobstart(), which may specify a stderr handler. References #6565 --- runtime/autoload/provider/clipboard.vim | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index a67681d28e..47f4271091 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -137,16 +137,24 @@ function! s:clipboard.set(lines, regtype, reg) abort let argv = split(s:copy[a:reg], " ") let selection.detach = s:cache_enabled let selection.cwd = "/" + call extend(selection, { + \ 'on_stdout': function('s:set_errhandler'), + \ 'on_stderr': function('s:set_errhandler'), + \ }) let jobid = jobstart(argv, selection) - if jobid <= 0 + if jobid > 0 + call jobsend(jobid, a:lines) + call jobclose(jobid, 'stdin') + let selection.owner = jobid + endif +endfunction + +function! s:set_errhandler(job_id, data, event) abort + if a:job_id <= 0 echohl WarningMsg - echo "clipboard: error when invoking provider" + echo 'clipboard: error when invoking provider: ' . join(a:data) echohl None - return 0 endif - call jobsend(jobid, a:lines) - call jobclose(jobid, 'stdin') - let selection.owner = jobid endfunction function! provider#clipboard#Call(method, args) abort -- cgit