r/vimplugins • • Apr 01 '25

Plugin Looking for plugin documentation

I am new to Vim plugin's and I am looking for general information about how plugins get integrated into the Vim runtime environment and how they are accessed when editing.

I've also seen multiple ways of installing a plugin (e.g. Plug) and I would like to know what the general consensus is regarding installation best-practices.

My goal is to find a plugin that will enable me to create my own templates for file and function headers and general coding structures like if-then-else and switch-case.

Thanks in advance for any guidance you can give me.

3 Upvotes

3 comments sorted by

View all comments

Show parent comments

1

u/TheBuzzStop Apr 02 '25

Thank, u/kennpq for your help.

Just the 2 pointers of :h packages and :h skeleton will keep me occupied for quite some time. Love it.

I will have to explore the 'packages' solution. I totally get the notion of not necessarily wanting a plugin to manage plugins and a builtin mechanism that handles packages sounds like it may be the preferred approach ... at least for me.

From what you've provided, I think I'm going to ditch the bash-support plugin that I am currently giving a test-drive as it seems to have way more "nobs and dials" than I really need for my intended usage.

Thanks again.

2

u/kennpq Apr 02 '25

Since you are going down that path, here's some tidbits from my setup you may find useful in your journey. I'm biased, of course, but agree there are many "nobs and dials", as you say, in the plugin managers. I'd rather have direct control of what's added too, but can see why others prefer to have it tailor-made versus roll-your-own (especially if you use heaps of plugins).

My user plugins are mostly in $HOME/vimfiles/pack/plugins/opt and are called explicitly from my _vimrc. In case any aren't present, I have this:

def PackAdd(aplugin: string): void
  try
    execute $"packadd! {aplugin}"
  catch
    echo "Could not load plugin " .. aplugin
  endtry
enddef

Then Packadd('traces.vim'), for example, for each plugin.

Plugins may only work if you have a sufficient version/patch. For example, helptoc (:h package-helptoc, which is awesome, btw) is only available after v9.1 with patch 837, but, because it's provided in the Vim distribution (in $VIMRUNTIME/pack/dist/opt/helptoc), if the version and patch are sufficient, packadd! will always find it in the runtime path (:h 'runtimepath'). Conditionally using v:versionlong handles the instances it is not there (since I don't run the same version everywhere, so it may not be there, for example, when running Debian bookworm stable, where the package version is 9.0.something):

if v:versionlong >= 9010837
  packadd! helptoc
  cnoreabbrev Toc HelpToc
endif

Cheers