Example #1
0
def cmd_9(view, edit, args, wd, rkey):
	if len(args) == 0 or args[0] not in ('run', 'replay', 'build'):
		push_output(view, rkey, ('9: invalid args %s' % args))
		return

	subcmd = args[0]
	cid = ''
	if subcmd == 'replay':
		cid = '9replay-%s' % wd
	cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid)

	a = {
		'cid': cid,
		'env': sh.env(),
		'dir': wd,
		'args': args[1:],
		'build_only': (subcmd == 'build'),
	}

	win = view.window()
	if win is not None:
		av = win.active_view()
		if av is not None:
			fn = av.file_name()
			if fn:
				_save_all(win, wd)
			else:
				if gs.is_go_source_view(av, False):
					a['fn'] = gs.view_fn(av)
					a['src'] = av.substr(sublime.Region(0, av.size()))

	sublime.set_timeout(lambda: mg9.acall('play', a, cb), 0)
Example #2
0
def cmd_9(view, edit, args, wd, rkey):
    if len(args) == 0 or args[0] not in ("run", "replay", "build"):
        push_output(view, rkey, ("9: invalid args %s" % args))
        return

    subcmd = args[0]
    cid = ""
    if subcmd == "replay":
        cid = "9replay-%s" % wd
    cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid)

    a = {"cid": cid, "env": sh.env(), "dir": wd, "args": args[1:], "build_only": (subcmd == "build")}

    win = view.window()
    if win is not None:
        av = win.active_view()
        if av is not None:
            fn = av.file_name()
            if fn:
                _save_all(win, wd)
            else:
                if gs.is_go_source_view(av, False):
                    a["fn"] = gs.view_fn(av)
                    a["src"] = av.substr(sublime.Region(0, av.size()))

    sublime.set_timeout(lambda: mg9.acall("play", a, cb), 0)
Example #3
0
 def run(self, edit):
     view = self.view
     if gs.is_go_source_view(view):
         if not gstest.handle_action(view, 'left-click'):
             view.run_command('gs_doc', {"mode": "goto"})
     elif view.score_selector(gs.sel(view).begin(), "text.9o") > 0:
         view.window().run_command("gs9o_open_selection")
Example #4
0
def cmd_9(view, edit, args, wd, rkey):
    if len(args) == 0 or args[0] not in ('run', 'replay', 'build'):
        push_output(view, rkey, ('9: invalid args %s' % args))
        return

    subcmd = args[0]
    cid = ''
    if subcmd == 'replay':
        cid = '9replay-%s' % wd
    cid, cb = _9_begin_call(subcmd, view, edit, args, wd, rkey, cid)

    a = {
        'cid': cid,
        'env': gs.env(),
        'dir': wd,
        'args': args[1:],
        'build_only': (subcmd == 'build'),
    }

    win = view.window()
    if win is not None:
        av = win.active_view()
        if av is not None:
            fn = av.file_name()
            if fn:
                _save_all(win, wd)
            else:
                if gs.is_go_source_view(av, False):
                    a['fn'] = gs.view_fn(av)
                    a['src'] = av.substr(sublime.Region(0, av.size()))

    sublime.set_timeout(lambda: mg9.acall('play', a, cb), 0)
Example #5
0
	def _is_go_source(view):
		fn = view.file_name()
		if fn:
			scope_ok = fn.lower().endswith('.go')
		else:
			scope_ok = gs.is_go_source_view(view)
		return scope_ok
Example #6
0
	def run(self, edit):
		view = self.view
		if gs.is_go_source_view(view):
			if not gstest.handle_action(view, 'left-click'):
				view.run_command('gs_doc', {"mode": "goto"})
		elif view.score_selector(gs.sel(view).begin(), "text.9o") > 0:
			view.window().run_command("gs9o_open_selection")
Example #7
0
	def is_enabled(self):
		fn = self.view.file_name()
		if fn:
			scope_ok = fn.lower().endswith('.go')
		else:
			scope_ok = gs.is_go_source_view(self.view)

		return scope_ok and gs.setting('fmt_enabled') is True
Example #8
0
def _ct(view):
	if not gs.is_go_source_view(view):
		return

	if gs.setting('calltips') is True:
		view.run_command('gs_show_call_tip', {'set_status': True})
	else:
		view.erase_status(HINT_KEY)
Example #9
0
def _ct(view):
    if not gs.is_go_source_view(view):
        return

    if gs.setting('calltips') is True:
        view.run_command('gs_show_call_tip', {'set_status': True})
    else:
        view.erase_status(HINT_KEY)
Example #10
0
    def run(self, _, mode=''):
        view = self.view
        if (not gs.is_go_source_view(view)) or (mode not in ['goto', 'hint']):
            return

        pt = gs.sel(view).begin()
        src = view.substr(sublime.Region(0, view.size()))
        pt = len(src[:pt].encode("utf-8"))

        def f(docs, err):
            doc = ''
            if err:
                self.show_output('// Error: %s' % err)
            elif docs:
                if mode == "goto":
                    fn = ''
                    flags = 0
                    if len(docs) > 0:
                        d = docs[0]
                        fn = d.get('fn', '')
                        row = d.get('row', 0)
                        col = d.get('col', 0)
                        if fn:
                            gs.println('opening %s:%s:%s' % (fn, row, col))
                            vu.open(fn=fn, row=row, col=col)
                            return
                    self.show_output("%s: cannot find definition" % DOMAIN)
                elif mode == "hint":
                    s = []
                    for d in docs:
                        name = d.get('name', '')
                        if name:
                            kind = d.get('kind', '')
                            pkg = d.get('pkg', '')
                            if pkg:
                                name = '%s.%s' % (pkg, name)
                            src = d.get('src', '')
                            if src:
                                src = '\n//\n%s' % src
                            doc = '// %s %s%s' % (name, kind, src)

                        s.append(doc)
                    doc = '\n\n\n'.join(s).strip()
            self.show_output(doc or "// %s: no docs found" % DOMAIN)

        mg9.doc(view.file_name(), src, pt, f)
