junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
33.7k stars 1.9k forks source link

Improve for https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation-of-missing-plugins #1264

Closed dracorp closed 5 months ago

dracorp commented 5 months ago

Explain the problem here ...

After adding the code from https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation-of-missing-plugins I get error:

Error detected while processing /root/.vim/vimrc:
line   32:
E21: Cannot make changes, 'modifiable' is off: fileencoding=utf-8

The line 32:

set fileencoding=utf-8

Bellow fixed this error:

" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
            \| PlugInstall --sync |  quit! | wincmd p | source $MYVIMRC
            \| endif

Of course, this can only occur in my configuration.

junegunn commented 5 months ago

I think it's a little strange to have an option that modifies the current buffer in the global configuration file. How about setting encoding instead?

When 'fileencoding' is empty, the same value as 'encoding' will be used (no conversion when reading or writing a file).

So I'll leave the code as it is. But thanks for the suggestion.