govim icon indicating copy to clipboard operation
govim copied to clipboard

cmd/govim: support running 'go build' and 'go test'

Open cespare opened this issue 5 years ago • 5 comments

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.

cespare avatar Aug 09 '19 02:08 cespare

I have been playing around with a GOVIMTest command this evening, is the below the kind of functionality required?

Tests pass: govim_test_pass

Tests fail: govim_test_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.

tjcain avatar Mar 30 '20 18:03 tjcain

Nice! Looks good.

[...] could also implement #441 in the same PR.

That's this PR. Did you mean to refer to another one?

cespare avatar Mar 30 '20 21:03 cespare

Ah, yes - sorry I meant to link in #442 !

tjcain avatar Mar 30 '20 21:03 tjcain

@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.

myitcv avatar Apr 01 '20 09:04 myitcv

Will do 👍

tjcain avatar Apr 01 '20 11:04 tjcain