Format Go files on saving

Plugins for SynWrite and CudaText...
Post Reply
indgy
Posts: 1
Joined: 08.06.2022 12:59

Format Go files on saving

Post 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
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post 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?
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post 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.
main Alexey
Posts: 2323
Joined: 25.08.2021 18:15

Post 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.
Post Reply