mihai-vlc / sublime-jsfmt

jsfmt plugin for Sublime Text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indent value in jsfmt.sublime-settings (User and/or Default) has no effect

jessemillar opened this issue · comments

No matter what I do, the character(s) set in the indent value of the Sublime settings doesn't do anything. As soon as I made a .jsfmtrc in my home directory, it started applying changes to indention style properly.

Current jsfmt.sublime-settings:

{
    // autoformat on save
    "autoformat": true,

    // array of extensions for autoformat
    "extensions": ["js", "sublime-settings"],

    // options for jsfmt
    "options": {
        "preset": "jquery",
        "indent": {
            "value": "    "
        },
        // plugins included
        "plugins": [
            "esformatter-quotes",
            "esformatter-semicolons",
            "esformatter-braces",
            "esformatter-dot-notation"
        ]
    },
    "options-JSON": {
        "plugins": [
            "esformatter-quotes"
        ],
        "quotes": {
            "type": "double"
        }
    },
    "node-path": "node",
    "alert-errors": false,
    "ignore-selection": true
}

Current .jsfmtrc (which causes four space indents)

{
  "preset": "jquery",
    "indent": {
        "value": "    "
    }
}

The configuration looks good to me so it should work fine with the User/jsfmt.sublime-settings alone.
Do other settings from the jsfmt configuration file apply ?
Edit: Also please make sure that you are editing the file settings - User file and not the default one. (http://puu.sh/m5ICG/d1198c80f7.png)

All other settings from the user configuration apply (I am modifying the user one).

Just to prove I'm not crazy, here's a GIF showing what happens with and without the .jsfmtrc file (contents pasted in my above comment) in my home directory:
untitled

Ah I see that you are trying to format a json file.
We have separate configuration for json files (options-JSON) and for javascript files (options).
You can have a look at some examples here: https://github.com/ionutvmi/sublime-jsfmt/blob/master/jsfmt.sublime-settings#L22

In order to change the default indentation (2 spaces) you need to specify the indent for the json files also.

    "options-JSON": {
        "indent": {
            "value": "    "
        }
    }

Please let me know if this fixes your issue.

That appears to have done the trick. Thanks!