From aab38f32e0a02e43565a554d0a76ff65636499b8 Mon Sep 17 00:00:00 2001 From: Michal Hanus Date: Sat, 2 Mar 2024 18:49:55 +0100 Subject: crazyshit --- docs/README.md | 218 ------------------------------------- docs/nvim_install_mac.sh | 20 ---- docs/nvim_resources.md | 18 ---- docs/nvim_setup_linux.sh | 258 -------------------------------------------- docs/nvim_setup_windows.ps1 | 55 ---------- 5 files changed, 569 deletions(-) delete mode 100644 docs/README.md delete mode 100644 docs/nvim_install_mac.sh delete mode 100644 docs/nvim_resources.md delete mode 100755 docs/nvim_setup_linux.sh delete mode 100644 docs/nvim_setup_windows.ps1 (limited to 'docs') diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 774d919..0000000 --- a/docs/README.md +++ /dev/null @@ -1,218 +0,0 @@ -This doc summarizes how to install and use this configuration in detail. - -# Pre-requisite - -## Terminal emulators - -Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we choose to use greatly affects the appearance and features of Nvim. -Since Nvim supports true colors, terminals that support true colors are preferred. -For a list of terminals that support true colors, see [here](https://github.com/termstandard/colors). - -For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty). - -If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/), -both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator. -For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal). - -## Patched Fonts - -Since statusline or file explorer plugins often use Unicode symbols not available in normal font, -we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project. - -# Automatic installation - -## Automatic Installation for Linux - -To set up a workable Nvim environment on Linux, -I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs. - -Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script -should be set properly based on your environment. - -## Automatic installation for Windows - -Run the script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) in PowerShell **with Administrator rights**: - -``` -.\docs\nvim_setup_windows.ps1 -``` - -# Manual install - -There are a few dependencies if we want to use Nvim for efficient editing and development work. - -## Dependencies - -### Python - -A lot of Nvim plugins are mainly written in Python, so we must install Python 3. -The easiest way to install is via [Anaconda](https://docs.anaconda.com/anaconda/install/index.html) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html). - -After installation, make sure that you can run `python --version`, -and that the output should be Python 3.x. - -### Pynvim - -Nvim relies on [pynvim](https://github.com/neovim/pynvim) to communicate with plugins that utilize its Python binding. -Pynvim is required by plugins such as [wilder.nvim](https://github.com/gelguy/wilder.nvim). - -``` -pip install -U pynvim -``` - -### python-lsp-server - -[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc. - -``` -pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort python-lsp-black -``` - -Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly. -If you use pip from Anaconda, the executable path may be something like `$CONDA_ROOT/bin/pylsp`. -For native python, the path for pylsp may be like `$HOME/.local/bin/pylsp` - -### Node - -We need to install node.js from [here](https://nodejs.org/en/download/). -For Linux, you can use the following script: - -```bash -# Ref: https://johnpapa.net/node-and-npm-without-sudo/ -wget https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz - -mkdir -p $HOME/tools -# extract node to a custom directory, the directory should exist. -tar xvf node-v14.15.4-linux-x64.tar.xz --directory=$HOME/tools -``` - -Then add the following config to `.bash_profile` or `.zshrc` - -```bash -export PATH="$HOME/tools/node-v14.15.4-linux-x64/bin:$PATH" -``` - -Source the file: - -```bash -source ~/.bash_profile -# source ~/.zshrc -``` - -### vim-language-server - -[vim-language-server](https://github.com/iamcco/vim-language-server) provides completion for vim script. We can install vim-language-server globally: - -```bash -npm install -g vim-language-server -``` - -vim-language-server is installed in the same directory as the node executable. - -### Git - -Git is required by plugin manager [lazy.nvim](https://github.com/folke/lazy.nvim) and other git-related plugins. - -For Linux and macOS, Git is usually pre-installed. -The version of Git on the Linux system may be too old so that plugins may break. -Check [here](https://jdhao.github.io/2021/03/27/upgrade_git_on_linux/) on how to install and set up the latest version of Git. -For Windows, install [Git for Windows](https://git-scm.com/download/win) and make sure you can run `git` from command line. - -### ctags - -In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to install a ctags distribution. -Universal-ctags is preferred. - -To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) for the details. -To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags): - -```bash -brew install ctags -``` - -To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/) - -``` -choco install universal-ctags - -# scoop bucket add extras -# scoop install universal-ctags -``` - -Set its PATH properly and make sure you can run `ctags` from command line. - -### Ripgrep - -[Ripgrep](https://github.com/BurntSushi/ripgrep), aka, `rg`, is a fast grepping tool available for both Linux, Windows and macOS. -It is used by several searching plugins. - -For Windows and macOS, we can install it via chocolatey and homebrew respectively. -For Linux, we can download the [binary release](https://github.com/BurntSushi/ripgrep/releases) and install it. - -Set its PATH properly and make sure you can run `rg` from command line. - -### Linters - -A linter is a tool to check the source code for possible style and syntax issues. -Based on the programming languages we use, we may need to install various linters. - -+ Python: [pylint](https://github.com/PyCQA/pylint) and [flake8](https://github.com/PyCQA/flake8). -+ Vim script: [vint](https://github.com/Kuniwak/vint). - -Set their PATH properly and make sure you can run `pylint`, `flake8` and `vint` from command line. - -## Install Nvim - -There are various ways to install Nvim depending on your system. -This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable). - -### Linux - -You can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz). -You can also use the system package manager to install nvim, -but that is not reliable since the latest version may not be available. - -### Windows - -You may download from [nvim release](https://github.com/neovim/neovim/releases/download/stable/nvim-win64.zip) from GitHub and manually extract it. - -Another way to install Nvim on Windows is via chocolatey or scoop: - -``` -choco install neovim - -# via scoop -# scoop bucket add versions -# scoop install neovim -``` - -### macOS - -It is recommended to install neovim via [Homebrew](https://brew.sh/) on macOS. Simply run the following command: - -```bash -brew install neovim -``` - -After installing Nvim, we need to set the path to nvim correctly. -**Make sure that you can run `nvim` from the command line after all these setups**. - -## Setting up Nvim - -After installing nvim and all the dependencies, we will install plugin managers and set up this config. - -### How to install this configuration - -On Linux and macOS, the directory is `~/.config/nvim`. -On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1]. -First, we need to remove all the files under the config directory (including dot files), -then go to this directory, and run the following command: - -``` -git clone --depth=1 https://github.com/jdhao/nvim-config.git . -``` - -After that, when we first open nvim, all the plugins will be installed automatically. -Since I use quite a lot of plugins (more than 60), it may take some time to install all of them. - -[^1]: Use `echo %userprofile%` to see where your `$HOME` is. diff --git a/docs/nvim_install_mac.sh b/docs/nvim_install_mac.sh deleted file mode 100644 index ef698c8..0000000 --- a/docs/nvim_install_mac.sh +++ /dev/null @@ -1,20 +0,0 @@ -# This script is used to update Nvim on macOS -#!/bin/bash -set -eux - -wget https://github.com/neovim/neovim/releases/download/stable/nvim-macos.tar.gz - -if [[ ! -d "$HOME/tools/" ]]; then - mkdir -p "$HOME/tools" -fi - -# Delete existing nvim installation. -# For newer release, the directory name is nvim-macos -if [[ -d "$HOME/tools/nvim-macos" ]]; then - rm -rf "$HOME/tools/nvim-macos" -fi - -# Extract the tar ball -tar zxvf nvim-macos.tar.gz -C "$HOME/tools" - -rm nvim-macos.tar.gz diff --git a/docs/nvim_resources.md b/docs/nvim_resources.md deleted file mode 100644 index 47c9156..0000000 --- a/docs/nvim_resources.md +++ /dev/null @@ -1,18 +0,0 @@ -Below are a list of resources that inspire me. This list is non-exhaustive as I -can not remember the source of many settings. - -- [From .vimrc to .vim](https://vimways.org/2018/from-vimrc-to-vim/) -- http://stevelosh.com/blog/2010/09/coming-home-to-vim/ -- https://github.com/tamlok/tvim/blob/master/.vimrc -- https://nvie.com/posts/how-i-boosted-my-vim/ -- https://blog.carbonfive.com/2011/10/17/vim-text-objects-the-definitive-guide/ -- https://sanctum.geek.nz/arabesque/vim-anti-patterns/ -- https://github.com/gkapfham/dotfiles/blob/master/.vimrc -- https://google.github.io/styleguide/vimscriptguide.xml -- https://github.com/romainl/idiomatic-vimrc -- https://github.com/mhinz/vim-galore -- https://learnvimscriptthehardway.stevelosh.com/ -- https://vimways.org/2018/from-vimrc-to-vim/ -- [vim script for Python developers](https://github.com/yegappan/VimScriptForPythonDevelopers) -- [Awesome neovim](https://github.com/rockerBOO/awesome-neovim): extensive list of neovim resources (plugins, mostly). -- [What is your favorite plugins for Nvim 0.5](https://www.reddit.com/r/neovim/comments/o20w3z/what_are_your_favorite_neovim_plugins_exclusive/) diff --git a/docs/nvim_setup_linux.sh b/docs/nvim_setup_linux.sh deleted file mode 100755 index f5dca87..0000000 --- a/docs/nvim_setup_linux.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/bin/bash -set -exu -set -o pipefail - -# Whether python3 has been installed on the system -PYTHON_INSTALLED=true - -# If Python has been installed, then we need to know whether Python is provided -# by the system, or you have already installed Python under your HOME. -SYSTEM_PYTHON=true - -# If SYSTEM_PYTHON is false, we need to decide whether to install -# Anaconda (INSTALL_ANACONDA=true) or Miniconda (INSTALL_ANACONDA=false) -INSTALL_ANACONDA=false - -# Whether to add the path of the installed executables to system PATH -ADD_TO_SYSTEM_PATH=true - -# select which shell we are using -USE_ZSH_SHELL=true -USE_BASH_SHELL=false - -if [[ ! -d "$HOME/packages/" ]]; then - mkdir -p "$HOME/packages/" -fi - -if [[ ! -d "$HOME/tools/" ]]; then - mkdir -p "$HOME/tools/" -fi - -####################################################################### -# Anaconda or miniconda install # -####################################################################### -if [[ "$INSTALL_ANACONDA" = true ]]; then - CONDA_DIR=$HOME/tools/anaconda - CONDA_NAME=Anaconda.sh - CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh" -else - CONDA_DIR=$HOME/tools/miniconda - CONDA_NAME=Miniconda.sh - CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh" -fi - -if [[ ! "$PYTHON_INSTALLED" = true ]]; then - echo "Installing Python in user HOME" - - SYSTEM_PYTHON=false - - echo "Downloading and installing conda" - - if [[ ! -f "$HOME/packages/$CONDA_NAME" ]]; then - curl -Lo "$HOME/packages/$CONDA_NAME" $CONDA_LINK - fi - - # Install conda silently - if [[ -d $CONDA_DIR ]]; then - rm -rf "$CONDA_DIR" - fi - bash "$HOME/packages/$CONDA_NAME" -b -p "$CONDA_DIR" - - # Setting up environment variables - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$CONDA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" - fi -else - echo "Python is already installed. Skip installing it." -fi - -# Install some Python packages used by Nvim plugins. -echo "Installing Python packages" -declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "vim-vint" "python-lsp-isort" "pylsp-mypy" "python-lsp-black") - -if [[ "$SYSTEM_PYTHON" = true ]]; then - echo "Using system Python to install $(PY_PACKAGES)" - - # If we use system Python, we need to install these Python packages under - # user HOME, since we do not have permissions to install them under system - # directories. - for p in "${PY_PACKAGES[@]}"; do - pip install --user "$p" - done -else - echo "Using custom Python to install $(PY_PACKAGES)" - for p in "${PY_PACKAGES[@]}"; do - "$CONDA_DIR/bin/pip" install "$p" - done -fi - -####################################################################### -# Install node and js-based language server # -####################################################################### -NODE_DIR=$HOME/tools/nodejs -NODE_SRC_NAME=$HOME/packages/nodejs.tar.gz -# when download speed is slow, we can also use its mirror site: https://mirrors.ustc.edu.cn/node/v15.0.0/ -NODE_LINK="https://mirrors.ustc.edu.cn/node/v15.0.0/node-v15.0.0-linux-x64.tar.xz" -if [[ -z "$(command -v node)" ]]; then - echo "Install Node.js" - if [[ ! -f $NODE_SRC_NAME ]]; then - echo "Downloading Node.js and renaming" - wget $NODE_LINK -O "$NODE_SRC_NAME" - fi - - if [[ ! -d "$NODE_DIR" ]]; then - echo "Creating Node.js directory under tools directory" - mkdir -p "$NODE_DIR" - echo "Extracting to $HOME/tools/nodejs directory" - tar xvf "$NODE_SRC_NAME" -C "$NODE_DIR" --strip-components 1 - fi - - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$NODE_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" - fi -else - echo "Node.js is already installed. Skip installing it." - NODE_DIR="$(realpath $(dirname $(which node))/..)" -fi - -# Install vim-language-server -"$NODE_DIR/bin/npm" install -g vim-language-server - -# Install bash-language-server -"$NODE_DIR/bin/npm" install -g bash-language-server - -####################################################################### -# lua-language-server # -####################################################################### -LUA_LS_DIR=$HOME/tools/lua-language-server -LUA_LS_SRC=$HOME/packages/lua-language-server.tar.gz -LUA_LS_LINK="https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-linux-x64.tar.gz" - -if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$LUA_LS_DIR/bin/lua-language-server" ]]; then - echo 'Install lua-language-server' - if [[ ! -f $LUA_LS_SRC ]]; then - echo "Downloading lua-language-server and renaming" - wget $LUA_LS_LINK -O "$LUA_LS_SRC" - fi - - if [[ ! -d "$LUA_LS_DIR" ]]; then - echo "Creating lua-language-server directory under tools directory" - mkdir -p "$LUA_LS_DIR" - echo "Extracting to directory $LUA_LS_DIR" - - tar zxvf "$LUA_LS_SRC" -C "$LUA_LS_DIR" - fi - - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$LUA_LS_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" - fi -else - echo "lua-language-server is already installed. Skip installing it." -fi - -####################################################################### -# Ripgrep part # -####################################################################### -RIPGREP_DIR=$HOME/tools/ripgrep -RIPGREP_SRC_NAME=$HOME/packages/ripgrep.tar.gz -RIPGREP_LINK="https://github.com/BurntSushi/ripgrep/releases/download/12.0.0/ripgrep-12.0.0-x86_64-unknown-linux-musl.tar.gz" -if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then - echo "Install ripgrep" - if [[ ! -f $RIPGREP_SRC_NAME ]]; then - echo "Downloading ripgrep and renaming" - wget $RIPGREP_LINK -O "$RIPGREP_SRC_NAME" - fi - - if [[ ! -d "$RIPGREP_DIR" ]]; then - echo "Creating ripgrep directory under tools directory" - mkdir -p "$RIPGREP_DIR" - echo "Extracting to $HOME/tools/ripgrep directory" - tar zxvf "$RIPGREP_SRC_NAME" -C "$RIPGREP_DIR" --strip-components 1 - fi - - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$RIPGREP_DIR:\$PATH\"" >> "$HOME/.bash_profile" - fi - - # set up manpath and zsh completion for ripgrep - mkdir -p "$HOME/tools/ripgrep/doc/man/man1" - mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1" - - if [[ "$USE_BASH_SHELL" = true ]]; then - echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile" - else - echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.zshrc" - echo 'export FPATH=$HOME/tools/ripgrep/complete:$FPATH' >> "$HOME/.zshrc" - fi -else - echo "ripgrep is already installed. Skip installing it." -fi - -####################################################################### -# Ctags install # -####################################################################### -CTAGS_SRC_DIR=$HOME/packages/ctags -CTAGS_DIR=$HOME/tools/ctags -CTAGS_LINK="https://github.com/universal-ctags/ctags.git" -if [[ ! -f "$CTAGS_DIR/bin/ctags" ]]; then - echo "Install ctags" - - if [[ ! -d $CTAGS_SRC_DIR ]]; then - mkdir -p "$CTAGS_SRC_DIR" - else - # Prevent an incomplete download. - rm -rf "$CTAGS_SRC_DIR" - fi - - git clone --depth=1 "$CTAGS_LINK" "$CTAGS_SRC_DIR" && cd "$CTAGS_SRC_DIR" - ./autogen.sh && ./configure --prefix="$CTAGS_DIR" - make -j && make install - - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$CTAGS_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" - fi -else - echo "ctags is already installed. Skip installing it." -fi - -####################################################################### -# Nvim install # -####################################################################### -NVIM_DIR=$HOME/tools/nvim -NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz -NVIM_CONFIG_DIR=$HOME/.config/nvim -NVIM_LINK="https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz" -if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then - echo "Installing Nvim" - echo "Creating nvim directory under tools directory" - - if [[ ! -d "$NVIM_DIR" ]]; then - mkdir -p "$NVIM_DIR" - fi - - if [[ ! -f $NVIM_SRC_NAME ]]; then - echo "Downloading Nvim" - wget "$NVIM_LINK" -O "$NVIM_SRC_NAME" - fi - echo "Extracting neovim" - tar zxvf "$NVIM_SRC_NAME" --strip-components 1 -C "$NVIM_DIR" - - if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then - echo "export PATH=\"$NVIM_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" - fi -else - echo "Nvim is already installed. Skip installing it." -fi - -echo "Setting up config and installing plugins" -if [[ -d "$NVIM_CONFIG_DIR" ]]; then - rm -rf "$NVIM_CONFIG_DIR.backup" - mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup" -fi - -git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR" - -echo "Installing nvim plugins, please wait" -"$NVIM_DIR/bin/nvim" -c "autocmd User LazyInstall quitall" -c "lua require('lazy').install()" - -echo "Finished installing Nvim and its dependencies!" diff --git a/docs/nvim_setup_windows.ps1 b/docs/nvim_setup_windows.ps1 deleted file mode 100644 index 9148a22..0000000 --- a/docs/nvim_setup_windows.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -# Set policy to avoid errors -Set-ExecutionPolicy RemoteSigned -scope CurrentUser - -# Install scoop -Invoke-WebRequest -UseBasicParsing get.scoop.sh | Invoke-Expression - -# Install node -scoop install nodejs - -# Install ripgrep -scoop install ripgrep - -# Install universal-ctags -scoop bucket add extras -scoop install universal-ctags - -# Install vim-language-server -npm install -g vim-language-server - -# Install bash-language-server -npm install -g bash-language-server - -# Install miniconda3 (for Python) -scoop install miniconda3 - -# Install pynvim -pip install -U pynvim - -# Install python-language-server -pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort - -# Install visual c++ redistribution -scoop install vcredist2022 - -# Install 7zip -scoop install 7zip - -# Install lua-language-server -$lua_ls_link = "https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-win32-x64.zip" -$lua_ls_install_dir = "D:\portable_tools" -$lua_ls_src_path = "$lua_ls_install_dir\lua-language-server.zip" -$lua_ls_dir = "$lua_ls_install_dir\lua-language-server" - -# Download file, ref: https://stackoverflow.com/a/51225744/6064933 -Invoke-WebRequest $lua_ls_link -OutFile "$lua_ls_src_path" - -# Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933 -7z x "$lua_ls_src_path" -o"$lua_ls_dir" - -# Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933 -[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$lua_ls_dir\bin", "Machine") - -# Install neovim nightly -scoop bucket add versions -scoop install neovim -- cgit v1.2.3