Sublime Forum

Typescript plugin format on save doesn't work correctly on files opened after load


Hey, this issue is annoying for me, I have to frequently close and reopen Sublime to get the proper formatting, so I posted the full issue on the plugin repo:

and maybe here there could be ideas for a workaround, I’ve been reading and maybe using AutomaticPluginReloader could help with a shortcut I can press or even better an automatic action to reload the Typescript plugin when I open new files



Not a solution that you requested, but you can use this TS plugin
It doesn’t have annoyning bugs and works more smoothly. Just customize it as i described here

Also this statement looks strange for me “I have to frequently close and reopen Sublime to get the proper formatting”. Why you need to open/close sublime for formatting? I am using prettier, bind it to sublime hotkey and able to format file just by pressing hotkey. No need to close sublime.

1 Like


Thanks, great answer, that’s probably what I need if I can figure how to make it format on save with some customized settings

I’ve configured my Preferences: LSP-typescript Settings like this:

// Settings in here override those in "LSP-typescript/LSP-typescript.sublime-settings"

  "settings": {
    "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
    "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
    "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,

but this code

const f2 = function() {


gets formatted like that, there should a space between function and () instead

Would you happen to have an idea on this? (I asked it here btw

edit: What I meant by closing and opening ST to make it work, is that if a file is already opened in ST at loading time, formatting works, if a file is opened then saved, formatting doesn’t work with the customization (space after anonymius function)



Ok LSP-typescript now support formatting settings, it’s perfect, thanks again

1 Like