Search code examples
vimneovimviml

Run vim command when preview window is open


In neovim, when my completion plugin is triggered, it will print out the methods signature in a preview window

enter image description here

The preview window though, contains line numbers which is something I want to disable. So far, I though this would work

function! Preview_func()
  if &pvw
    setlocal nonum
   endif
endfunction

autocmd * BufCreate call Preview_func()

But no dice. Any ideas?


Solution

  • In autocommand definition file pattern ( here: * ) should come after event ( BufCreate ); also base on which autocompletion plugin you are using there may be an entrance to preview window or not so also check with WinEnter event:

    autocmd WinEnter * call Preview_func()