1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:50:05 +08:00
SpaceVim/bundle/defx.nvim/rplugin/python3/denite/source/defx/history.py
2020-10-31 15:58:52 +08:00

37 lines
1.2 KiB
Python
Vendored

# ============================================================================
# FILE: defx/history.py
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
# License: MIT license
# ============================================================================
import typing
from defx.util import Nvim, UserContext, Candidates
from denite.source.base import Base
class Source(Base):
def __init__(self, vim: Nvim) -> None:
super().__init__(vim)
self.name = 'defx/history'
self.kind = 'command'
self._histories: typing.List[str] = []
def on_init(self, context: UserContext) -> None:
options = self.vim.current.buffer.options
if 'filetype' not in options or options['filetype'] != 'defx':
return
self._histories = reversed(self.vim.vars['defx#_histories'])
def gather_candidates(self, context: UserContext) -> Candidates:
return [{
'word': x,
'abbr': f'{source_name}:{x}/',
'action__command': ('call defx#call_action' +
f"('cd', ['{source_name}', '{x}'])"),
'action__path': x,
} for [source_name, x] in self._histories]