-
-
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
Override the :A command to toggle between go implementation code and test code. #684
Comments
Thanks @peterhellberg for the suggestion. This is a nice feature we can add 👍 |
@fatih Do we ask the author for permission or can we just take it and credit him? |
The only issue on that repo is a question about what license it should have… opened on 24 Jan 2014 I wouldn’t hold my breath for a reply from @benmills, but we should at least try to contact him. |
Alright, whenever you feel is good I can create the PR with the docs and everything. |
Sounds good to me! Thanks for thinking of this @peterhellberg |
Okie, i'll create a PR and stuff. |
@peterhellberg do you really think we need an option to create the test file? Do you you think it should be universally enabled? |
@nhooyr I’d be happy if the test file was automatically created. It might be a good idea to be able to disable that feature using a Edit: And now when I looked at the PR it seems like you already did that :) |
@nhooyr Is your code enabling the traditional commands :A :AV and :AS? (alternate, alternate vsplit and alternate split) |
@peterhellberg oh I didn't know thats a actual thing. I just used :GoAlternate and a bunch of mappings. I can switch it to that but that might cause problems with other peoples mappings (:A is the mapping in fzf.vim for ag). Should I add a switch to turn this on then? |
It's just that the other mappings (GoRun) use the same setup I implemented instead of overriding :A. There is no GoRunVertical, you instead use the mapping (go-run-vertical). And it uses a variable to decide the default way you want it. I mean if you really think its necessary, its not that hard to just add over the current code, its like 3 lines. |
You can also just add this to your .vimrc augroup go
autocmd!
autocmd Filetype go command! -bang A call go#alternate#Switch('edit<bang>')
autocmd Filetype go command! AV call go#alternate#Switch('vsplit')
autocmd Filetype go command! AS call go#alternate#Switch('split')
augroup END |
I’m just so used to using a.vim (and for vim-golang-alternate for go) for so many years now that :A and :AV is lodged in my muscle memory. I can definitely change my .nvimrc if you want to keep the default command as GoAlternate. |
lets wait and see what @fatih thinks. |
I've made some comments to the PR #704 I think we shouldn't create a new file at all but it should be created if a bang |
@peterhellberg it was merged. here are the commands you need to put in your vimrc if you want your alternate commands to work. augroup go
autocmd!
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
augroup END |
@nhooyr I've just added myself for |
Closed as we have this feature now. |
@fatih should I add this to the readme. It sounds like something more suited for it. |
Readme is ok. But also add to the |
Thank you guys! I’ll update my config when I get back to Europe :) |
I’ve now updated my config and this feature works really well, but I get a Is this the intended behavior? |
No, I'll look into it. |
Note that it functions just fine, it is just an unexpected error message (possibly due to the created empty buffer not having a package line) |
Yea I understood. I'm in class atm, i'll look into it at lunch. |
So it only happens in empty buffers? |
@nhooyr Take your time, no stress :) And yes, it only happens when an empty file/buffer is created. |
I'm not stressed, its my way of having fun :P alright thanks. |
|
Yes, and I guess gocode is called when the buffer is switched. Calling |
I don't think that can be fixed then, its a harmless error message though. |
No, unless populating the buffer with I think I found the underlying issue now, and it was that I have |
ah yes, that calls gocode as well. |
Maybe we shouldn't print the |
It might too much of an edge case to really care about? |
I meant, ignore the |
Probably not, but @fatih maybe want to decide on this? |
Yup. but I did find a bug in the implementation of this thanks to you. it doesn't handle empty filenames. |
I’d like vim-go to have the functionality of https://github.com/benmills/vim-golang-alternate and possibly add support for optionally creating missing test files when toggling.
The text was updated successfully, but these errors were encountered: