Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useful snippets for documentation? #85

Open
knghtbrd opened this issue Sep 7, 2019 · 1 comment
Open

Useful snippets for documentation? #85

knghtbrd opened this issue Sep 7, 2019 · 1 comment

Comments

@knghtbrd
Copy link

knghtbrd commented Sep 7, 2019

I used to use vim-plug whose documentation included an if statement you could use to drop a vimrc/init.vim on a new system and the first time you started vim, it'd install all your plugins for you. Useful if you are constantly blowing away the contents of a machine and want to easily deploy a functional environment to it.

Unfortunately minpac doesn't have such a simple single-file you can download, but I came up with this:

" self-install minipac!
if empty(glob('~/.config/nvim/pack/minpac/opt/minpac'))
        let g:minpac_first_install = 1
        silent !git clone https://github.com/k-takata/minpac.git
                                \ ~/.config/nvim/pack/minpac/opt/minpac
endif

" regular minpac setup
packadd minpac
call minpac#init()

call minpac#add('k-takata/minpac', {'type': 'opt'}) " opt is required for minpac

" other plugins here

" actually install plugins
if exists('g:minpac_first_install')
        call minpac#update()
endif

This seems about as convenient as defining commands to call minpac's function. Unless I did it "wrong", in which case I'm sure the Internet will inform me of how I should've done it.

One niggle: My colorscheme is unavailable a few lines later in init.vim because minpac#update() hasn't finished installing it. I've protected it with a try block for now since I can run the single command myself once the job finishes.

@knghtbrd
Copy link
Author

knghtbrd commented Sep 7, 2019

Correcting myself, instances of g:minpac_first_install above should probably be changed to s:minpac_first_install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant