1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Update doc and install script

This commit is contained in:
jdhao 2021-07-04 17:51:48 +08:00
parent 896e13291c
commit f9484a6623
3 changed files with 67 additions and 82 deletions

View File

@ -12,31 +12,31 @@ the additional config file for GUI client of Neovim (I am using
My configurations are heavily documented to make it as clear as possible. While
you can download the whole repository and use it, it is not recommended though.
Good configurations are personal. Everyone should have his or her unique config
file. You are encouraged to copy from this this repo the part you feel useful
and add it to your own Nvim config.
file. You are encouraged to copy from this repo the part you feel useful and
add it to your own Nvim config.
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim
itself, and how to configure on different platforms (Linux, macOS and Windows).
itself, and how to set up on different platforms (Linux, macOS and Windows).
# Features #
+ Code auto-completion via [nvim-compe](https://github.com/hrsh7th/nvim-compe) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) using nvim [builtin lsp](https://neovim.io/doc/user/lsp.html) feature.
+ Source code linting via [Ale](https://github.com/dense-analysis/ale).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary).
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
+ Fuzzy searching in current project quickly via [LeaderF](https://github.com/Yggdroot/LeaderF).
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Faster matching pair insertion and jump via [auto-pairs](https://github.com/jiangmiao/auto-pairs).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
+ Beautiful status line via [vim-airline](https://github.com/vim-airline/vim-airline).
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
+ Fast buffer jump via [vim-sneak](https://github.com/justinmk/vim-sneak).
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
+ Beautiful status line via [vim-airline](https://github.com/vim-airline/vim-airline).
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
+ Markdown writing and syntax highlighting via [vim-markdown](https://github.com/plasticboy/vim-markdown),
Markdown Previewing via [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Source code linting via [Ale](https://github.com/dense-analysis/ale).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Faster matching pair insertion and jump via [auto-pairs](https://github.com/jiangmiao/auto-pairs).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
+ LaTeX editing via [vimtex](https://github.com/lervag/vimtex)[^1].
+ Smooth scroll experience via [vim-smoothie](https://github.com/psliwka/vim-smoothie).
+ ......
@ -46,33 +46,34 @@ itself, and how to configure on different platforms (Linux, macOS and Windows).
Some of the shortcuts I use frequently. In the following shortcuts, `<leader>`
represents ASCII character `,`.
| Shortcut | Mode | platform | Description |
|-------------------|---------------|-----------------|------------------------------------------------------------------|
| `<leader>f` | Normal | Linux/macOS/Win | Fuzzy file search in a floating window |
| `<leader>h` | Normal | Linux/macOS/Win | Fuzzy help search in a floating window |
| `<leader>t` | Normal | Linux/macOS/Win | Fuzzy buffer tag search in a floating window |
| `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Neovim config in a new tabpage |
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Neovim config |
| `<leader>q` | Normal | Linux/macOS/Win | Quit current window |
| `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Neovim |
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current directory to where current file is |
| `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register |
| `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
| `{count}gb` | Normal | Linux/macOS/Win | Go to {count} buffer or next buffer in the buffer list. |
| `Alt-M` | Normal | macOS/Win | Render Markdown to HTML and open it in system browser |
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode (faster `<ESC>`) |
| Shortcut | Mode | platform | Description |
|-------------------|---------------|-----------------|------------------------------------------------------------------------------------------------------|
| `<leader>f` | Normal | Linux/macOS/Win | Fuzzy file search in a floating window |
| `<leader>h` | Normal | Linux/macOS/Win | Fuzzy help search in a floating window |
| `<leader>t` | Normal | Linux/macOS/Win | Fuzzy buffer tag search in a floating window |
| `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Neovim config in a new tabpage |
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Neovim config |
| `<leader>q` | Normal | Linux/macOS/Win | Quit current window |
| `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Neovim |
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current directory to where current file is |
| `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register |
| `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
| `{count}gb` | Normal | Linux/macOS/Win | Go to {count} buffer or next buffer in the buffer list. |
| `Alt-M` | Normal | macOS/Win | Render Markdown to HTML and open it in system browser |
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode [without lagging](https://github.com/jdhao/better-escape.vim) (faster `<ESC>`) |
# Trouble shooting
@ -80,7 +81,7 @@ If you come across an issue, you can first use `:checkhealth` command provided
by `nvim` to trouble-shoot yourself. Please read carefully the messages
provided by health check.
If you still have an issue, you may [open a new issue](https://github.com/jdhao/nvim-config/issues).
If you still have an issue, [open a new issue](https://github.com/jdhao/nvim-config/issues).
# Further readings

View File

@ -130,7 +130,7 @@ if [[ ! -f "$CTAGS_DIR/bin/ctags" ]]; then
rm -rf "$CTAGS_SRC_DIR"
fi
git clone "$CTAGS_LINK" "$CTAGS_SRC_DIR" && cd "$CTAGS_SRC_DIR"
git clone --depth=1 "$CTAGS_LINK" "$CTAGS_SRC_DIR" && cd "$CTAGS_SRC_DIR"
./autogen.sh && ./configure --prefix="$CTAGS_DIR"
make -j && make install
@ -176,12 +176,13 @@ if [[ -d "$NVIM_CONFIG_DIR" ]]; then
mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup"
fi
git clone https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR"
git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR"
echo "Installing vim-plug"
curl -fLo "$NVIM_SITE_DIR/autoload/plug.vim" --create-dirs https://cdn.jsdelivr.net/gh/junegunn/vim-plug/plug.vim
echo "Installing packer.nvim"
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim
echo "Installing plugins"
"$NVIM_DIR/bin/nvim" +PlugInstall +qall
"$NVIM_DIR/bin/nvim" +PackerInstall +qall
echo "Finished installing Neovim and its dependencies!"

View File

@ -7,10 +7,8 @@ and development work.
A lot of Neovim plugins are mainly written in Python. To use auto-completion
and other features, we must install Python 3. The easiest way to install is via
[Anaconda](https://www.anaconda.com/distribution/#download-section) or
[Miniconda](https://docs.conda.io/en/latest/miniconda.html). Make sure that the
output of `python --version` on the command line shows that Python 3.x is
installed.
[Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html). Make sure that the
output of `python --version` shows that Python 3.x is installed.
## Pynvim
@ -18,6 +16,10 @@ Neovim relies on [pynvim](https://github.com/neovim/pynvim) to communicate with
plugins that utilize its Python binding. Pynvim is required by plugins such as
[Deoplete](https://github.com/Shougo/deoplete.nvim) and [Semshi](https://github.com/numirias/semshi).
```
pip install -U pynvim
```
## pyls
[Pyls](https://github.com/palantir/python-language-server) is a Python Language
@ -29,8 +31,8 @@ pip install "python-language-server[all]" pyls-isort pyls-mypy
## Git
Git is used by the plugin manager vim-plug to download plugins from GitHub or
other Git repositories.
Git is used by the plugin manager packer.nvim to download plugins from GitHub
or other Git repositories.
Since Git is usually pre-installed on Linux and macOS, we do not need to worry
if we are on these two platforms. For Windows, install [Git for
@ -114,16 +116,12 @@ version of nvim.
## Linux
Follow the official guide and download the appimage from the [release
page](https://github.com/neovim/neovim/releases/nightly).
For some Linux systems, we may not be able to run the appimage. We can directly
download the binary release from [here](https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz).
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz).
## Windows
The easiest way to install Neovim on Windows is via chocolatey. First, install
chocolatey. Then we can install neovim easily following command:
chocolatey. Then we can install neovim easily using the following command:
```
# install the latest version of neovim
@ -157,50 +155,35 @@ setups.
# Setting up Nvim
## Install plugin manager vim-plug
## Install plugin manager packer.nvim
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.
I use [packer.nvim](https://github.com/wbthomason/packer.nvim) to manage my
plugins. We need to install packer.nvim on our system first.
For Windows, if curl is installed, use the following command:
For Windows, if curl is installed, use the following command (on Powershell):
```
curl -fLo ~\AppData\Local\nvim-data\site\autoload\plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
git clone --depth=1 https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\packer.nvim"
```
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
git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim
```
## How to install this configuration
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1]. On Linux
and macOS, the directory is `~/.config/nvim`. First, we need to remove all the
files under the config directory (including dot files), then use the following
command to install this configuration:
files under the config directory (including dot files), then go to this
directory, and run the following command to install this configuration:
```
git clone https://github.com/jdhao/nvim-config.git .
git clone --depth=1 https://github.com/jdhao/nvim-config.git .
```
After that, when we first open nvim, use `:PlugInstall` to install all the
After that, when we first open nvim, use `:PackerInstall` 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.