Errors when using do_action with custom vim function
See original GitHub issueWith vimfiler
I can use the following to open ranger file manager at the current directory:
if executable('ranger')
nmap <buffer>ge <Plug>(vimfiler_cd_vim_current_dir)
\ <C-u>:call <SID>TmuxSplitCmd('ranger')<CR>
endif
where the TmuxSplitCmd
function is:
function! s:TmuxSplitCmd(cmd)
if empty('$TMUX')
return
endif
silent execute '!tmux split-window -p 30 -c '. getcwd() . ' ' . a:cmd
endfunction
I’m trying to do the same with defx:
if s:is_linux && executable('ranger')
nmap <silent><buffer><expr>ge defx#do_action('change_vim_cwd',
\ "call <SID>TmuxSplitCmd('ranger')")
endif
but I get the following error
Error detected while processing function defx#_do_action[6]..defx#util#rpcrequest[15].._defx_do_action[1]..remote#define#request:
line 2:
error caught in request handler '/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx:function:_defx_do_action [['change_vim_cwd', ["call <SNR>1_TmuxSplitCmd('ranger')"], {
'columns': 'mark:filename:type', 'auto_cd': False, 'prev_bufnr': 7, 'resume': False, 'listed': False, 'new': False, 'fnamewidth': 100, 'direction': '', 'winheight': 0, 'profile': False, 'search': '', 'buffer_name
': 'default', 'winwidth': 0, 'split': 'no', 'cursor': 22, 'toggle': False}]]':
Traceback (most recent call last):
File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx/__init__.py", line 41, in do_action
self._rplugin.do_action(args)
File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx/rplugin.py", line 37, in do_action
view.do_action(args[0], args[1], args[2])
File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx/view.py", line 321, in do_action
ret = action.do_action(self, defx, action_name, context)
File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx/action.py", line 38, in do_action
action.func(view, defx, context)
File "/home/pedro/git-repos/private/dotfiles/vim/bundle/.cache/init.vim/.dein/rplugin/python3/defx/action.py", line 74, in _change_vim_cwd
view._vim.command(f'silent {command} {defx._cwd}')
File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/api/nvim.py", line 287, in command
return self.request('nvim_command', string, **kwargs)
File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/api/nvim.py", line 182, in request
res = self._session.request(name, *args, **kwargs)
File "/home/pedro/.local/lib/python3.7/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
raise self.error_wrapper(err)
pynvim.api.nvim.NvimError: b'Vim(call):E488: Trailing characters'
Error detected while processing function defx#_do_action[6]..defx#util#rpcrequest:
line 15:
E171: Missing :endif
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
folding - How-to handle errors in Vim Script?
In my .vimrc file, I have the following function, which folds the licensing ... Edit: complete solution (using Bryan Ross answer).
Read more >Execute with system function results in error of `undefined ...
There are a couple of problems here. First of all, you want to run an ex command, so you don't need the :norm!...
Read more >custom keymap function not working after update to HEAD
local map = vim.keymap.set local function map_group(group, ... got nil stack traceback: [C]: in function 'error' vim/shared.lua: in function ...
Read more >Act on text objects with custom functions - Vim Tips Wiki
In all cases, ultimately it is DoAction that gets called. The algorithm argument tells the user-defined function that should be called, and type ......
Read more >coc-explorer
Install by coc.nvim command: :CocInstall coc-explorer; Configuration custom vim mapping :nnoremap <space>e :CocCommand explorer<CR>; Open explorer <space>e
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why don’t read the documentation?
call
action argument must befunction
instead ofcommand
.I’m afraid I don’t follow. None of the following works: