Ejemplo n.º 1
0
    def gather_candidates(
            self, context: Context,
            path: Path) -> typing.List[typing.Dict[str, typing.Any]]:
        if not readable(path):
            error(self.vim, f'"{path}" is not readable file.')
            return []

        if path.is_dir():
            # Fallback to file source
            return File(self.vim).gather_candidates(context, path)

        candidates = []
        with path.open() as f:
            for line in f:
                entry = Path(line.rstrip('\n'))
                if not entry.exists():
                    continue
                candidates.append({
                    'word':
                    str(entry) +
                    ('/' if safe_call(entry.is_dir, False) else ''),
                    'is_directory':
                    safe_call(entry.is_dir, False),
                    'action__path':
                    entry,
                })
        return candidates
Ejemplo n.º 2
0
 def __init__(self, vim: Nvim, context: Context,
              cwd: str, index: int) -> None:
     self._vim = vim
     self._context = context
     self._cwd = self._vim.call('getcwd')
     self.cd(cwd)
     self._source: File = File(self._vim)
     self._index = index
     self._cursor_history: typing.Dict[str, str] = {}
Ejemplo n.º 3
0
 def __init__(self, vim: Nvim, context: Context, cwd: str,
              index: int) -> None:
     self._vim = vim
     self._context = context
     self._cwd = self._vim.call('getcwd')
     self.cd(cwd)
     self._source: File = File(self._vim)
     self._index = index
     self._enabled_ignored_files = not context.show_ignored_files
     self._ignored_files = ['.*']
     self._cursor_history: typing.Dict[str, Path] = {}
     self._sort_method: str = self._context.sort
Ejemplo n.º 4
0
    def __init__(self, vim: Nvim, context: Context,
                 cwd: str, index: int) -> None:
        self._vim = vim
        self._context = context
        self._cwd = self._vim.call('getcwd')
        self.cd(cwd)
        self._source: File = File(self._vim)
        self._index = index
        self._enabled_ignored_files = not context.show_ignored_files
        self._ignored_files = context.ignored_files.split(',')
        self._cursor_history: typing.Dict[str, Path] = {}
        self._sort_method: str = self._context.sort
        self._mtime: int = -1
        self._opened_candidates: typing.Set[str] = set()

        self._init_source()
Ejemplo n.º 5
0
 def __init__(self, vim: Nvim, cwd: str) -> None:
     self._vim = vim
     self._cwd = self._vim.call('getcwd')
     self.cd(cwd)
     self._source: File = File(self._vim)