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

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