New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defx action for cdable files/sources #556

Closed
petobens opened this Issue Jan 8, 2019 · 11 comments

Comments

Projects
None yet
3 participants
@petobens
Copy link

petobens commented Jan 8, 2019

Is it possible to add a defx action for files/sources that are cdable (such as directories)? This is basically what unite had with vimfiler and I think it's pretty useful. Thanks!

@Shougo

This comment has been minimized.

Copy link
Owner

Shougo commented Jan 9, 2019

I don't want to add the feature.
You can use deoplete#custom#action instead.

@Shougo Shougo added the wontfix label Jan 9, 2019

@Shougo Shougo closed this Jan 9, 2019

@petobens

This comment has been minimized.

Copy link

petobens commented Jan 9, 2019

I tried with

call denite#custom#action('buffer,directory,file,openable', 'defx',
      \ {context -> execute('Defx ' . context['targets'][0]['action__path'])})

but sometimes, for instance when running on file_rec candidates I get

[denite] pynvim.api.nvim.NvimError: b"Vim(let):error caught in request handler '/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx:function:_defx_do_action [['redraw', ['
'], {'columns': 'icons:filename:size:git', 'auto_cd': False, 'prev_bufnr': 21, 'resume': False, 'sort': 'filename', 'listed': False, 'new': False, 'direction': 'topleft', 'show_ignored_files': 1, 'winheight': 0,
'profile': False, 'search': '', 'buffer_name': 'default', 'winwidth': 40, 'split': 'vertical', 'cursor': 1, 'prev_winid': 1017, 'toggle': False}]]':"
[denite] Please execute :messages command.

What't the correct way to define the custom defx action?

@Shougo

This comment has been minimized.

Copy link
Owner

Shougo commented Jan 10, 2019

I have tested it, but I don't reproduce the problem.
I don't support for no reproduce-able problems.

You need to create the minimal vimrc and reproduce instructions.

@petobens

This comment has been minimized.

Copy link

petobens commented Jan 10, 2019

With the following minimal vimrc:

set nocompatible

let $DOTVIM = expand('$HOME/.config/nvim')

set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/defx.nvim
set runtimepath+=$DOTVIM/bundle/repos/github.com/Shougo/denite.nvim
set runtimepath+=$DOTVIM/bundle/repos/github.com/kristijanhusak/defx-git

call denite#custom#action('buffer,directory,file,openable', 'defx',
      \ {context -> execute('Defx ' . context['targets'][0]['action__path'])})

call defx#custom#option('_', {
            \ 'columns': 'icons:filename:size:git',
            \ })

Do:
i) run :Denite file_rec
ii) Run defx on some candidate.
I get the following error:

[denite] Traceback (most recent call last):
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/__init__.py", line 38, in start
[denite]     return ui.start(args[0], args[1])
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/default.py", line 70, in start
[denite]     self._start(context['sources_queue'][0], context)
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/default.py", line 137, in _start
[denite]     status = self._prompt.start()
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/prompt/prompt.py", line 201, in start
[denite]     raise e
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/prompt/prompt.py", line 191, in start
[denite]     interval=self.harvest_interval,
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/prompt.py", line 96, in on_keypress
[denite]     ret = self.action.call(self, m.group('action'))
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/prompt/action.py", line 139, in call
[denite]     return fn(prompt, params)
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/action.py", line 22, in _choose_action
[denite]     return prompt.denite.choose_action()
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/default.py", line 705, in choose_action
[denite]     return self.do_action(action)
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/ui/default.py", line 667, in do_action
[denite]     self._denite.do_action(self._context, action_name, candidates)
[denite]   File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/denite/denite.py", line 245, in do_action
[denite]     action['kind'], action['name'], context)
[denite]   File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/api/nvim.py", line 299, in call
[denite]     return self.request('nvim_call_function', name, args, **kwargs)
[denite]   File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/api/nvim.py", line 182, in request
[denite]     res = self._session.request(name, *args, **kwargs)
[denite]   File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
[denite]     raise self.error_wrapper(err)
[denite] pynvim.api.nvim.NvimError: b"Vim(let):error caught in request handler '/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/vimrc_min/.dein/rplugin/python3/defx:function:_defx_do_action [['redraw', [
''], {'columns': 'icons:filename:size:git', 'auto_cd': False, 'prev_bufnr': 1, 'resume': False, 'sort': 'filename', 'listed': False, 'new': False, 'direction': '', 'show_ignored_files': False, 'winheight': 0, 'pr
ofile': False, 'search': '', 'buffer_name': 'default', 'winwidth': 0, 'split': 'no', 'cursor': 1, 'prev_winid': 1000, 'toggle': False}]]':"
[denite] Please execute :messages command.

It might have something to do with defx-git @kristijanhusak

@kristijanhusak

This comment has been minimized.

Copy link

kristijanhusak commented Jan 10, 2019

If you suspect it's a git column, try removing it from columns and test.

@petobens

This comment has been minimized.

Copy link

petobens commented Jan 10, 2019

@kristijanhusak the problem is indeed defx-git. That was what I was trying to convey in my previous comment. Removing git from the columns makes the error go away

@kristijanhusak

This comment has been minimized.

Copy link

kristijanhusak commented Jan 10, 2019

@petobens then open this issue on defx-git please.

@petobens

This comment has been minimized.

Copy link

petobens commented Jan 10, 2019

Done

@kristijanhusak

This comment has been minimized.

Copy link

kristijanhusak commented Jan 10, 2019

I tried to debug it, but i can't find what's the problem. @Shougo do you know maybe what can be a problem?

@Shougo

This comment has been minimized.

Copy link
Owner

Shougo commented Jan 11, 2019

OK. I have reproduced it And I have got the reason.
https://github.com/kristijanhusak/defx-git/blob/master/rplugin/python3/defx/column/git.py#L176
The line throws something exception.
If I add except, the error is gone.

@kristijanhusak

This comment has been minimized.

Copy link

kristijanhusak commented Jan 11, 2019

Thanks, I will look deeper into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment