junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
34.1k stars 1.93k forks source link

Automatic installation on Windows? #837

Open fladd opened 5 years ago

fladd commented 5 years ago

The automatic installation instructions for Windows are missing.


junegunn commented 5 years ago

Can you provide one? I'm not familiar with the Windows environment, so I could use your help.

jakeloo commented 5 years ago
  if empty(glob('$LOCALAPPDATA\nvim\autoload\plug.vim'))
    silent ! powershell (md "$env:LOCALAPPDATA\nvim\autoload")
    silent ! powershell (New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', $env:LOCALAPPDATA + '\nvim\autoload\plug.vim')
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  endif
  call plug#begin('$LOCALAPPDATA\nvim\plugged')

In the .vimrc. This should automatically install plug to %LOCALAPPDATA%\nvim\autoload.

fladd commented 5 years ago

This unfortunately does not work:

Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At line:1 char:1
+ (New-Object Net.WebClient).DownloadFile('https://raw.githubuserconten ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException
janlazo commented 5 years ago

Is it acceptable to install scoop which can install curl? The same instructions with curl should apply on Windows, save for the user config directory (ie. ~/vimfiles/ for vim, output of stdpath('config') for Neovim).

RomanDanyk commented 4 years ago

This snippet works for me:

if empty(glob('$LOCALAPPDATA\nvim\autoload\plug.vim'))
  silent ! powershell -Command "
  \   New-Item -Path ~\AppData\Local\nvim -Name autoload -Type Directory -Force;
  \   Invoke-WebRequest
  \   -Uri 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  \   -OutFile ~\AppData\Local\nvim\autoload\plug.vim
  \ "
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
KarboniteKream commented 4 years ago

Windows 10 ships with curl now, so you can use this as well (works on Linux, macOS and Windows):

let g:dotvim = '...'

if empty(glob(g:dotvim . '/autoload/plug.vim'))
    silent execute '!curl -fLo ' . g:dotvim . '/autoload/plug.vim --create-dirs '
        \ . '"https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"'
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif