Page 1 of 1

Format Go files on saving

Posted: 08.06.2022 13:07
by indgy
I am new to CudaText, coming from TextMate on Mac.

In TextMate when I save a file I can run a shell command which can optionally replace the contents of the current file.

This is useful for code formatting and automatically adding code where needed e.g. Go Imports can be automatically added.

I have had a look at 'runners' and 'formatters' but I can't seem to get a formatter for Go working.

Can anyone point me in the right direction?

Thanks

Posted: 09.06.2022 06:58
by main Alexey
The CudaFormatter plugin + its formatters.
https://wiki.freepascal.org/CudaText_pl ... aFormatter

Call menu item "Options/ Settings-plugins/ CudaFormatter/ Configure on_save".

You tried the formatter for Go? I don't see the formatters for Go in addons-manager, so what did you try? tells us by steps. where did you get the formatter?

Posted: 09.06.2022 08:26
by main Alexey
I just published the formatter for Go (using 'gofmt'). Pls try. In addons-manager.
In the menu item "Options / settings-plugins / CudaFormatter / Configure on_save" set the label for this formatter.

Posted: 09.06.2022 11:06
by main Alexey
Updated the formatter-package.
Supported the following formatters from this list:
https://github.com/life4/awesome-go-code-formatters
They all must be found in PATH.

- gofmt
- goimports
- goreturns

you can tell which formatters you need and miss.