Questions tagged [job-control]
The job-control tag has no usage guidance.
25
questions
7
votes
1
answer
1k
views
prevent line wrap in terminal buffer
I can easily see the output of a command in a split using vim's terminal
For example, I use :vertical terminal make re a lot.
This example is also stated in the help (h :terminal):
Or to run build ...
6
votes
2
answers
4k
views
How to start an async function in Vim 8?
I've known that Vim 8 provides us an async mechanism job_start so that we can start a command asynchronously and get its return with the help of channel.
However, it seems that job_start can only ...
6
votes
1
answer
1k
views
job_start() command only works with seemingly random job options
I am getting some unexpected behavior when trying to run the zip shell command using Vim's job_start().
As an example, suppose I have two images (im1.png and im2.jpg) in the directory /home/username/...
4
votes
1
answer
2k
views
How do I get the output of a vim 8.0 job?
I wanted to try vim 8.0's new job start feature with a simple "hello world" style example. I tried:
:let job = job_start('ls -alh')
but there is no output. I tried
echo job_info(job)
and that ...
4
votes
0
answers
130
views
Why would job_start()'s close_cb sometimes not be called?
I have a job_start() call like this:
let options = {
\ 'stdoutbuffer': [],
\ 'handler': a:handler,
\ }
let command = s:build_command(a:cmd)
let s:job = job_start(command, {
\ '...
3
votes
1
answer
317
views
Job continuously outputting to Vim buffer
I have a job that produces output continually. I want to write this output to a Vim buffer. I start it with:
let job = job_start(cmd, { 'out_io': 'buffer', 'out_name': 'joboutput' })
But I can't see ...
3
votes
1
answer
1k
views
Vim immediately sent to background
Whenever I call Vim from the CLI, either to edit a file (vim idk.tex) or without arguments, or run a command (vim +help), it gets sent to the background, as if I had pressed Ctrl+Z.
In order to use ...
3
votes
0
answers
119
views
How to emulate vim job out_io buffer with neovim?
I'd like to make a plugin with functionality that is similar to https://github.com/ramele/agrep and grep-edit in emacs. That is get search results from ag or some other tool that supports multiline ...
2
votes
1
answer
830
views
What is the proper way to use the async mechanism: timer_start
I just started to use Vim 8 and I'm trying to figure out how to use the async mechanism: timer_start.
As my understanding, timer_start allows us to run a job asynchronously and repeatly.
I have two ...
2
votes
1
answer
592
views
Vim Script: How to pass Varargs to a lambda in timer_start
I'm configuring my vim with Vim Script.
I have set my own custom grep function as below:
function! CustomGrepCore(...)
if a:0 == 0
" do something
else if a:0 == 1
" ...
2
votes
1
answer
868
views
Neovim Jobstart(), not receiving STDOUT sometimes (if async I think)
Working Base Test
Working on a plugin, and it wasnt working on windows, so I reduced it to this test scenario:
function! myautoload#OnStdout(job_id, data, event)
for line in a:data
echom ...
2
votes
1
answer
1k
views
How do you send vim to the background from a terminal window?
I just learned that Vim has the :terminal command, which opens a window with a terminal session inside. Previously, my normal workflow was to launch vim from my terminal and use job control to get in ...
2
votes
1
answer
54
views
Why does ch_evalraw() evaluate to my message instead of the response?
I am trying to learn about jobs and channels on Vim (on Windows), and I am using the following sequence as an example:
let job = job_start("cmd")
let channel = job_getchannel(job)
let ...
1
vote
2
answers
556
views
Run :cwindow after :Neomake finishes
How do I attach a callback to :NeomakeProject so that :cwindow is executed after compilation finishes?
i.e. I'm too lazy and want everything (open the error list) to happen automatically. (currently ...
1
vote
1
answer
166
views
How to use JSON API to send messages from terminal to vim?
In terminal.txt, there is description about terminal-api, but it seems not to give a example to show how the message is send from terminal to vim function Tapi_..., is there some examples for the ...
1
vote
1
answer
292
views
How can I set the working directory for only the job_start() process?
I would like to set the working directory for the process started with job_start().
The only way I know how to do this is to change Vim's current working directory before calling job_start(), and ...
1
vote
1
answer
91
views
keep contents of nofile buffer
My plugin creates new buffer, sets buffer type to nofile and fills it with text via job_start with out_io=buffer. Simplified code:
enew
setl bt=nofile
...
call job_start(cmd, {'out_io': 'buffer', '...
1
vote
0
answers
352
views
How to flush job output in vim8?
Trying to do something with job output in exit_cb or close_cb, but it's all buffered, how to flush it. e.g.:
function! s:exit_cb(job, status)
echom getbufline(s:bufnr, '$')
endfunction
function! s:...
1
vote
0
answers
122
views
neovim: exit code for jobs terminated by jobstop
When I call jobstop on a running script waiting for input, the on_exit callback is invoked. But the exit code is always 0.
Is this the correct behavior?
According to :h jobstop it should be killed ...
1
vote
1
answer
142
views
jobsend sends no data even though return code is 1?
So I am trying to send some json text to a python script with jobsend in neovim like this:
let l:json_msg = json_encode(a:msg)
call jobsend(s:vimwatcher_job, l:json_msg)
If i echo l:json_msg I can ...
0
votes
1
answer
186
views
How to pass a parameter to a function called from an on_exit event of an asynchronous task
Imagine the following asynchronous job to convert a given file to odt :
let mdfile = 'testfile.md'
call jobstart (['bash', '-c', 'pandoc ' . mdfile . ' -s -f markdown -o test.odt'], {'on_exit': '...
0
votes
0
answers
26
views
What's the usage of jobresize?
As title. I'm learning Neovim's terminal-emulator related API. To explain the problem I need to show you the code first. I have a Lua script like this:
local win = vim.api.nvim_get_current_win()
local ...
0
votes
1
answer
36
views
Help in troubleshooting strange behavior when resuming Vim from background
Latest update
I start to think that the problem is not due to Vim in the first place. See this.
Previous update
I think I've almost tracked it down. The issue seems to be due to either command-t or ...
0
votes
0
answers
220
views
How to set up a buffer to receive command output
In my $VIMRC, I would like to
autocmd BufWinEnter *.ly call s:BufWinEnterLY()
autocmd TextChanged *.ly call s:TextChangedLY()
autocmd BufUnload *.ly call s:BufUnloadLY()
I want s:BufWinEnterLY() to ...
0
votes
0
answers
276
views
Make vim commands be executed once a job on a terminal buffer has finished
The context
I've the following mapping in ~/.vim/ftplugin/cpp/mappings.vim. What this mapping does is to compile an arbitrary C++ file and open two windows (a) and (b). (a) shows the output of the ...