federomero / pretty-json

Atom plugin. Format JSON documents.
MIT License
94 stars 23 forks source link

Feature Request: Respect Atom's tab and tab-width settings when prettifying #72

Closed schnitzelK1ng closed 5 years ago

schnitzelK1ng commented 7 years ago

It would be nice if it used hard/soft tabs and use tab-width specified in Atom's settings.

stereonom commented 5 years ago

I modified the formatter.js to get this working.

  space (scope) {
    const softTabs = atom.config.get('editor.softTabs', {scope})
    const tabLength = Number([atom.config.get('editor.tabLength', {scope})])
    if (softTabs) {
      return Array(tabLength + 1).join(' ')
    } else {
      return '\t'
    }
  },
lexicalunit commented 5 years ago

Thanks for the fix! Published as pretty-json@v2.0.4.

stereonom commented 5 years ago

Hey. You forgot to change the if (softTabs != null) { to if (softTabs) { The Editor-Config editor.softTabs always gives u a boolean.

So, it's still broken in the current version.

lexicalunit commented 5 years ago

Fixed and released as pretty-json@v2.1.2 🎉