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

Zeavim starts Zeal in foreground #18

Closed
lervag opened this issue Apr 11, 2017 · 6 comments
Closed

Zeavim starts Zeal in foreground #18

lervag opened this issue Apr 11, 2017 · 6 comments

Comments

@lervag
Copy link

lervag commented Apr 11, 2017

Hi. I'm curious if I am misunderstanding something: When I start Zeal through zeavim, the Zeal window is blocking Vim. Is that by intention?

I'm on Vim 8.0.427 on Arch Linux. This behaviour happens with both vim and gvim. I use the following settings:

let g:zv_disable_mapping = 1
let g:zv_zeal_args = '--style=gtk+'
let g:zv_file_types = {
    \ 'help' : 'vim',
    \ 'python' : 'python 3',
    \ }

nmap gzz <plug>Zeavim
xmap gzz <plug>ZVVisSelection
nmap gz <plug>ZVMotion

I would expect that the Zeal window opens as a background process, such that I could read the docs while editing the file. The current behaviour requires me to close the Zeal window before I continue editing the file.

@KabbAmine
Copy link
Owner

No this is not expected, vim should not be blocked.
Zeal is executed in the background and have or not the focus depending of g:zv_keep_focus's value (see #17).

There is the command used in the plugin, try it directly and see what happen:

" Linux
:silent exe "!zeal --style=gtk+ foo:bar 2> /dev/null &" | redraw!
" Windows
:silent exe "!start path/to/zeal.exe foo:bar &" | redraw!

@lervag
Copy link
Author

lervag commented Apr 11, 2017

Ah, if I disable the g:zv_keep_focus, things work as expected.

IMHO, I think it is better to separate the focus command from the zeal command. That is, I think you should have two execute commands, one that only opens the zeal window, and one that runs the focus command. Something like this:

let l:cmd = printf('!%s%s %s %s %s &',
      \ (has('unix') ? '' : 'start '),
      \ g:zv_zeal_executable,
      \ g:zv_zeal_args,
      \ shellescape(l:docset . l:query),
      \ (has('unix') ? '2> /dev/null' : '')
      \ )
silent execute l:cmd

if g:zv_keep_focus
      \ && has('unix')
      \ && executable('wmctrl')
      \ && v:windowid !=# 0
  silent execute 'wmctrl -ia' v:windowid
endif

I would also claim that the following is more readable:

silent execute '!'
      \ . (has('unix') ? '' : 'start ')
      \ . g:zv_zeal_executable
      \ . ' ' . g:zv_zeal_args
      \ . ' ' . shellescape(l:docset . l:query)
      \ . (has('unix') ? ' 2> /dev/null' : '')
      \ . ' &'

Although clearly this is a subjective matter. :)

@KabbAmine
Copy link
Owner

Ah, if I disable the g:zv_keep_focus, things work as expected.

Strange, this one is applied only when wmctrl is installed and do not block vim either (I should add it to the documentation).

I think it is better to separate the focus command from the zeal command.

Good idea, I'll do it later when having time ⌚

I would also claim that the following is more readable:...

Nah 👅 I prefer the good old printf format, it makes clear how much elements and spaces we have in our string.

@lervag
Copy link
Author

lervag commented Apr 11, 2017

I have wmctrl installed, so it should work. For some reason, it does not. But no worries, I don't mind having it disabled, and now it works.

So far I like your plugin, good work! I would prefer a similar plugin that worked without external guis, but that is only a minor drawback. Zeal seems to work pretty well.

@lervag lervag closed this as completed Apr 11, 2017
@KabbAmine
Copy link
Owner

Have you tried dasht? It uses the same docsets as dash/zeal but can render them in a terminal.

@lervag
Copy link
Author

lervag commented Apr 11, 2017

Yes, and vim-dasht, but I couldn't get it working quite as I wanted. I might look more into it later, though, thanks!

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

No branches or pull requests

2 participants