Example #1
0
 def run(self, dir=''):
     if not dir:
         view = self.window.active_view()
         dir = gs.basedir_or_cwd(
             view.file_name() if view is not None else None)
     gsq.dispatch('*', lambda: show_pkgfiles(dir),
                  'scanning directory for package files')
Example #2
0
	def run(self, edit):
		if gs.setting('comp_lint_enabled') is not True:
			return

		fn = self.view.file_name()
		fn = os.path.abspath(fn)
		if fn:
			dirname = gs.basedir_or_cwd(fn)
			file_refs[fn] = FileRef(self.view)
			gsq.dispatch(CL_DOMAIN, lambda: do_comp_lint(dirname, fn), '')
Example #3
0
    def run(self, edit):
        if gs.setting('comp_lint_enabled') is not True:
            return

        fn = self.view.file_name()
        fn = os.path.abspath(fn)
        if fn:
            dirname = gs.basedir_or_cwd(fn)
            file_refs[fn] = FileRef(self.view)
            gsq.dispatch(CL_DOMAIN, lambda: do_comp_lint(dirname, fn), '')
Example #4
0
	def run(self, dir=''):
		o = kv.O(cancelled=False)

		def cancel():
			o.cancelled = True

		if not dir:
			view = self.window.active_view()
			dir = gs.basedir_or_cwd(view.file_name() if view is not None else None)

		gsq.do(DOMAIN, lambda: show_pkgfiles(dir, o), 'scanning directory for package files', cancel=cancel)
Example #5
0
    def __init__(self, cmd=[], shell=False, env={}, cwd=None, view=None):
        self.view = view
        super(ViewCommand, self).__init__(cmd=cmd, shell=shell, env=env, cwd=cwd)

        self.output_done = []
        self.show_summary = False

        if not self.cwd and view is not None:
            try:
                self.cwd = gs.basedir_or_cwd(view.file_name())
            except Exception:
                self.cwd = None
Example #6
0
	def __init__(self, cmd=[], shell=False, env={}, cwd=None, view=None):
		self.view = view
		super(ViewCommand, self).__init__(cmd=cmd, shell=shell, env=env, cwd=cwd)

		self.output_done = []
		self.show_summary = False

		if not self.cwd and view is not None:
			try:
				self.cwd = gs.basedir_or_cwd(view.file_name())
			except Exception:
				self.cwd = None
Example #7
0
def _complete_opts(fn, src, pos):
    home = gs.home_path()
    builtins = gs.setting("autocomplete_builtins") is True or gs.setting("complete_builtins") is True
    return {
        "Dir": gs.basedir_or_cwd(fn),
        "Builtins": builtins,
        "Fn": fn or "",
        "Src": src or "",
        "Pos": pos or 0,
        "Home": home,
        "Env": gs.env({"XDG_CONFIG_HOME": home}),
    }
Example #8
0
def _complete_opts(fn, src, pos, builtins):
    nv = sh.env()
    return {
        "Dir": gs.basedir_or_cwd(fn),
        "Builtins": builtins,
        "Fn": fn or "",
        "Src": src or "",
        "Pos": pos or 0,
        "Home": sh.vdir(),
        "Autoinst": gs.setting("autoinst"),
        "InstallSuffix": gs.setting("installsuffix", ""),
        "Env": {"GOROOT": nv.get("GOROOT", ""), "GOPATH": nv.get("GOPATH", "")},
    }
Example #9
0
def _complete_opts(fn, src, pos):
	home = gs.home_path()
	builtins = (gs.setting('autocomplete_builtins') is True or gs.setting('complete_builtins') is True)
	return {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': home,
		'Env': gs.env({
			'XDG_CONFIG_HOME': home,
		}),
	}
Example #10
0
    def run(self):
        pkg_name = "main"
        view = gs.active_valid_go_view()
        try:
            basedir = gs.basedir_or_cwd(view and view.file_name())
            for fn in os.listdir(basedir):
                if fn.endswith(".go"):
                    name, _ = mg9.pkg_name(os.path.join(basedir, fn), "")
                    if name:
                        pkg_name = name
                        break
        except Exception:
            gs.error_traceback("GsNewGoFile")

        self.window.new_file().run_command("gs_create_new_go_file", {"pkg_name": pkg_name, "file_name": "main.go"})
Example #11
0
    def run(self, dir=''):
        o = kv.O(cancelled=False)

        def cancel():
            o.cancelled = True

        if not dir:
            view = self.window.active_view()
            dir = gs.basedir_or_cwd(
                view.file_name() if view is not None else None)

        gsq.do(DOMAIN,
               lambda: show_pkgfiles(dir, o),
               'scanning directory for package files',
               cancel=cancel)
