# VIM

# Rust + Vim

brew install neovim

Then install nvchad and clone this to ~/.config/nvim.

Reference video.

For fonts - brew tap homebrew/cask-fonts && brew install --cask font-fira-code-nerd-font, then select the fira font on iterm2.

# Exclude directory in telescope

Go to ~/.config/nvim and open telescope.lua. Then add the directory name, e.g. node_modules to file_ignore_patterns.

# Tabs

Reference

In normal mode

gt      go to next tab
gT      go to previous tab
{i}gt   go to tab number {i}

# Fuzzy find for files

Reference

To invoke: ctrl + p.

  1. to include hidden files: let g:ctrlp_show_hidden = 1
  2. to exclude node_modules and git: let g:ctrlp_custom_ignore='node_modules\|git'
  3. to open file in split: use <c-v>

# NerdTree show hidden files

Shift + i to toggle hidden files, let NERDTreeShowHidden=1 in .vimrc.

# NERDTree review file in navigator

:NERDTreeFind

# Reload vim config without restarting

:so ~/.vimrc

# Configuration

Install vundle.

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Create ~/.vimrc with the following content.

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'

Plugin 'NLKNguyen/papercolor-theme'
Plugin 'rust-lang/rust.vim'
" Run :CocInstall coc-rust-analyzer 
Plugin 'neoclide/coc.nvim', {'branch': 'release'}
Plugin 'vim-airline/vim-airline'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l

nmap <C-n> :NERDTree<CR>
nmap <C-p> :CtrlP<CR>

syntax enable
set t_Co=256
set background=dark
colorscheme PaperColor
set number

# Common Issues

# [coc.nvim] build/index.js not found

cd ~/.vim/bundle/coc.nvim
yarn install
yarn build

Maybe install the latest NodeJS and yarn

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

npm i -g yarn

sudo npm i -g n
sudo n lts

# Rust

To get rust working, do not use brew install rust. Instead do curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install Neovim on Amazon Linux ref

#!/usr/bin/env bash
sudo yum groups install -y Development\ tools
sudo yum install -y cmake
sudo yum install -y python34-{devel,pip}
sudo pip-3.4 install neovim --upgrade
(
cd "$(mktemp -d)"
git clone https://github.com/neovim/neovim.git
cd neovim
make CMAKE_BUILD_TYPE=Release
sudo make install
)