예제 #1
0
    def run(self, edit):
        settings = self.view.settings()
        file_name = self.view.file_name()

        if file_name is not None and s.get("ignore_sublime_settings"):
            _, ext = os.path.splitext(file_name)
            if ext in {".sublime-settings", ".sublime-project"}:
                return

        # settings
        opts = jsbeautifier.default_options()
        opts.indent_char = " " if settings.get("translate_tabs_to_spaces") else "\t"
        opts.indent_size = int(settings.get("tab_size")) if opts.indent_char == " " else 1
        opts = jsf_rc.augment_options(opts, s)

        if s.get("jsbeautifyrc_files"):
            opts = jsf_rc.augment_options_by_rc_files(opts, self.view)

        selection = self.view.sel()[0]

        # formatting a selection/highlighted area
        if(len(selection) > 0):
            jsf.format_selection(self.view, edit, opts)
        else:
            jsf.format_whole_file(self.view, edit, opts)
예제 #2
0
    def run(self, edit):
        settings = self.view.settings()
        file_name = self.view.file_name()

        if file_name is not None and s.get("ignore_sublime_settings"):
            _, ext = os.path.splitext(file_name)
            if ext in [".sublime-settings", ".sublime-project"]:
                return

        # settings
        opts = jsbeautifier.default_options()
        opts.indent_char = " " if settings.get(
            "translate_tabs_to_spaces") else "\t"
        opts.indent_size = int(
            settings.get("tab_size")) if opts.indent_char == " " else 1
        opts = jsf_rc.augment_options(opts, s)

        if s.get("jsbeautifyrc_files"):
            opts = jsf_rc.augment_options_by_rc_files(opts, self.view)

        selection = self.view.sel()[0]

        # formatting a selection/highlighted area
        if (len(selection) > 0 and s.get("format_selection")):
            jsf.format_selection(self.view, edit, opts)
        else:
            self.change_syntax()
            jsf.format_whole_file(self.view, edit, opts)
예제 #3
0
    def run(self, edit):
        settings = self.view.settings()

        # settings
        opts = jsbeautifier.default_options()
        opts.indent_char = " " if settings.get("translate_tabs_to_spaces") else "\t"
        opts.indent_size = int(settings.get("tab_size")) if opts.indent_char == " " else 1
        opts = jsf_rc.augment_options(opts, s)

        if s.get("jsbeautifyrc_files") == True:
            opts = jsf_rc.augment_options_by_rc_files(opts, self.view)

        selection = self.view.sel()[0]

        # formatting a selection/highlighted area
        if len(selection) > 0:
            jsf.format_selection(self.view, edit, opts)
        else:
            jsf.format_whole_file(self.view, edit, opts)
예제 #4
0
    def run(self, edit):
        settings = self.view.settings()

        # settings
        opts = jsbeautifier.default_options()
        opts.indent_char = " " if settings.get(
            "translate_tabs_to_spaces") else "\t"
        opts.indent_size = int(
            settings.get("tab_size")) if opts.indent_char == " " else 1
        opts = jsf_rc.augment_options(opts, s)

        if (s.get("jsbeautifyrc_files") == True):
            opts = jsf_rc.augment_options_by_rc_files(opts, self.view)

        selection = self.view.sel()[0]

        # formatting a selection/highlighted area
        if (len(selection) > 0):
            jsf.format_selection(self.view, edit, opts)
        else:
            jsf.format_whole_file(self.view, edit, opts)