govim / govim

govim is a Go development plugin for Vim8, written in Go
BSD 3-Clause "New" or "Revised" License
872 stars 62 forks source link

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

Open cespare opened 5 years ago

cespare commented 5 years ago

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:

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.

tjcain commented 4 years ago

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.

cespare commented 4 years ago

Nice! Looks good.

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

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

tjcain commented 4 years ago

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

myitcv commented 4 years ago

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

tjcain commented 4 years ago

Will do 👍