bitst0rm-pub / Formatter

🧜‍♀️ A Sublime Text plugin to beautify and minify source code: CSS, SCSS, Sass, HTML, XML, SVG,JS,JavaScript, JSON, GraphQL, Markdown, TypeScript, Vue, Lua, YAML, Go, Perl, PHP, Python, Ruby, Rust, Haskell, Dart, Swift, Crystal, Bash, Shell, SQL, CSV, C, C++, C#, Objective-C, D, Java, Pawn, Julia, Proto, LaTeX, D2, Graphviz, Mermaid, PlantUML, etc
Other
100 stars 20 forks source link

[BUG] Doesn't seem to work for ST4 #43

Closed smac89 closed 8 months ago

smac89 commented 8 months ago

I added the following file:

#!/bin/bash

for a in {1..3};   do
    echo     "$a"
done

I have the following configuration for the formatter:

// Do NOT edit anything in the left-hand pane.
// Pick up items you need, just make sure to maintain the structure.
{
    "debug": true,
    "open_console_on_failure": true,
    "show_statusbar": true,
    "formatters": {
        "shellcheck": {
            "disable": true,
        },
        "shfmtmin": {
            "disable": true,
        },
        "shfmt": {
            "executable_path": "/usr/bin/shfmt",
            "format_on_save": true,
            "format_on_paste": false
        }
    }
}

When I save the file, nothing happens: no errors, no console output.

Whereas if I run shfmt -i 2 /tmp/foo.sh, the output is:

#!/bin/bash

for a in {1..3}; do
  echo "$a"
done
bitst0rm commented 8 months ago

shfmt has not been activated in your config therefore nothing happens: no errors, no console output. Using your modified config with"disable": false, option:

// Do NOT edit anything in the left-hand pane.
// Pick up items you need, just make sure to maintain the structure.
{
    "debug": true,
    "open_console_on_failure": true,
    "show_statusbar": true,
    "formatters": {
        "shellcheck": {
            "disable": true,
        },
        "shfmtmin": {
            "disable": true,
        },
        "shfmt": {
            "disable": false,
            "syntaxes": ["bash"],
            "executable_path": "/Users/admin/go/bin/shfmt",
            //"config_path": {
            //    "default": "${packages}/User/formatter.assets/config/shfmt_rc.json"
            //},
            "args": ["-i", 2],
            "format_on_save": true,
            "format_on_paste": false
        }
    }
}
▋[Formatter](MainThread:formatter_shfmt.py#L52): [DEBUG] Current arguments: ['/Users/admin/go/bin/shfmt', '-i', '2', '-']
▋[Formatter](MainThread:main.py#L415): [DEBUG] Formatting successful. 🎉😃🍰
smac89 commented 8 months ago

Ok that's a bit confusing. I thought "disable": false was already the default. Since it was listed as part of the default settings for the plugin. If all plugins are disabled by default, maybe the default settings should say that ("disable": true or better "enable": false)

bitst0rm commented 8 months ago

@smac89 I have released 1.1.5 some days ago, with this release all plugins are disabled by default ("disable": true). I will add some notes to the readme and the settings file, which have been removed sometimes ago.