vifm / vifm

Vifm is a file manager with curses interface, which provides Vim-like environment for managing objects within file systems, extended with some useful ideas from mutt.
https://vifm.info
GNU General Public License v2.0
2.75k stars 125 forks source link

Vifm requires a console that can support color when vifm starts executing in vim/vifm.vim in gvim #500

Open z0rel opened 4 years ago

z0rel commented 4 years ago

I'm trying to run Vifm on Gentoo Linux in gvim 8.1.1486 through vifm/vifm.vim plugin. When I run it, there an error occurs with message Got non-zero code from vifm: 1

When I run the !vifm, it is given :

Vifm requires a console that can support color
Got non-zero code from vifm: 1.

Search in the vifm source code displays the following:

./vifm/src/ui/ui.c: vifm_finish("Vifm requires a console that can support color.");
if(!has_colors())
{
  vifm_finish("Vifm requires a console that can support color.");
}

has_colors - is the function from curses.h:

./vifm/configure.ac:AC_CHECK_FUNC([has_colors], [], [AC_MSG_ERROR([has_colors() function not found.])])

Because of this code, Vifm does not work in my GUI version Gvim on Linux. However, in Windows Vifm fine starts in gvim. Also, if I run :terminal vifm, vifm also fine starts in GVim.

xaizek commented 4 years ago

What's your version of vifm.vim and are there any settings for it?

The latest version will use :terminal inside gvim when it's available. Otherwise a terminal will be used instead (xterm by default, specified via g:vifm_term).

:!vifm inside gvim won't work properly anyway (it's not meant to).

z0rel commented 4 years ago

My version vifm.vim is installed through Vundle and the default version is the master (9db471361e167453db7ccb7940ea591329e0adf2, xaizek 2019-11-30 00:17:54)

Using :debug Vifm, I found that the error occurs after the call:

function <SNR>71_StartVifm
line 97: let buf = term_start(['/bin/sh', '-c', termcmd], options)

and only if gvim is executed from the click on kde plasma gvim.desktop. If I launch givm from the Konsole in the same directory ($HOME) and then I enter :Vifm, the error does not occur.

The error is following:

The error was found during processing function <SNR>71_StartVifm[98]..VifmExitCb:
line    1:
E121: Undefined variable: b:data
line    2:
E121: Undefined variable: data
line    8:
E121: Undefined variable: data
line   11:
E121: Undefined variable: data
E116: The parameters for the function type(data.cwdjob) == v:t_job are incorrect
line   14:
E121: Undefined variable: data
E116: The parameters for the function <SNR>71_HandleRunResults are incorrect
function <SNR>71_StartVifm[98]..VifmExitCb   

I tried to debug the cause of premature call the VifmExitCb, but I do not understand how to do it.

xaizek commented 4 years ago

Undefined variable: b:data

This is more of a symptom as well (although this could be handled better), term_start() fails fast and calls calllback before b:data is set. What's interesting is why it fails.

only if gvim is executed from the click on kde plasma gvim.desktop

You can try doing :read !env in gvim run from plasma and from command-line and look for differences.

As a workaround you can always set g:vifm_embed_term to 0 to make vifm run outside Vim (and probably configure Konsole to be used for it).