Esempio n. 1
0
def slow_linters(view=None, hook=None):
    """Run slow gometalinter linters
    """

    if view is None:
        view = active_view()

    if not get_settings(view, 'anaconda_go_linting', True):
        return

    if view.file_name() in anaconda_sublime.ANACONDA['DISABLED']:
        anaconda_sublime.erase_lint_marks(view)
        return

    settings = _get_settings(view)

    data = {
        'vid': view.id(),
        'code': view.substr(st3_sublime.Region(0, view.size())),
        'settings': settings,
        'filepath': view.file_name(),
        'method': 'slow_lint',
        'handler': 'anaGonda',
        'go_env': {
            'GOROOT': go.GOROOT,
            'GOPATH': go.GOPATH,
            'CGO_ENABLED': go.CGO_ENABLED
        }
    }

    callback = partial(anaconda_sublime.parse_results, **dict(code='go'))
    if hook is None:
        Worker().execute(Callback(on_success=callback), **data)
    else:
        Worker().execute(Callback(partial(hook, callback)), **data)
Esempio n. 2
0
    def is_enabled(self) -> bool:
        """Determine if this command is enabled or not
        """

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

        if not go.ANAGONDA_PRESENT:
            return False

        return is_code(active_view(), lang='go')
Esempio n. 3
0
    def is_enabled(self) -> bool:
        """Determine if this command is enabled or not
        """

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

        if not go.ANAGONDA_PRESENT:
            return False

        return is_code(active_view(), lang='go')
Esempio n. 4
0
    def _detect_in_configuration(self) -> bool:
        """Detect and validate Go parameters in configuration
        """

        view = active_view()

        goroot = get_settings(view, 'anaconda_go_GOROOT', '')
        gopath = get_settings(view, 'anaconda_go_GOPATH', '')
        gobin = get_settings(view, 'anaconda_go_GOBIN', '')
        if goroot and gopath:
            gobin = 'go' if os.name != 'nt' else 'go.exe'
            if os.path.exists(os.path.join(goroot, 'bin', gobin)):
                self.GOROOT = goroot
                self.GOPATH = gopath
                self.GOBIN = gobin
                self.CGO_ENABLED = "1"
                return True

        return False
Esempio n. 5
0
    def _detect_in_configuration(self) -> bool:
        """Detect and validate Go parameters in configuration
        """

        view = active_view()

        goroot = get_settings(view, 'anaconda_go_GOROOT', '')
        gopath = get_settings(view, 'anaconda_go_GOPATH', '')
        gobin = get_settings(view, 'anaconda_go_GOBIN', '')
        if goroot and gopath:
            gobin = 'go' if os.name != 'nt' else 'go.exe'
            if os.path.exists(os.path.join(goroot, 'bin', gobin)):
                self.GOROOT = goroot
                self.GOPATH = gopath
                self.GOBIN = gobin
                self.CGO_ENABLED = "1"
                return True

        return False