Vim-plug: Terrible magic of plug#end()

Created on 14 Jan 2016  Â·  9Comments  Â·  Source: junegunn/vim-plug

According to the documentation, plug#end() should only add the plugins to &runtimepath, but it also includes commands filetype plugin indent on and syntax enable.
It might be sensible to someone else, since it help them to simplify their .vimrc, but when it comes to debugging, the only way to disable them is by changing the code inside vim-plug.

I got this because I found comment the line filetype plugin indent on in my own .vimrc refuse to work after I use vim-plug, that confuse me a lot.

Please, at least add documentation for that.

invalid

Most helpful comment

It's a design choice I made from the beginning ("Should be easier to setup, require less boilerplate code") when I started vim-plug, and changing it now will break many users' configurations. I can understand that some don't like it, but there are also others, myself included, who like the idea that vim-plug does the things that are required to enable most plugins. vim-plug is not just a runtimepath manager, but a plugin manager that is responsible for setting up the environment where plugins work out of the box without extra configuration, so I don't think it's an abomination that it enables some settings most plugins require. I can add more description to the README page though.

As pointed out in the above, you can easily undo the things plug#end() does with just a single line in your configuration. And vim-plug is an open-source project after all, you can always change it to your liking.

Also related: #83, #156

All 9 comments

I'm not sure what the problem is. Having extra filetype plugin indent on in your .vimrc is unnecessary but it does not break anything and it barely affects the startup time.

the only way to disable them is by changing the code inside vim-plug

...
call plug#end()
filetype off
syntax off

I have mixed feelings about your suggestion on the documentation; make it as complete as possible vs. do not waste people's time with implementation details they don't need to care. People simply want to use some plugins, and vim-plug does what needs to be done. I'll just update the sentence to more precisely describe what it does in an abstract way.

@junegunn could we possibly reopen?

I do have an actual issue.. I don't mind it setting syntax on or even filetype on, but it actually seems to enable some kind of autoindent behaviour for me which is definitely not what I want.. (and I don't know how to undo that) - specifically, filetype off doesn't undo it.

Calling plug#end seems to enable indentexpr, indentkeys, suffixesadd, include, includeexpr, formatoptions, comments, commentstring and balloonexpr. Are you telling me I really need to unset all those if I want to use plug?

(And yes, all those problems dissapear when I comment out that filetype plugin indent on from plug.vim.)

filetype indent off right after call plug#end() #156

@himdel Yeah, filetype indent off will do. See :help :filetype-overview.

@junegunn could you please add this to the README? Took me ages to find that your plugin was doing this.

@junegunn, if that command is not necessary for your script to work and harms your users you should remove it.

Links to the offending line(s?°):
Permalink: https://github.com/junegunn/vim-plug/blob/a4aac4cf567bb060356694991064f687f8758a81/plug.vim#L276
Current revision: https://github.com/junegunn/vim-plug/blob/master/plug.vim#L276
° (Dunno if the syntax enable 3 lines below could also cause trouble for some users.)


This issue is pointed out in a popular thread on the Vi[m] StackExchange since recently (by @laktak): http://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers?noredirect=1&lq=1#comment18609_397


@junegunn, you may also want to tack the

… and initialize plugin system

plug#end() description supplement, from your above Jan 14 issue-closing commit https://github.com/junegunn/vim-plug/commit/03504f26b1f5f7d17e21fbf4bee27a45172d8348, onto the respective comment a few lines below, in the vim-plug vimrc section code example: https://github.com/junegunn/vim-plug/commit/03504f26b1f5f7d17e21fbf4bee27a45172d8348?diff=unified#diff-04c6e90faac2675aa89e2176d2eec7d8R92

It's a design choice I made from the beginning ("Should be easier to setup, require less boilerplate code") when I started vim-plug, and changing it now will break many users' configurations. I can understand that some don't like it, but there are also others, myself included, who like the idea that vim-plug does the things that are required to enable most plugins. vim-plug is not just a runtimepath manager, but a plugin manager that is responsible for setting up the environment where plugins work out of the box without extra configuration, so I don't think it's an abomination that it enables some settings most plugins require. I can add more description to the README page though.

As pointed out in the above, you can easily undo the things plug#end() does with just a single line in your configuration. And vim-plug is an open-source project after all, you can always change it to your liking.

Also related: #83, #156

@junegunn that was a very reasonable way to handle it.

Was this page helpful?
0 / 5 - 0 ratings