6

I think I figured this out myself. I believe the problem was that my job was being deleted before the zip command finished. I guess Vim deletes a job object if there are no references to it. So the solution was to turn my job variable into a script-local variable to prevent it from being deleted. So, I changed my line let job = ... to let s:job = .... I ...


5

From discussion in comments I learned that OP has a custom vimgrep call and would like to run it asynchronously. The utility of this is pretty clear, especially if you run a lot of searches that take a while: by moving the execution into a separate/background thread you free up Vim's UI so you can continue working without waiting for the result. As I ...


4

This is almost surely happening because the output from cmd is getting buffered when being sent to a pipe, so until you get enough of it (a few kilobytes), Vim won't really receive any. A very simple fix for this, that will work in most cases, is to have Vim use a pty instead of a pipe to communicate with the external job. The standard library in Linux/Unix ...


4

Neomake runs a user autocmd called NeomakeFinished when it's done. It sets the context variable: g:neomake_hook_context.file_mode. If it's 1 it's using the location list. If you only want it to run when it's finished with a project: autocmd User NeomakeFinished if !g:neomake_hook_context.file_mode | cwindow | endif There is also an option: *g:...


4

I don't know first hand if it works with your fork but the following snippets works perfectly in real Vim: augroup qf autocmd! " automatically open the location/quickfix window after :make, :grep, " :lvimgrep and friends if there are valid locations/errors autocmd QuickFixCmdPost [^l]* cwindow autocmd QuickFixCmdPost l* lwindow ...


4

Vim jobs start with a channel, you can use job-options to redirect output to a buffer. For example: :let job = job_start('ls -alh', {'out_io': 'buffer', 'out_name': 'mybuffer'}) then :sbuf mybuffer to read it. Ref: :h job-start. Escaping issues (dependent on the platform) can be fixed with a list (issue 1539): let args = ['/bin/bash', '-c', cmd]


2

In Build-Tool-Wrapper, I've used sh -c to actually run cd compdir && make args: " the a:cmd is managed elsewhere in the plugin " it may contain many things, usually things like " `cd build/dir && make tgt -j 8 2>&1 | gSTLfilt.pl` if lh#os#OnDOSWindows() && &shell =~ 'cmd' let cmd = &shell . ' /C '.a:cmd else ...


2

I shouldn't have set the shell as interactive. Somehow it pauses the main Vim process. So: set shell=bash\ -i Should be: set shell=bash


2

Have you tried partials? {'on_exit': function('OnEvent', [parameters])} This is what I do in lh-tags+lh-vim-lib to register things like: delete a temporary file and print a finished message on close_cb with vim -- I've never tried to use neovim.


2

This question is largely addressing some follow-up questions OP had in response to an answer I gave to another question that they posted. This one also talks about a solution involving lambda functions and closures that is valid but more complicated than needed for most use cases. For both those reasons I recommend you check out that Q&A first: How to ...


2

Section :help terminal-api includes a thorough description of the API and also an example function: function Tapi_Impression(bufnum, arglist) if len(a:arglist) == 2 echomsg "impression " . a:arglist[0] echomsg "count " . a:arglist[1] endif endfunc Then inside a :term you can call this function by sending a special sequence ...


2

Turned out rg command for some reason behaves a certain way when called from the following: Window cmd bash vim :! Ubuntu jobstart() Differently to when called from Windows jobstart() The solution is simply to define what to search: let cmd = ['rg', '--vimgrep', 'endfunction', './']


1

You also need setl bufhidden=hide to prevent the buffer from getting unloaded when you switch to another buffer. See also :help special-buffers, in particular the entry for "scratch" buffers.


1

Tested on Vim Version: 8.2.1537 Response: A timer's resources will be freed on one of three conditions: the timer_stop() function in Vim is called, invoking it's counterpart stop_timer() in the C source.1 after invoking the callback function, there are no repetitions left for the timer, upon which free_timer() is invoked.2 the timer has encountered an ...


1

Is it possible to call a vim script function with the help of job_start? Not directly. I guess you would need Vim to be multithreaded, which might be possible in the future. In fact I've used the command :vimgrep to make my custom grep. It worked. Now I starts to use vim 8 so I'm thinking if it's possible to make my custom grep async. FWIW, I wrote some ...


1

I came up with a solution using channels, an idea based on Bram's presentation in this video. command! -complete=shellcmd -nargs=+ Shell call s:TmpShellOutput(<q-args>) function! s:TmpShellOutput(cmdline) abort if bufexists('tmplog') " clear buffer content call deletebufline('tmplog', 1, '$') else " create new ...


Only top voted, non community-wiki answers of a minimum length are eligible