Skip to content
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

Neovim integration #607

Merged
merged 39 commits into from
Dec 8, 2015
Merged

Neovim integration #607

merged 39 commits into from
Dec 8, 2015

Conversation

fatih
Copy link
Owner

@fatih fatih commented Nov 20, 2015

This PR is going to add a proper initial Neovim integration (to make use of Neovim's advanced features). Nothing needs to be installed or to be done. The features will be active only if you use vim-go inside Neovim.

Currently implemented features:

  • An async launcher and base foundation was implemented for the go command. This will be used for all upcoming subcommands of the go tool.
  • :GoBuild is now called asynchronously (it doesn't block the UI anymore).
  • A new go#jobcontrol#Statusline() can be used to plug into the statusline. This will show the status of the job running asynchronously
  • :GoRun opens a new vertical terminal and runs the command there. The terminal mode can be changed with g:go_term_mode, which is by default vsplit. Current options are vsplit, split or tab
  • Three new mappings to open :GoRun terminal in different modes: <Plug>(go-run-vertical), <Plug>(go-run-split) and <Plug>(go-run-tab): An example usage:
au FileType go nmap <leader>rt <Plug>(go-run-tab)
au FileType go nmap <Leader>rs <Plug>(go-run-split)
au FileType go nmap <Leader>rv <Plug>(go-run-vertical)
  • We have two settings for terminal sizes: g:go_term_height and g:go_term_width. By default a vertical or horizontal is just split by vim automatically. However with these settings we can for example have a terminal with a smaller height when we split it horizontally.
  • :GoTest, :GoTestFunc and :GoTestCompile opens and runs in a new terminal. The view mode(split,vertical, tab) is defined with g:go_term_mode.
  • If a command inside the term fails (such as go run, go test ...) we parse now the errors and list them inside in a qf window.
  • A g:go_term_enabled setting is added to change the behavior of :GoTest .If set to 1, it opens the test commands inside a terminal, if not it runs them in background just like :GoBuild and displays the result in the statusline
  • The status_line is improved to show the status per package instead of file. Assume you have three files open, all belonging to the same package, if the package build (:GoBuild) is successful, all statusline's will be empty (means SUCCESS), if you it fails all file's statusline will show FAILED.

Please test all features both with Vim and Neovim if you can. Right now documentation, messages and co are just placeholders and will be suited and corrected once it's release ready. Please ask any question. Any feedback is welcome.

@gonzaloserrano
Copy link

I have rebased master with this branch and built a couple of projects serveral times without any issue. Does it happen building any codebase?

@fatih
Copy link
Owner Author

fatih commented Nov 22, 2015

@gonzaloserrano yeah it should just work like the previous :GoBuild. Also if you add the function go#jobcontrol#Statusline() to your statusline, you'll se the building state in your statusline. Example:

image 2015-11-22 at 4 50 53 pm

@fatih fatih changed the title Async GoBuild using Neovim Jobs Neovim integration Nov 22, 2015
@gonzaloserrano
Copy link

Yep it does, what i was asking is what kind of code are you trying to build, since i'm not able to reproduce the crash. Maybe you can post here a repo or something to build that made it crash?

@fatih
Copy link
Owner Author

fatih commented Nov 22, 2015

@gonzaloserrano change something (like remove the func statement of a function), do NOT save the file and hit :GoBuild. Somehow together with :GoFmt it crashes Neovim occasionally.

Another case might be: Call :GoBuild, change something (like removing a func statement`) and save the file (while the package is still being built). This also crashes it (again sometimes).

I still couldn't find the a case which I can use to reproduce the crash.

@fatih
Copy link
Owner Author

fatih commented Nov 22, 2015

:GoRun demo:

gorun

@marcosnils
Copy link

@fatih simply amazing!

@iamralch
Copy link

@fatih The new improvements are great. However, if you have an application that is waiting for stdin the vim-go sets arbitrary input values automatically. If you try to run :Gorun for this code snippet, you will understand what I mean. Thanks!

PS. I am not sure that I had to open new issue

@fatih
Copy link
Owner Author

fatih commented Nov 23, 2015

@Svett thanks for the input. Yes please do not open issue, just write it here until this is ready to go. As I know neovim opens a real terminal, so stdin shouldn't be affected by anything else. I'm going to look at it, thanks!

@iamralch
Copy link

@fatih my fault this happens with the latest version. I didn't realise that this changes are not merged yet. It works fine with the changes from these pull request.

@fatih
Copy link
Owner Author

fatih commented Nov 23, 2015

@Svett awesome :) I've just tried and it works perfectly: http://cl.ly/1d1j1I2s031l

@wavded
Copy link

wavded commented Nov 23, 2015

@fatih this looks exciting, thanks for working on it, are you planning on running :GoTest async as well?

@fatih
Copy link
Owner Author

fatih commented Nov 23, 2015

@wavded yes! One by one ;) I'm working on my spare times and this needs to be rock solid for both Vim and Neovim (it shouldn't break anything on Vim for example). For now it would be very helpful for me if people could test and report back any kind of errors to this issue.

@divan
Copy link

divan commented Nov 23, 2015

Nice! It even works with TermUI based programs.
captura de pantalla 2015-11-23 a las 16 46 03

@wavded
Copy link

wavded commented Nov 23, 2015

Sweet, am pulling from this branch now and will report any issues.

@fatih
Copy link
Owner Author

fatih commented Dec 2, 2015

@wavded I've fixed your problem. Please pull and try again.

@wavded
Copy link

wavded commented Dec 2, 2015

Buffer isn't cleared out now which is good and error doesn't show up when successful which is also good. Now I get errors when the build fails:

screen shot 2015-12-02 at 3 57 34 pm

@fatih
Copy link
Owner Author

fatih commented Dec 2, 2015

How is your go output from the terminal? Pushing a fix now.

@wavded
Copy link

wavded commented Dec 3, 2015

I wonder if its junk in my output. I get this on a run of go test from the terminal:

[GIN] 2015/12/02 - 20:02:49 | 200 |      11.727µs |  |   GET     /
--- FAIL: TestWelcome (0.01s)
        Error Trace:    routes_test.go:30
    Error:      Not equal: 200 (expected)
                    != 400 (actual)

[GIN] 2015/12/02 - 20:02:49 | 200 |   33.687223ms |  |   GET     /mv
Subscription: subscribe phonedm 1
[GIN] 2015/12/02 - 20:02:49 | 200 |   13.908545ms |  |   GET     /d/fastundercar-stockton-staging/31/45.6353/-90.34321/0.34/23/1
Received: phonedm {"arrived":true,"context":"fastundercar-stockton-staging","currentSpeed":0.34,"driverId":31,"driverLat":-90.34321,"driverLon":45.6353,"lastReportTime":1449108169534,"routeStopId":23}
Error #01: missing form body
Error #02: Invalid chat data sent
[GIN] 2015/12/02 - 20:02:49 | 400 |          45µs |  |   POST    /chat
Error #01: Invalid chat data sent
Error #01: No context provided
[GIN] 2015/12/02 - 20:02:49 | 400 |         141µs |  |   POST    /chat
Error #01: No context provided
Subscription: subscribe phonedm-chat 1
[GIN] 2015/12/02 - 20:02:49 | 200 |   13.822976ms |  |   POST    /chat
Received: phonedm-chat {"context":"fastundercar-stockton-staging","message":{}}
FAIL
exit status 1
FAIL    bitbucket.org/applieddataconsultants/extra-phone-dm 0.192s

I went back to the master branch and I get the same extra stuff in the quicklist.

@wavded
Copy link

wavded commented Dec 3, 2015

An update. Setting log.SetOutput(ioutil.Discard) and using standard go t.Error and friends instead of testify cleared up my output and seems to work good now.

@fatih
Copy link
Owner Author

fatih commented Dec 3, 2015

That's normal, we don't support testify. In the future we might support custom error format, but not now.

@fatih fatih mentioned this pull request Dec 4, 2015
@wavded
Copy link

wavded commented Dec 4, 2015

@fatih, when running :GoTest and a failure occurs the location list shows (which is expected) but when the tests pass again, the location list still shows. :GoTest (sync version, on master) removes that location list. Still possible?

@fatih
Copy link
Owner Author

fatih commented Dec 8, 2015

@fatih, when running :GoTest and a failure occurs the location list shows (which is expected) but when the tests pass again, the location list still shows. :GoTest (sync version, on master) removes that location list. Still possible?

Let me check it.

@fatih
Copy link
Owner Author

fatih commented Dec 8, 2015

@wavded fixed!

@fatih fatih mentioned this pull request Dec 8, 2015
@fatih
Copy link
Owner Author

fatih commented Dec 8, 2015

I'm going to merge this today. This also includes several other fixes for the main branch.

I'm going to work on other improvements (such as async :GoFmt ...) afterwards. This is getting bigger and bigger, and I don't like big PR's :)

@igungor
Copy link

igungor commented Dec 8, 2015

Yay :)

@wavded
Copy link

wavded commented Dec 8, 2015

Thanks @fatih !

fatih added a commit that referenced this pull request Dec 8, 2015
@fatih fatih merged commit 83e4afc into master Dec 8, 2015
@fatih fatih deleted the nvim branch December 8, 2015 16:16
@svanharmelen
Copy link
Contributor

🎉 👍

Very nice!!

@philk
Copy link

philk commented Dec 11, 2015

This is so awesome 🎉.

I just hacked the statusline update into Airline for anyone else that's interested (fair warning I'm super bad at vim and very well could be breaking something 😁 ) Note also that I don't use syntastic and this will remove it from the default warning section:

function! VimGoAirline(...)
  if &filetype == 'go'
    let w:airline_section_warning = airline#section#create(['whitespace', '%{go#jobcontrol#Statusline()}'])
  endif
endfunction
call airline#add_statusline_func('VimGoAirline')

@marcosnils
Copy link

Can someone recommend a good alternative for neocomplete to use with neo-vim?

Thx!.

@apriendeau
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet