Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
79 lines
2.7 KiB
Python
79 lines
2.7 KiB
Python
# ============================================================================
|
|
# FILE: rplugin.py
|
|
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
|
|
# License: MIT license
|
|
# ============================================================================
|
|
|
|
import typing
|
|
|
|
from defx.clipboard import Clipboard
|
|
from defx.view import View
|
|
from defx.util import Nvim
|
|
|
|
|
|
class Rplugin:
|
|
|
|
def __init__(self, vim: Nvim) -> None:
|
|
self._vim = vim
|
|
self._views: typing.List[View] = []
|
|
self._clipboard = Clipboard()
|
|
|
|
def init_channel(self) -> None:
|
|
self._vim.vars['defx#_channel_id'] = self._vim.channel_id
|
|
|
|
def start(self, args: typing.List[typing.Any]) -> None:
|
|
[paths, context] = args
|
|
self.get_view(context).init_paths(
|
|
paths, context, self._clipboard)
|
|
|
|
def do_action(self, args: typing.List[typing.Any]) -> None:
|
|
views = [x for x in self._views
|
|
if x._bufnr == self._vim.current.buffer.number]
|
|
if not views:
|
|
return
|
|
view = views[0]
|
|
|
|
prev_paths = [x._cwd for x in view._defxs]
|
|
prev_candidates = view._candidates
|
|
|
|
view.do_action(args[0], args[1], args[2])
|
|
|
|
paths = [x._cwd for x in view._defxs]
|
|
if paths == prev_paths and view._candidates != prev_candidates:
|
|
self.redraw([x for x in self._views if x != view])
|
|
|
|
def get_candidate(self) -> typing.Dict[str, typing.Union[str, bool]]:
|
|
cursor = self._vim.call('line', '.')
|
|
for view in [x for x in self._views
|
|
if x._bufnr == self._vim.current.buffer.number]:
|
|
candidate = view.get_cursor_candidate(cursor)
|
|
return {
|
|
'word': candidate['word'],
|
|
'is_directory': candidate['is_directory'],
|
|
'is_opened_tree': candidate['is_opened_tree'],
|
|
'level': candidate['level'],
|
|
'action__path': str(candidate['action__path']),
|
|
}
|
|
return {}
|
|
|
|
def get_context(self) -> typing.Dict[str, typing.Any]:
|
|
for view in [x for x in self._views
|
|
if x._bufnr == self._vim.current.buffer.number]:
|
|
return view._context._asdict()
|
|
return {}
|
|
|
|
def get_view(self, context: typing.Dict[str, typing.Any]) -> View:
|
|
views = [x for x in self._views
|
|
if context['buffer_name'] == x._context.buffer_name]
|
|
if not views or context['new']:
|
|
view = View(self._vim, len(self._views))
|
|
views = [view]
|
|
self._views.append(view)
|
|
return views[0]
|
|
|
|
def redraw(self, views: typing.List[View]) -> None:
|
|
call = self._vim.call
|
|
for view in [x for x in views
|
|
if call('bufwinnr', x._bufnr) > 0]:
|
|
view.redraw(True)
|