govim
govim copied to clipboard
cmd/govim: support running 'go build' and 'go test'
In migrating from vim-go, one thing I miss are the :GoBuild / :GoTest commands. I had these bound to shortcuts and used them a lot.
I'm still experimenting to see if GOVIMQuickfixDiagnostics suffices instead of using :GoBuild (looks like maybe?), but either way I'd still like to have :GoTest.
Basically, the flow would be:
- Find the package the current file is in
- Run
go test
from that package dir - Report failures in the quickfix window
This makes it easy to run the tests and jump directly to failures within vim.
An equivalent of vim-go's :GoTestFunc would be a great bonus feature. This figures out the test function that the cursor is in and then runs go test -run '^TestSomeFunction$'
. This is handy if you have a lot of failures or if the tests are slow and you want to quickly run a single test.
I have been playing around with a GOVIMTest
command this evening, is the below the kind of functionality required?
Tests pass:
Tests fail:
If so I am happy to clean up my hacking around and take this issue on, could also implement #441 in the same PR.
Nice! Looks good.
[...] could also implement #441 in the same PR.
That's this PR. Did you mean to refer to another one?
Ah, yes - sorry I meant to link in #442 !
@tjcain very happy for you to work on this.
One thing I'd encourage you to look at is the code lens feature of LSP. gopls
has some support for this, so I'd want to be leverage that as far as possible.
Will do 👍