Пример #1
0
    def on_pre_save(self, view):
        """Called just before the file is goign to be saved
        """

        if is_code(view, lang='rust', ignore_comments=True):
            if get_settings(view, 'rust_format_on_save', False):
                    view.run_command('anaconda_rust_fmt')
Пример #2
0
    def is_enabled(self):
        """Determine if this command is enabled or not
        """

        if len(sublime.active_window().views()) == 0:
            return False

        return is_code(self.view, lang='rust')
Пример #3
0
    def is_enabled(self):
        """Determine if this command is enabled or not
        """

        if len(sublime.active_window().views()) == 0:
            return False

        return is_code(self.view, lang='rust')
Пример #4
0
    def is_enabled(self):
        """Determine if this command is enabled or not
        """

        if len(sublime.active_window().views()) == 0:
            return False

        if RACER_VERSION is not None and RACER_VERSION < (1, 2, 10):
            return False

        return is_code(self.view, lang='rust')
Пример #5
0
    def on_query_completions(self, view, prefix, locations):
        """Sublime Text autocompletion event handler
        """

        if not is_code(view, lang='rust'):
            return

        if self.ready_from_defer is True:
            completion_flags = 0

            if ags(view, 'suppress_word_completions', False):
                completion_flags = sublime.INHIBIT_WORD_COMPLETIONS

            if ags(view, 'suppress_explicit_completions', False):
                completion_flags = sublime.INHIBIT_EXPLICIT_COMPLETIONS

            cpl = self.completions
            self.completions = []
            self.ready_from_defer = False

            return (cpl, completion_flags)

        code = view.substr(sublime.Region(0, view.size()))
        row, col = view.rowcol(locations[0])
        racer = get_settings(view, 'racer_binary_path', 'racer')
        if racer == '':
            racer = 'racer'

        data = {
            'vid': view.id(),
            'filename': view.file_name(),
            'settings': {
                'racer_binary_path': racer,
                'rust_src_path': get_settings(view, 'rust_src_path'),
                'row': row,
                'col': col,
                'source': code,
            },
            'method': 'autocomplete',
            'handler': 'racer'
        }
        Worker().execute(
            Callback(
                on_success=self._complete,
                on_failure=self._on_failure,
                on_timeout=self._on_timeout
            ),
            **data
        )
Пример #6
0
    def is_enabled(self):
        """Determine if this command is enabled or not
        """

        return is_code(self.view, lang='rust', ignore_comments=True)
Пример #7
0
    def is_enabled(self):
        """Determine if this command is enabled or not
        """

        return is_code(self.view, lang='rust', ignore_comments=True)