def run(self, args):
view = self.view
# Show the stdlib documentation on the official site?
default_docs = False
non_empty_selections = [sl for sl in view.sel() if not sl.empty()]
if len(non_empty_selections) == 0:
default_docs = True
if len(non_empty_selections) == 1:
pkg = view.substr(non_empty_selections[0])
pkg = pkg.strip(' \t\r\n"')
elif len(non_empty_selections) > 1:
sublime.status_message('TOO MANY SELECTIONS')
return
launcher = 'xdg-open'
via_shell = False
if sys.platform == 'darwin':
launcher = 'open'
elif sys.platform == 'win32':
launcher = 'start'
via_shell=True
if default_docs:
run_tool([launcher, 'https://golang.org/pkg/'], wd='.', shell=via_shell)
else:
run_tool([launcher, 'https://godoc.org/' + pkg.lower()], wd='.', shell=via_shell)
评论列表
文章目录