tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.9k stars 214 forks source link

Make plugin autoloadable #96

Closed somini closed 6 years ago

somini commented 6 years ago

Similar to #78, to the latest master.

somini commented 6 years ago

Updated to the latest version.

tpope commented 6 years ago

The plugin fits into one 4k disk sector. What could possibly be the value in autoloading it?!

chrisbra commented 6 years ago

What could possibly be the value in autoloading it?!

At least in my case, I consider it a good approach to only loading anything until it is really needed.

somini commented 6 years ago

Another plus is "forcing" defining a clear separation between internal functions and an exposed API.

tpope commented 6 years ago

The counterpoint is that a single file plugin is significantly easier for ad hoc installations, like if you want to dump it on a random server, for example. It's a small thing, but it does win out over minor code organization concerns.

Furthermore, all functions in Commentary are internal, but autoloading requires me to expose them as an implementation detail. It doesn't force a clear separation, it prevents it. In dispatch.vim, for example, the official API is :Make (so you can swap in :make if it's not available, and avoid a hard dependency), but people are sometimes distracted by internal APIs that are necessarily exposed. The namespacing is great for when you do want to expose functions, but I have no reason to do that here.