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
def gather_candidates( self, context: Context, path: Path) -> typing.List[typing.Dict[str, typing.Any]]: candidates = [] if not readable(path) or not path.is_dir(): error(self.vim, f'"{path}" is not readable directory.') return [] try: for entry in path.iterdir(): candidates.append({ 'word': entry.name.replace('\n', '\\n') + ('/' if safe_call(entry.is_dir, False) else ''), 'is_directory': safe_call(entry.is_dir, False), 'action__path': entry, }) if context.show_parent: candidates.append({ 'word': '../', 'is_directory': True, 'action__path': path.resolve().parent, }) except OSError: pass return candidates
def gather_candidates( self, context: Context, path: Path ) -> typing.List[typing.Dict[str, typing.Any]]: candidates = [] if not readable(path) or not path.is_dir(): error(self.vim, f'"{path}" is not readable directory.') return [] for entry in path.iterdir(): candidates.append({ 'word': entry.name + ('/' if safe_call(entry.is_dir, False) else ''), 'is_directory': safe_call(entry.is_dir, False), 'action__path': entry, }) return candidates
def load_custom_columns(self) -> typing.List[Path]: rtp_list = self._vim.options['runtimepath'].split(',') result: typing.List[Path] = [] for path in rtp_list: column_path = Path(path).joinpath('rplugin', 'python3', 'defx', 'column') if safe_call(column_path.is_dir): result += column_path.glob('*.py') return result
def _load_custom_sources(self) -> typing.List[Path]: rtp_list = self._vim.options['runtimepath'].split(',') result: typing.List[Path] = [] for path in rtp_list: source_path = Path(path).joinpath('rplugin', 'python3', 'defx', 'source') if safe_call(source_path.is_dir): result += source_path.glob('*.py') result += source_path.glob('*/*.py') return result