akalongman / sublimetext-codeformatter

Code Formatter plugin for ST2/ST3
MIT License
772 stars 130 forks source link

CodeFormatter: Formatter for this file type (javascript) not found. #247

Open magleahy opened 8 years ago

magleahy commented 8 years ago

I can't seem to run CodeFormatter over JS file. I have Sublime Text 3 and installed CodeFormatter via Package Installer. HELP!

RevanProdigalKnight commented 8 years ago

Try adding "syntaxes": "javascript" to your "codeformatter_js_options" settings if it isn't there.

bcreeves commented 8 years ago

I had this same issue. I had made a change to codeformatter_js_options that I put in the user settings so it wouldn't overwrite when the package updated. When I added the syntaxes line to the user settings it worked again. Is that intended behavior? I thought any line that I don't overwrite in my user settings would default to the package settings.

ryenus commented 8 years ago

A working version of Package Settings > Code Formatter > Settings - User:

{
  "codeformatter_js_options":
  {
    "indent_size": 2, // indentation size
    "syntaxes": "javascript,json",
    "preserve_newlines": true
  },
}

The problem is likely caused by the shallow merging strategy used to merge user settings with default settings, thus the resulting codeformatter_js_options.syntaxes might be empty if not copied to user settings,

A possible solution could be moving codeformatter_js_options.syntaxes out of codeformatter_js_options object, e.g.:

{
    codeformatter_syntaxes: 
    {
        "codeformatter_js": "javascript,json",
        "codeformatter_css": "css,less",
        // ...
    }
}

Or maybe just make sure the default values apply when not set in bogus user settings.