daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
716 stars 57 forks source link

Is there any way to detect that neovim-gtk is running? #133

Closed unclechu closed 5 years ago

unclechu commented 5 years ago

I'd like to detect if it's neovim-gtk is running or other GUI in my ginit.vim, is there any way to do so?

neovim-gtk uses GUI font setting format which is different than for neovim-qt, so if I use same ginit.vim for both neovim-gtk and neovim-qt I'm getting errors pushed back from GUI without ability to catch it. To avoid that I could detect if it's neovim-gtk to run one command and another for other GUIs.

See my ginit.vim: https://github.com/unclechu/neovimrc/blob/f1d41a0/ginit.vim#L26-L38

wezm commented 5 years ago

I'd like to detect if it's neovim-gtk is running or other GUI in my ginit.vim, is there any way to do so?

Yep, like this:

" NeovimGtk
if exists('g:GtkGuiLoaded')
  " Use GTK  clipboard
  let g:GuiInternalClipboard = 1
  " Disable native popup an use vim one instead
  call rpcnotify(1, 'Gui', 'Option', 'Popupmenu', 0)
endif
unclechu commented 5 years ago

@wezm Is this working only for neovim-gtk? Any chance it could clash with other GUI implementations?

unclechu commented 5 years ago

@wezm Thanks, it works for me for now. But I personally think this hack isn't safe and robust one. I'd like to explicitly detect if it's exactly neovim-gtk.

unclechu commented 5 years ago

@wezm Thanks, it works for me for now. But I personally think this hack isn't safe and robust one. I'd like to explicitly detect if it's exactly neovim-gtk.

daa84 commented 5 years ago

set g:GtkGuiLoaded at start exactly for this purpose

unclechu commented 5 years ago

Okay, I'm taking it as absolutely unique for neovim-gtk and closing this issue as solved.