Example #12
0
def _complete_opts(fn, src, pos, builtins):
	nv = sh.env()
	return {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': sh.vdir(),
		'Autoinst': gs.setting('autoinst'),
		'Env': {
			'GOROOT': nv.get('GOROOT', ''),
			'GOPATH': nv.get('GOPATH', ''),
		},
	}
Example #13
0
def _complete_opts(fn, src, pos, builtins):
    nv = sh.env()
    return {
        'Dir': gs.basedir_or_cwd(fn),
        'Builtins': builtins,
        'Fn': fn or '',
        'Src': src or '',
        'Pos': pos or 0,
        'Home': sh.vdir(),
        'Autoinst': gs.setting('autoinst'),
        'InstallSuffix': gs.setting('installsuffix', ''),
        'Env': {
            'GOROOT': nv.get('GOROOT', ''),
            'GOPATH': nv.get('GOPATH', ''),
        },
    }
Example #14
0
def complete(fn, src, pos):
	home = gs.home_path()
	builtins = (gs.setting('autocomplete_builtins') is True or gs.setting('complete_builtins') is True)
	res, err = bcall('gocode_complete', {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': home,
		'Env': gs.env({
			'XDG_CONFIG_HOME': home,
		}),
	})

	res = gs.dval(res.get('completions'), [])
	return res, err
Example #15
0
def complete(fn, src, pos):
	home = gs.home_path()
	builtins = (gs.setting('autocomplete_builtins') is True or gs.setting('complete_builtins') is True)
	res, err = bcall('gocode_complete', {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': home,
		'Env': gs.env({
			'XDG_CONFIG_HOME': home,
		}),
	})

	res = gs.dval(res.get('completions'), [])
	return res, err
Example #16
0
	def run(self):
		pkg_name = 'main'
		view = gs.active_valid_go_view()
		try:
			basedir = gs.basedir_or_cwd(view and view.file_name())
			for fn in os.listdir(basedir):
				if fn.endswith('.go'):
					name, _ = mg9.pkg_name(os.path.join(basedir, fn), '')
					if name:
						pkg_name = name
						break
		except Exception:
			gs.error_traceback('GsNewGoFile')

		self.window.new_file().run_command('gs_create_new_go_file', {
			'pkg_name': pkg_name,
			'file_name': 'main.go',
		})
Example #17
0
def _complete_opts(fn, src, pos, builtins, *, forceInstall=False):
    nv = sh.env()
    return {
        'Dir': gs.basedir_or_cwd(fn),
        'Builtins': builtins,
        'Fn': fn or '',
        'Src': src or '',
        'Pos': pos or 0,
        'Home': sh.vdir(),
        'Autoinst': gs.setting('autoinst'),
        'InstallSuffix': gs.setting('installsuffix', ''),
        'Env': {
            'GOROOT': nv.get('GOROOT', ''),
            'GOPATH': nv.get('GOPATH', ''),
            'TEMP': nv.get('TEMP', ''),
            'TMP': nv.get('TMP', ''),
            'FORCE_INSTALL': str(int(forceInstall)),
        },
    }
Example #18
0
def _complete_opts(fn, src, pos, builtins, *, forceInstall = False):
	nv = sh.env()
	return {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': sh.vdir(),
		'Autoinst': gs.setting('autoinst'),
		'InstallSuffix': gs.setting('installsuffix', ''),
		'Env': {
			'GOROOT': nv.get('GOROOT', ''),
			'GOPATH': nv.get('GOPATH', ''),
			'TEMP': nv.get('TEMP', ''),
			'TMP': nv.get('TMP', ''),
			'FORCE_INSTALL': str(int(forceInstall)),
		},
	}
Example #19
0
	def run(self, dir=''):
		if not dir:
			view = self.window.active_view()
			dir = gs.basedir_or_cwd(view.file_name() if view is not None else None)
		gsq.dispatch('*', lambda: show_pkgfiles(dir), 'scanning directory for package files')
Example #20
0
def active_wd(win=None):
	_, v = gs.win_view(win=win)
	return gs.basedir_or_cwd(v.file_name() if v else '')
Example #21
0
 def cb(i, win):
     if i >= 0:
         dirname = gs.basedir_or_cwd(m[ents[i]])
         win.run_command('gs_browse_files', {'dir': dirname})
Example #22
0
				def cb(i, win):
					if i >= 0:
						dirname = gs.basedir_or_cwd(m[ents[i]])
						win.run_command('gs_browse_files', {'dir': dirname})
Example #23
0
def active_wd(win=None):
    _, v = gs.win_view(win=win)
    return gs.basedir_or_cwd(v.file_name() if v else '')