Search code examples
zerobrane

How do you fire 'Correct Indentation' on save in ZeroBrane Studio?


ZeroBrane has an excellent Lua formatter built in that fires with: Cmd + I

Is there a way to trigger that to fire on save?


Solution

  • Yes, you can create a plugin to do this using onEditorPreSave event or can make it an inline plugin by adding the following to the config file:

    package {
      onEditorPreSave = function(self, editor)
        ide:GetMainFrame():ProcessEvent(wx.wxCommandEvent(
          wx.wxEVT_COMMAND_MENU_SELECTED, ID.REINDENT))
      end,
    }
    

    This will send a command to process reindentation event, which should have the desired effect.