2

per the recommendation in the vim-plug wiki: https://github.com/junegunn/vim-plug/wiki/extra, I've added the following snippet to my vimrc:

" Install missing plugins on Vim startup
autocmd VimEnter *
  \  if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
  \|   PlugInstall --sync | q
  \| endif

This does indeed cause any missing plugins to be installed on Vim startup, but on subsequent launches on Ubuntu (18.04 LTS, with apt's version of vim and a version I built from source) the body of the if statement continues to evaluate to 1 (verified with echomsg), so the plugin installation screen flashes every time I open vim.

This is not the case on macOS; once the plugins are installed for the first time, the body of the if statement no longer evaluates to 1, and the PlugInstall screen no longer displays.

How would I go about fixing this?

  • 2
    Can't reproduce, it works fine for me. You need to check result of filter(...), it's not empty. – dedowsdi Dec 9 '19 at 6:24
  • 1
    You should provide us the result of the filter command so that we can have an idea of what is happening. Also if I may add my two cents: Is it really worth it to add to your vimrc an autocommand which will be executed every time you start vim and which is already causing some issues just to run PlugInstall once which you could do manually or from the script which installs your dotfiles to a new machine? And finally your autocommands should always be in a :h :augroup. – statox Dec 9 '19 at 11:09
  • 1
    Thank you both for your replies. Checking the output of filter helped diagnose the problem, my vimrc also contained the following line: " If installed using Homebrew Plug '/usr/local/opt/fzf' which referred to a program that wasn‘t installed but also couldn‘t be installed by vim-plug. Installing it properly fixed the problem. statox, I will consider your comments about including this section at all, it might not be worth the trouble. Thank you both! – Paul Roever Dec 9 '19 at 12:24
  • @PaulRoever Please post that as an answer. Thanks! – filbranden Dec 9 '19 at 14:38
2

Checking the output of filter helped diagnose the problem, my vimrc also contained the following line:

" If installed using Homebrew
Plug '/usr/local/opt/fzf'

which referred to a program (fzf) that wasn't installed but also couldn't be installed by vim-plug. Installing it properly fixed the problem.

  • Nice to see that you found the solution to your problem. Don't hesitate to mark your answer as accepted when you can. – statox Dec 10 '19 at 17:27
  • Ah, yes. I work around this by checking for the executable when adding the plugin: if executable('go') | Plug 'fatih/vim-go', {'for': 'go'} | endif etc. – muru Dec 11 '19 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.