-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unify async job handling #1864
unify async job handling #1864
Conversation
Remove go#jobcontrol#RemoveHandler, because it is unused.
Remove the desc argument from go#jobcontrol#Spawn, because it is unused.
Set the working directory for Neovim jobs instead of manually changing the directory before starting the job.
autoload/go/job.vim
Outdated
@@ -1,7 +1,18 @@ | |||
" Spawn returns callbacks to be used with job_start. It is abstracted to be | |||
let s:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, this doesn't do what you want. The haslocaldir()
checks if the current window has a local path set already with :lcd
. So evaluating it once here isn't really that useful. You need to evaluate it when using.
We could add a wrapper function in util.vim
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
Rename go#job#Spawn to go#job#Options. Add a new key, cwd, to the return value of go#job#Options so that the working directory for the job can be passed in the job options. Add a new function, go#job#Start, to wrap vim8's job_start function. Eventually, this new function will be used to start Neovim jobs, too, so that vim-go can have an abstraction to start jobs that hides the details of dealing with Neovim and Vim8 job API differences.
* Update the status in vim8 so it can be shown on the statusline.
Add go#job#Spawn, a convenience wrapper around go#job#Options and go#job#Start that brings the vim8 and neovim job abstraction closer together.
PTAL |
@fatih approved the PR in a personal DM. |
Unify how jobs are handled in
autoload/go/job.vim
andautoload/go/jobcontrol.vim
so that there's a single abstraction for async jobs instead of separate abstractions for Vim and Neovim. Unifying the abstractions allows us to provide the same behavior around updating status, writing progress, and handling errors in Vim and Neovim.As part of this work, I was able to refactoring async
go test
jobs to use the abstraction inautoload/go/job.vim
and also enable the tests inautoload/go/test_test.vim
for Neovim.Among other things, this work paves the way to:
job_start
orjobstart
into the abstraction so that there are fewer one offs.job_start
in Vim, but use a synchronous call in Neovim, to use the abstraction instead.Though this PR is relatively large, the commits that make up this change tell a coherent story using small and focused changes; reviewing this PR will be made easier by reviewing each commit individually.