3

If possible, I would prefer to not start using a package manager for now.

I'm trying to manually install this plugin for editing JS files: https://github.com/pangloss/vim-javascript

I have looked around, and tested several things, but for some reason I can't get it to work.

How would you go about "manually" installing the pangloss plugin without using pathogen, or a package manager?

It's my first question here. Hope this makes sense.

4
  • @D.BenKnoble Thanks! yes, I have a vim with packages support. Would be happy to hear about your suggestions. Commented Aug 23, 2019 at 20:18
  • Thanks for the detailed answer! It makes sense, and I can install pangloss/vim-javascript. It seems to work now! Commented Aug 23, 2019 at 20:54
  • I tried upvoting, but it seems I haven't enough rep. Will wait the ~24h for accepting an answer. Thanks. Commented Aug 23, 2019 at 21:40
  • Ah, but of course. Apologies
    – D. Ben Knoble
    Commented Aug 23, 2019 at 21:50

1 Answer 1

4

TL;DR Use :h packages

You will need

  • the plugin code (github is easiest, though if you just have a copy of the source tree lying around, that works too)

A brief history of time managing plugins1

I won't go into extreme detail here unless it is requested. This is mostly a background section, and can be skipped if needed.

In the dark ages, you used to need to put all plugin code next to each other, so (for example) your ~/.vim/plugin would have

  • plugin-a.vim
  • unrelated-plugin-b.vim
  • etc.

Updating and removing plugins was a nightmare: what did you do if an update removed a file? How did you know which files belonged with which plugins and needed deletion?

Pathogen gave us bundle to keep things separate, and that's what packages do too2.

Pathogen (typically) adds each directory under, e.g., ~/.vim/bundle to the 'runtimepath'. In other words, you could have

  • ~/.vim/bundle/mypluginhere, and
  • ~/.vim/bundle/pangloss-javascript-here

But you still managed those directories yourself. (Other plugin managers can do that for you, but you don't need—or always want—that).

The advantage of this is described Plugin layout in the Dark Ages and A New Hope: Plugin Layout with Pathogen.

Packages bring to vim8 what pathogen had already done for previous vim versions, and they do so natively. Packages provide a way of adding segmented components to the 'runtimepath' (remember that this path controls where vim looks for plugin code, autoload scripts, filetype plugins, &c.).

Enter packages

Packages use 'packpath', which is a bit like a combination of bundle and 'runtimepath'.

What you need to know is that you can put a complete copy of the plugin source tree in ~/.vim/pack/<any-name-you-want>/start/<plugin-name>. (The adept user may want to investigate opt as well.)

That's it. It will be loaded for you by vim.

Some management strategies with git

  1. git-clone: this strategy is for users who just want to clone the plugin and have it run. Typical interaction looks like
# git clone <path/to/repo> ~/.vim/pack/<other-plugins>/start/<plugin-name>
  1. git-submodule: this strategy is for folks like me who keep their dotfiles/vim configs in version control. Typical interaction looks like
# git -C <dotfile-dir> submodule add <path/to/repo> <dotfile-vim-dir>/pack/<other-plugins>/start/<plugin-name>

  1. I omit all plugin managers except pathogen, which is actually a 'runtimepath' manager. This little lie won't hurt anyone, though.
  2. They have a slightly broader use case. I'm aware, but I don't find it necessary for the purposes of this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.