diff --git a/.gitignore b/.gitignore index b1b709c..aa06818 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ /.antlr /scadformat /scadformat.exe + +go/* +go + +venv +venv/* +go1.22.2.linux-amd64.tar.gz diff --git a/README.md b/README.md index fc54540..bf7cce5 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ SCADFormat is a source code formatter / beautifier for [OpenSCAD](https://opensc SCADFormat is, shall we say, "opinionated" in the way that it formats OpenSCAD code. In other words, there are no configuration options that alter the way code is formatted. That's not because I feel strongly that OpenSCAD code should be formatted a certain way - it's just that I haven't had time to implement options. -## Installation +## Changes in this fork -The easiest way to install is to download one of the pre-built binary releases: +Compared to hugheaves/scadformat not much has changed. All I did was increase the indent size from 2 to 4, since that's also my personal preference as well as the VSCode extension I use has a hard time with 2 indents. Other than that, I also removed the creation of the backup file (files suffixed with a date and `.scadbak`), as my directory got cluttered with old backups quite quickly, even though I had no use for those files. -https://github.com/hugheaves/scadformat/releases +## Installation -Download the zip file for your operating system (windows.zip, linux,zip, macos.zip) and extract the contents. +The easiest way to install is to download one of the pre-built binary releases. I can only provide a Linux x64 build tho. Check out the release page for that. ## Usage diff --git a/internal/formatter/formatsettings.go b/internal/formatter/formatsettings.go index 6f0894a..e7f7a95 100644 --- a/internal/formatter/formatsettings.go +++ b/internal/formatter/formatsettings.go @@ -30,6 +30,6 @@ func DefaultFormatSettings(fileName string) *FormatSettings { return &FormatSettings{ fileName: fileName, maxLineLen: math.MaxInt, - indentSize: 2, + indentSize: 4, } } diff --git a/internal/formatter/formatter.go b/internal/formatter/formatter.go index 85101a0..aa685d9 100644 --- a/internal/formatter/formatter.go +++ b/internal/formatter/formatter.go @@ -23,9 +23,6 @@ import ( "fmt" "io" "os" - "path/filepath" - "strings" - "time" "github.com/antlr4-go/antlr/v4" "github.com/hugheaves/scadformat/internal/parser" @@ -69,13 +66,13 @@ func (f *Formatter) formatFile() error { return err } - timeStamp := time.Now().Format("2006-01-02_15-04-05") - backupFileName := strings.TrimSuffix(f.settings.fileName, filepath.Ext(f.settings.fileName)) + "_" + timeStamp + ".scadbak" - err = os.WriteFile(backupFileName, input, 0666) - if err != nil { - zap.S().Errorf("failed to write file %s: %s", backupFileName, err) - return err - } + // timeStamp := time.Now().Format("2006-01-02_15-04-05") + // backupFileName := strings.TrimSuffix(f.settings.fileName, filepath.Ext(f.settings.fileName)) + "_" + timeStamp + ".scadbak" + // err = os.WriteFile(backupFileName, input, 0666) + // if err != nil { + // zap.S().Errorf("failed to write file %s: %s", backupFileName, err) + // return err + // } err = os.WriteFile(f.settings.fileName, output, 0666) if err != nil {