airblade / voom

A simplest-thing-that-works Vim plugin manager. Use with Vim 8 or Pathogen.
MIT License
29 stars 9 forks source link

Feature Request: Post install action #13

Open Integralist opened 7 years ago

Integralist commented 7 years ago

Heya,

So I'm noticing a lot of plugins using this sort of 'post-install' action:

https://github.com/junegunn/vim-plug#example

One such example being:

https://github.com/roxma/nvim-cm-tern

Is this something you think might be useful to include, or does it push the 'minimalism' focus of voom a bit too much.

Just asking as I could look to open a PR at some point if you thought it would be interesting to include

airblade commented 7 years ago

Sounds like a slippery slope ;)

I don't use any plugins requiring a post-install step but if I did I'd probably want voom to support that. We would need to figure out:

Integralist commented 7 years ago

OK, cool. I'll have a think about it and put some further comments here when I do.

Rycieos commented 7 years ago

I have a feature for the same problem in my voom inspired profile-manager, if I can give my input.

An example config:

dot-files() {
  repo_url="https://github.com/Rycieos/dot-files.git"
  files=(
    ["profile-manager/config"]="~/.config/profile-manager/config"
  )
  dot-files_post_update() {
    example command
  }
}

I have both a post_update hook and a post_install hook, which run after their respective actions.

For voom, this would be much trickier, since right now the config only has plugin names specified. I would think that the config format would have to change completely to make it work.

eNV25 commented 2 years ago

Maybe this could be done with git hooks? https://git-scm.com/docs/githooks

eNV25 commented 2 years ago

Example:

example/plugin post-merge:"make" post-merge:"echo Finished building plugin"

Would generate:

#!/bin/sh
# ~/.vim/pack/voom/start/plugin/.git/hooks/post-merge
make
echo Finished building plugin
airblade commented 2 years ago

@eNV25 Presumably that would mean creating a directory for the plugin before cloning, writing the hook files, then cloning – instead of just cloning. It feels a little too fiddly to me. I like your example syntax though.

How about something like:

example/plugin post-install:"..." post-update:"..."

Or using = instead of :.

@Integralist @Rycieos Would that work for you?

Integralist commented 2 years ago

Oh hey 👋 I see I opened this 5 years ago. I'm afraid I've moved on since then. So best not to wait on my input. Thanks ♥️

Rycieos commented 2 years ago

Looks good to me.

eNV25 commented 2 years ago

@eNV25 Presumably that would mean creating a directory for the plugin before cloning, writing the hook files, then cloning – instead of just cloning. It feels a little too fiddly to me. I like your example syntax though.

I didn't think about that at first. Anyway, it seems git has the perfect option --template for this.

tmpdir="$(mktemp -d)"
mkdir -p "$tmpdir/hooks/"
echo ... > "$tmpdir/hooks/pre-merge"
git clone https://git.example.com/repo.git repo --template="$tmpdir" # or
GIT_TEMPLATE_DIR="$tmpdir" git clone https://git.example.com/repo.git repo
rm -rf "$tmpdir"

How about something like:

example/plugin post-install:"..." post-update:"..."

Or using = instead of :.

That would be fine too. I used the name post-merge above because it's the name of the git hook that needs to be created, but a more intuitive name is probably better.

I would assume post-install is executed once after install (without a hook), and post-update is run every time after git pull. The hook for post-update should probably be updated before first install $ voom, and before update $ voom update.