0

I'm developing a vim plugin. There will be some global-level functionality that's not specific to a particular filetype.

Is there some kind of registry of commands being used by vim packages?

How can I ensure that some other module isn't already using the command name that I want to use? Making it start with the full module name seems cumbersome at best.

  • 3
    You should read :h write-plugin which describe exactly what you want to do and a bit lower in the page :h using-<Plug> is also pretty interesting :) – statox Jun 12 at 11:57
  • Hmm I was thinking to make a custom auto-complete keybinding (i.e. CTRL-X CTRL-something). I haven't really RTFMed yet though so this may be misguided. – intuited Jun 12 at 13:15
  • 3
    The "too broad" option to close a question says "Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once." and I tend to think that your question is too broad by this definition, especially if you didn't took the time to read any doc at all. – statox Jun 12 at 13:19
  • Edited to focus on commands only. – intuited Jun 13 at 1:22
1

From someone who has published 100+ Vim plugins:

If you spend some time to find a clear and precise name for your custom command, the chances of clashes actually are pretty small. Don't use abbreviations or prefixes (prefer :FrobnizeControlModule instead of :FCM or :FCtrlMod; people can define shorter aliases themselves) and in case of doubt, a longer, more exact variant allows for future variations (and most Vim users do know about the disambiguation rules and command-completion).

If you use :help autoload-functions instead of script-local functions for the command implementation (and definitely not global functions!), people can duplicate your command definition, redefine a custom name themselves, and :delcommand yours (if they really hate it / have a clash with their own customizations).

There's much more potential for clashes and plugin overlaps in mappings - therefore, Vim has a lot of infrastructure and conventions for those (:help using-<Plug>). If there's really a command name clash with a very popular plugin, and you weren't aware of it, people will tell you about it as long as you make it easy for them to contact you (which today mostly means publishing the plugin on GitHub and using its issue tracker).

  • To add to that, I sometimes provide only autoload functions, and let the user define their "interface" (command, mapping, etc.) – D. Ben Knoble Nov 7 at 14:42

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.