Add async support for neovim#81
Add async support for neovim#81mitermayer merged 1 commit intoprettier:feature/adding-support-for-neovim-asyncfrom
Conversation
|
Thanks so much for that @chemzqm !!! Super happy to see this! |
|
|
||
| function! s:Prettier_Job_Nvim_Exit(status, info, out, err) | ||
| if a:status != 0 | ||
| echoerr join(a:err, "\n") |
There was a problem hiding this comment.
| let l:dict = { | ||
| \ 'start': a:startSelection - 1, | ||
| \ 'end': a:endSelection, | ||
| \ 'buf_nr': bufnr('%'), |
There was a problem hiding this comment.
can we store the buffer name before we start the job call ? If we don't do that the user can save the file and move to a different buffer and get its contents overwritten with the output of this job execution, refer to : #62
| \} | ||
| let l:out = [] | ||
| let l:err = [] | ||
|
|
There was a problem hiding this comment.
can we shield this with a flag to make sure that only a single job can be running at a time similar how we do for vim8 async ?
if s:prettier_job_running != 1
let s:prettier_job_running = 1
let l:job = jobstart(l:async_cmd, {
\ 'on_stdout': {job_id, data, event -> extend(l:out, data)},
\ 'on_stderr': {job_id, data, event -> extend(l:err, data)},
\ 'on_exit': {job_id, status, event -> s:Prettier_Job_Nvim_Exit(status, l:dict, l:out, l:err)},
\ })
call jobsend(l:job, l:lines)
call jobclose(l:job, 'stdin')
endif| endfunction | ||
|
|
||
| function! s:Prettier_Job_Nvim_Exit(status, info, out, err) | ||
| if a:status != 0 |
There was a problem hiding this comment.
Assuming we did add the running flag here we unset it
function! s:Prettier_Job_Nvim_Exit(status, info, out, err)
let s:prettier_job_running = 0
if a:status != 0| if len(a:out) == 0 | return | endif | ||
|
|
||
| let l:last = a:out[len(a:out) - 1] | ||
| let l:out = l:last == '' ? a:out[0:len(a:out) - 2] : a:out |
There was a problem hiding this comment.
what is this line doing ? could we add some comments before it ?
|
Once again thank you so much for submitting this PR, it has been one of the things I wanted to do before 1.0!! wohooo. Added some comments to it, havent tested it yet but it looks good! |
|
I have been pretty busy lately but will get back in this PR next week and make sure it will get merged in some form! |
|
Hey @mitermayer! Could this get merged in soon? |
|
Sorry guys, will get into this ASAP, added some comments in the PR that was hoping to get addressed, but if they don’t I will address myself |
|
@mitermayer That's alright! Whenever works! :) |
|
Merged this on branch feature/adding-support-for-neovim-async where I will be addressing some of the previous comments in order to merge it to master. Thanks a lot for the work on this PR |
|
Thanks @mitermayer! |

Using job control for async job when using neovim.