Skip to content
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

gnvim evaluates has('gui_running') as false #97

Closed
dbarnett opened this issue Aug 18, 2019 · 4 comments
Closed

gnvim evaluates has('gui_running') as false #97

dbarnett opened this issue Aug 18, 2019 · 4 comments

Comments

@dbarnett
Copy link

When I start up gnvim and try

:echo has('gui_running')

it responds with 0, and it doesn't seem to try to load my $XDG_CONFIG_HOME/nvim/ginit.vim. Is that an oversight, or somehow intentional?

@justinmk
Copy link

current workaround is to check nvim_list_uis(), e.g.:

:echo !nvim_list_uis()[0]['ext_termcolors']  " This means we probably have a GUI.

Nvim core is working on a UIAttach autocmd that will better inform configs/plugins if a GUI is connected. neovim/neovim#6917

I suppose Nvim could shim has('gui_running') to return true if any GUI is connected, although scripts often make bad assumptions based on that, which don't always hold in the case where multiple UIs are connected.

@vhakulinen
Copy link
Owner

As already mentioned, has('gui_running') isn't supported by neovim currently. As a workaround, with gnvim you can use exists("g:gnvim").

@dbarnett
Copy link
Author

Gotcha, and I just found a parallel discussion in neovim-qt tracker: equalsraf/neovim-qt#94 (comment). I'm just getting back into the neovim world and not up to speed on some of these gotchas.

@Lythenas
Copy link

neovim/neovim#6917 was merged and is in nvim 0.4.0 so you can use an autocmd to setup your gui stuff. Note however (at least for me) the UIEnter event is still fired even when using the terminal. But for me the chan in v:event is 0 in the terminal and 1 using gnvim.

I'm using something like this:

function! s:ui_enter()
  if get(v:event, "chan") == 1
    " do your gui setup
  endif
endfunction

au UIEnter * call s:ui_enter()

Also I'm not very experienced with vimscript so if this can be done better please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants