-
Notifications
You must be signed in to change notification settings - Fork 41
Add maktaba#plugin#Register that never touches runtimepath #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
So now we have three types of plugin "installish"ness?
First off, I'm not sure I see the point. What does the registered state buy us? Secondly, the names are quite confusing. I would strongly expect "installation" to include both adding to the runtimepath and sourcing the instant files. |
There is no "registered but not initialized" state, and "install" does what you're suggesting it should (rtp + instant files). If you're referring to the way I split up the script-local functions, that was just a quirk of the code flow, and I struggled to come up with names for the different blobs of logic. Now I've merged some of the functions together to help that part of code explain itself better (see the force_rtp arg). I agree there are a lot of variants of "installish"ness. Part of the reason I wanted to create something with more tightly-defined behavior and call it "Register" is that the term "Install" is so murky. Just for the sake of argument, turn the question around: If we only had In fact, every major plugin manager already knows how to handle rtp without maktaba's help. If any of the |
This is where things get murky between maktaba's provision of utility functions and provision of a plugin format. Ideally, any plugin manager that actually adopts maktaba should also forgo its own rtp manipulation in favor of maktaba#rtp (instead of duplicating the functionality). That said, there probably is a purpose for a "I've already handled the rtp stuff, handle the other stuff" function. Remind me again why we can't just have #Install not manipulate the rtp if it finds that the plugin is already on the rtp? (Or is the problem that checking the rtp is slow?) |
We do that, but the detection isn't quite perfect and probably never will be. When it fails, you get two different versions of the same path added to your runtimepath. For instance, my ~/.vim/ is a symlink, and I end up with both |
call maktaba#rtp#Add(l:plugin.location) | ||
if l:already_installed | ||
if !empty(a:settings) | ||
call s:ApplySettings(a:plugin, a:settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When are the settings applied if we aren't l:already_installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In s:InitPlugin (or, as you would have it, s:LoadInstantFilesAndApplySettings). They're applied in a precise sequence, after the flags are defined but before the instant/ files are sourced.
All right, the feature is fine by me, but I still find the names very confusing. Can we be more explicit about which function does what? I'd suggest |
I could just inline the code into s:RegisterPlugin if you'd rather. It's only used in that one place, and that way at least you can clearly see the parallel s:ApplySettings in both l:already_installed branches. Depending on which reads better for you, I could even pivot the whole thing into if !l:already_installed
" Maybe force rtp.
" Source flags.
endif
call s:ApplySettings(a:plugin, a:settings)
if !already_installed
" Source the rest of instant/ and define g:installed_PLUGIN.
endif |
The script-local code is fine, I'm worrying about the name of the user-visible |
Oh, hmm… The name "Install" was unfortunately vague, but I wouldn't want to overcompensate on the "Register" naming. What it does is everything maktaba absolutely must do to fulfill its contract with plugins that depend on maktaba. Something like "Init", "Setup", or "RegisterAndInit" might suggest a bit more of its side-effecty nature, but |
Indeed. If I had known what a clusterfuck this was going to be, I'd have named |
Maktaba as a plugin framework should allow plugins to register/init themselves via maktaba without side effects like modifying runtimepath that should generally be left up to plugin managers. This change adds a
maktaba#plugin#Register
function to do just that. Also changes allmaktaba#plugin#GetOrInstall
calls in maktaba tomaktaba#plugin#Register
because:maktaba#plugin#Detect
andmaktaba#plugin#Enter
, we can assume that the plugin is already on runtimepath and skip the overhead of checking, andmaktaba#rtp
utilities.Resolves #50.