go-lang-plugin-org / go-lang-idea-plugin

Google Go language IDE built using the IntelliJ Platform
https://plugins.jetbrains.com/plugin/5047
Other
4.56k stars 571 forks source link

Formatter doesn't follow the same rules as gofmt or goimports #1215

Open dlsniper opened 9 years ago

dlsniper commented 9 years ago

The formatting in IDEA is very different than the one from gofmt (or goimports).

I know this is a pretty generic ticket so let me know how should I best add information to it. In 0.9.x branch there's a bunch of tests that should cover the source code formatting, and that's a very good start for it and Mihai started working on a new formatting engine a while ago, which can be found here: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/tree/formatter_work

Since the go community is very keen on having all projects respecting gofmt, this should be a must for the initial stable release of the plugin.

Alternatively, integration with gofmt or goimports like we have for 0.9.16 could be done, where we execute gofmt/goimports on save, which could be good enough to start with, even if it's against the way IDEA should handle the issue.

Thanks.

ignatov commented 9 years ago

As a temporary workaround you can use go fmt as an external formatter as well via Code > Go fmt file/project actions. Also you can enable this option for every commit: screenshot 2015-02-01 14 29 20

dlsniper commented 9 years ago

I haven't noticed those options and I'm using git from command line. Thanks.

kokizzu commented 9 years ago

+1 :+1: https://stackoverflow.com/questions/29029258/setting-specific-macro-only-run-for-certain-file-extension-on-intellij

jaytaylor commented 8 years ago

@kokizzu That StackOverflow link redirects back to a GH issue: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/issues/1324#issuecomment-75263115

Hoping this saves some others from having to do the roundabout trip :)

bits01 commented 8 years ago

Using the nightly plugin but the menus for Go fmt or Goimports on file are disabled even though I'm editing a .go file and also have goimports installed, in the PATH and working fine from cmd line, only the one for the project is enabled. Any ideas? There must be some setting that I don't have right. image

zolotov commented 8 years ago

@bits01 please file a separate issue with more details (https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/CONTRIBUTING.md#reporting-errors)

dlsniper commented 8 years ago

The plugin can't detect goimports in your GOPATH/bin/goimports. Can you please open an issue and share a screenshot of your Settings -> Languages & Frameworks -> Go -> Go libraries. Also see what @zolotov just linked. Thanks