magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.02k stars 250 forks source link

GoLand code completion #294

Open guumaster opened 4 years ago

guumaster commented 4 years ago

Hi, is there a way to enable code completion in JetBrain's GoLand IDE?

I have a magefile.go and also the project has a go.mod file. I can't get the IntelliSense to autocomplete any of the magefile/mage methods.

Anyone knows if it is possible?

Thanks

natefinch commented 4 years ago

If you're trying to autocomplete inside the magefile itself... you probably have to tell your editor to include the mage build tag in its compilation to get auto-complete. This is an unfortunate problem with most IDE's autocomplete in that if the current file has a build tag, they won't autocomplete.

ghostsquad commented 4 years ago

I just ran into the same problem. It seems that the only solution is to add mage to the custom tags as described here:

https://www.jetbrains.com/help/go/configuring-build-constraints-and-vendoring.html#

It looks like doing this though means you also end up getting autocompletion on mage exports in non-mage .go files.

I did a little bit of research, and I wasn't able to find a way to quickly change between build tags. There might be an open issue for Jetbrains GoLand to do this.

guumaster commented 4 years ago

Thanks @ghostsquad! It works perfectly! I'm ok with completion on other files if that mean that I can create mage files with autocompletion help.

@natefinch is it ok to add this info somewhere in the docs? Which section would be a good place to make a PR?