Example #11
0
	def run(self, _, mode=''):
		view = self.view
		if (not gs.is_go_source_view(view)) or (mode not in ['goto', 'hint']):
			return

		pt = gs.sel(view).begin()
		src = view.substr(sublime.Region(0, view.size()))
		pt = len(src[:pt].encode("utf-8"))
		def f(docs, err):
			doc = ''
			if err:
				self.show_output('// Error: %s' % err)
			elif docs:
				if mode == "goto":
					fn = ''
					flags = 0
					if len(docs) > 0:
						d = docs[0]
						fn = d.get('fn', '')
						row = d.get('row', 0)
						col = d.get('col', 0)
						if fn:
							gs.println('opening %s:%s:%s' % (fn, row, col))
							gs.focus(fn, row, col)
							return
					self.show_output("%s: cannot find definition" % DOMAIN)
				elif mode == "hint":
					s = []
					for d in docs:
						name = d.get('name', '')
						if name:
							kind = d.get('kind', '')
							pkg = d.get('pkg', '')
							if pkg:
								name = '%s.%s' % (pkg, name)
							src = d.get('src', '')
							if src:
								src = '\n//\n%s' % src
							doc = '// %s %s%s' % (name, kind, src)

						s.append(doc)
					doc = '\n\n\n'.join(s).strip()
			self.show_output(doc or "// %s: no docs found" % DOMAIN)

		mg9.doc(view.file_name(), src, pt, f)
Example #12
0
 def is_enabled(self):
     return gs.is_go_source_view(self.view)
Example #13
0
	def is_enabled(self):
		return gs.is_go_source_view(self.view)
Example #14
0
 def is_enabled(self):
     if gs.setting("fmt_enabled") is True:
         fn = self.view.file_name() or ""
         return fn.endswith(".go") or gs.is_go_source_view(self.view)
     return False
Example #15
0
	def is_enabled(self):
		return gs.is_go_source_view(self.window.active_view())
Example #16
0
	def is_enabled(self):
		return gs.is_go_source_view(self.window.active_view())
Example #17
0
 def is_enabled(self):
     return bool(gs.is_go_source_view(self.view) and self.view.file_name())
Example #18
0
	def is_enabled(self):
		fn = self.view.file_name() or ''
		return fn.endswith('.go') or gs.is_go_source_view(self.view)
Example #19
0
	def run(self, edit):
		view = self.view
		if gs.is_go_source_view(view):
			if not gstest.handle_action(view, 'right-click'):
				view.run_command('gs_doc', {"mode": "hint"})
Example #20
0
	def is_enabled(self):
		return gs.setting('fmt_enabled', False) is True and gs.is_go_source_view(self.view)
Example #21
0
 def run(self, edit):
     view = self.view
     if gs.is_go_source_view(view):
         if not gstest.handle_action(view, 'right-click'):
             view.run_command('gs_doc', {"mode": "hint"})
Example #22
0
	def run(self, _, mode=''):
		view = self.view
		if (not gs.is_go_source_view(view)) or (mode not in ['goto', 'hint', 'usage']):
			return

		pt = gs.sel(view).begin()
		src = view.substr(sublime.Region(0, view.size()))
		pt = len(src[:pt].encode("utf-8"))
		def f(docs, err):
			doc = ''
			if err:
				self.show_output('// Error: %s' % err)
			elif docs:
				if mode == "goto" or mode == "usage":
					fn = ''
					flags = 0

					#method to open doc
					def open(d):
						fn = d.get('fn', '')
						row = d.get('row', 0)
						col = d.get('col', 0)
						if fn:
							gs.println('opening %s:%s:%s' % (fn, row, col))
							gs.focus(fn, row, col)
							return
						self.show_output("%s: cannot find definition" % DOMAIN)

					if len(docs) > 1:
						def callback(idx):
							open(docs[idx])

						def highlight(idx):
							d = docs[idx]
							fn = d.get('fn', '')
							row = d.get('row', 0) + 1
							col = d.get('col', 0) + 1
							sublime.active_window().open_file('%s:%s:%s' % (fn, row or 0, col or 0), sublime.TRANSIENT | sublime.ENCODED_POSITION)

						#list of usages
						lines = []
						for d in docs:
							lines.append(d.get('fn', '') + ':' + str(d.get('row', 0) + 1) + ':' + str(d.get('col', 0) + 1))
						
						sublime.active_window().show_quick_panel(lines, callback, on_highlight=highlight)
						return
						
					elif len(docs) == 1:
						open(docs[0])
						return

				elif mode == "hint":
					s = []
					for d in docs:
						name = d.get('name', '')
						if name:
							kind = d.get('kind', '')
							pkg = d.get('pkg', '')
							if pkg:
								name = '%s.%s' % (pkg, name)
							src = d.get('src', '')
							if src:
								src = '\n//\n%s' % src
							doc = '// %s %s%s' % (name, kind, src)

						s.append(doc)
					doc = '\n\n\n'.join(s).strip()
			self.show_output(doc or "// %s: no docs found" % DOMAIN)

		mg9.doc(view.file_name(), src, pt, f, mode)
Example #23
0
 def is_enabled(self):
     return gs.setting('fmt_enabled',
                       False) is True and gs.is_go_source_view(self.view)
Example #24
0
	def is_enabled(self):
		return bool(gs.is_go_source_view(self.view) and self.view.file_name())