예제 #1
0
파일: cmds.py 프로젝트: SCdF/NeoVintageous
    def run(self, edit):
        if self.view.score_selector(0, 'text.excmdline') == 0:
            return

        state = State(self.view)
        _nv_fs_completion.frozen_dir = (_nv_fs_completion.frozen_dir
                                        or (state.settings.vi['_cmdline_cd'] +
                                            '/'))

        cmd, prefix, only_dirs = parse_for_fs(
            self.view.substr(self.view.line(0)))
        if not cmd:
            return

        if not (_nv_fs_completion.prefix
                or _nv_fs_completion.items) and prefix:
            _nv_fs_completion.prefix = prefix
            _nv_fs_completion.is_stale = True

        if prefix == '..':
            _nv_fs_completion.prefix = '../'
            self.view.run_command('_nv_write_fs_completion', {
                'cmd': cmd,
                'completion': '../'
            })

        if prefix == '~':
            path = os.path.expanduser(prefix) + '/'
            _nv_fs_completion.prefix = path
            self.view.run_command('_nv_write_fs_completion', {
                'cmd': cmd,
                'completion': path
            })

            return

        if (not _nv_fs_completion.items) or _nv_fs_completion.is_stale:
            _nv_fs_completion.items = iter_paths(
                from_dir=_nv_fs_completion.frozen_dir,
                prefix=_nv_fs_completion.prefix,
                only_dirs=only_dirs)
            _nv_fs_completion.is_stale = False

        try:
            self.view.run_command('_nv_write_fs_completion', {
                'cmd': cmd,
                'completion': next(_nv_fs_completion.items)
            })
        except StopIteration:
            _nv_fs_completion.items = iter_paths(
                prefix=_nv_fs_completion.prefix,
                from_dir=_nv_fs_completion.frozen_dir,
                only_dirs=only_dirs)

            self.view.run_command('_nv_write_fs_completion', {
                'cmd': cmd,
                'completion': _nv_fs_completion.prefix
            })
예제 #2
0
파일: cmds.py 프로젝트: SCdF/NeoVintageous
    def on_change(self, s):
        if s == '':
            return self._force_cancel()

        if len(s) <= 1:
            return

        if s[0] != ':':
            return self._force_cancel()

        if _nv_cmdline.interactive_call:
            cmd, prefix, only_dirs = parse_for_fs(s)
            if cmd:
                _nv_fs_completion.prefix = prefix
                _nv_fs_completion.is_stale = True
            cmd, prefix, _ = parse_for_setting(s)
            if cmd:
                _nv_setting_completion.prefix = prefix
                _nv_setting_completion.is_stale = True

            if not cmd:
                return

        _nv_cmdline.interactive_call = True