From dbe24697f35e2d56b1e69b9ab0790fb238ac35e9 Mon Sep 17 00:00:00 2001 From: jdhao Date: Sat, 31 Oct 2020 00:34:15 +0800 Subject: [PATCH] Move vim-plug installation outside of config. It is a one-time thing. Do not waste precious time checking it every time we start Nvim. --- docs/README.md | 41 ++++++++++++++++++++++++++++++++++++----- plugins.vim | 29 +++++++---------------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/docs/README.md b/docs/README.md index 84ae32e..522aa45 100644 --- a/docs/README.md +++ b/docs/README.md @@ -156,6 +156,38 @@ Make sure that you can call `nvim` from the command line after all these setups. # Setting up Nvim +## Install plugin manager vim-plug + +I use [vim-plug](https://github.com/junegunn/vim-plug) to manage all my +plugins. We need to install vim-plug on our system first. + +For Windows, if curl is installed, use the following command: + +``` +curl -fLo ~\AppData\Local\nvim-data\site\autoload\plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + +Or execute the following command on PowerShell: + +``` +md ~\AppData\Local\nvim-data\site\autoload +$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' +(New-Object Net.WebClient).DownloadFile( + $uri, + $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath( + "~\AppData\Local\nvim-data\site\autoload\plug.vim" + ) +) +``` + +Or just create the directory `~\AppData\Local\nvim-data\site\autoload\`, and put the vim-plug script there. + +For macOS and Linux, use the following command: + +```bash +curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + ## How to install this configuration On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1]. On Linux @@ -167,12 +199,11 @@ command to install this configuration: git clone https://github.com/jdhao/nvim-config.git . ``` -After that, when we first open nvim, all the plugins included in this -configuration will be installed automatically for you (for Windows and macOS). -Since I use quite a lot of plugins (around 60 plugins), it may take some time -to install all of them, depending on your network condition. +After that, when we first open nvim, use `:PlugInstall` to install all the +plugins. Since I use quite a lot of plugins (more than 60), it may take some +time to install all of them, depending on your network condition. -# Automatic Installation # +# Automatic Installation for Linux # To set up a workable Neovim environment in Linux, I use the script [`Nvim_setup.sh`](Nvim_setup.sh) to automatically install necessary diff --git a/plugins.vim b/plugins.vim index 6e1d0ba..67afc99 100644 --- a/plugins.vim +++ b/plugins.vim @@ -1,30 +1,15 @@ scriptencoding utf-8 "{ Plugin installation -"{{ Vim-plug Install and related settings +"{{ Vim-plug related settings. +" The root directory to install all plugins. +let g:PLUGIN_HOME=expand(stdpath('data') . '/plugged') -" Auto-install vim-plug on different systems if it does not exist. For -" Windows, only Windows 10 with curl installed are supported (after Windows 10 -" build 17063, source: -" https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/). -" The following script to install vim-plug is adapted from vim-plug -" wiki: https://github.com/junegunn/vim-plug/wiki/tips#tips -let g:vim_plug_fpath = expand(stdpath('data') . '/site/autoload/plug.vim') -if (g:is_win || g:is_mac) && !filereadable(g:vim_plug_fpath) - if !executable('curl') - echoerr 'Curl not available on your system, you may install vim-plug by yourself.' - finish - endif - echomsg 'Installing Vim-plug on your system' - let g:vim_plug_furl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - silent execute printf('!curl -fLo %s --create-dirs %s', g:vim_plug_fpath, g:vim_plug_furl) - augroup plug_init - autocmd! - autocmd VimEnter * PlugInstall --sync | quit |source $MYVIMRC +if empty(readdir(g:PLUGIN_HOME)) + augroup plug_init + autocmd! + autocmd VimEnter * PlugInstall --sync | quit |source $MYVIMRC augroup END endif - -" The directory to install plugins. -let g:PLUGIN_HOME=expand(stdpath('data') . '/plugged') "}} "{{ Autocompletion related plugins