dotfiles/neovim/.config/nvim/installer/README.md

9.2 KiB

My Neovim setup

My Neovim IDE setup for Python, Go, Rust, HTML, CSS, Javascript, Typescript, gettext and more.

Features

  • init.vim handling
  • Incremental and smart case search.
  • Sublime Text style multiple selections
  • Trailing whitespace highlighting and cleaning shortcut
  • Logical and Visual layout (for Right-To-Left lanaguegs) editing.
  • Tabs expand to 4 spaces by default
  • Remap <Leader> to <SPACE> and jj to <ESC>
  • Highlight current row and color column 80
  • 70+ language packs support
  • Syntax checking
  • Snippets
  • Quotes, parens etc pair, surround
  • Extended pair matching with %
  • ASCII drawing
  • Fuzzy file, buffer, mru, tag, etc finder
  • VCS plugins (Fugitive, Lawrencium)
  • Tab completion
  • Commenting

Prerequisites

  • Neovim and Neovim Python client.
  • For faster search, ripgrep
  • For tags: ctags
  • For devicons, a patched font, like the one from nerd-fonts

Usage

The following commands will clone the repo, and install vim-plug plugin manager:

mkdir -p ~/.config/nvim
git clone https://github.com/MeirKriheli/dotneovim.git ~/.config/nvim
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Install plugins from the command line:

nvim +PlugUpdate +qa

After that, install the desired COC plugins or extensions.

Overrides

  • ~/.config/nvim/before.vim, if exists, is sourced before everything allowing definitions of variables to act upon.
  • ~/.config/nvim/after.vim if exists, is sourced after all the files in ~/.config/nvim/rc.d allowing override of default settings (e.g: color schemes, plugin configuration, etc.).

Go tags

For CtrlPBufTag search in go files, make sure you have an updated version of ctags (>=5.8) and put in your ~/.ctags::

--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/v,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/t,type/

Rust tags

For Rust ctags to wok (e.g: TagBar), put in your ~/.ctags::

--langdef=Rust
--langmap=Rust:.rs
--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(static|const)[ \t]+(mut[ \t]+)?([a-zA-Z0-9_]+)/\4/c,consts,static constants/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\3/t,traits,traits/
--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+(for)[ \t]+)?([a-zA-Z0-9_]+)/\5 \7 \8/i,impls,trait implementations/
--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/

Plugins

  • Solarized - color scheme
  • base16-vim - color scheme
  • vim-molokai - color scheme
  • Oceanic-next - color scheme
  • Nord VIM - color scheme
  • Gruvbox - color scheme
  • Fugitive - a Git wrapper so awesome, it should be illegal
  • gv.vim - A git commit browser in Vim
  • Lawrencium - Mercurial wrapper for Vim, inspired by Tim Pope's Fugitive
  • ctrlp.vim - Fuzzy file, buffer, mru, tag, etc finder
  • ale - Asynchronous Lint Engine
  • coc.nvim - Intellisense engine for vim8 & neovim, full language server protocol support as VSCode
  • UltiSnips - The ultimate snippet solution for Vim.
  • vim-snippets - vim-snipmate default snippets
  • python-mode - Vim python-mode. PyLint, Rope, Pydoc, breakpoints from box
  • vim-go - Go development plugin for Vim
  • rust.vim - provides Rust file detection, syntax highlighting, formatting, Syntastic integration, and more.
  • DrawIt - ASCII drawing plugin: lines, ellipses, arrows, fills, and more!
  • vim-surround - quoting/parenthesizing made simple
  • Shebang - Make executable by setting the correct shebang and executable bit
  • Tagbar - Displays tags in a window, ordered by class etc.
  • NERD tree - A tree explorer
  • nerdtree-git-plugin - A plugin of NERDTree showing git status
  • auto-pairs - Insert or delete brackets, parens, quotes in pair
  • po.vim - Easier editing of GNU gettext PO files
  • MatchTagAlways - A Vim plugin that always highlights the enclosing html/xml tags
  • vim-airline - Light weight status line utility
  • tabular - text filtering and alignment
  • tcomment_vim - An extensible & universal comment vim-plugin that also handles embedded filetypes
  • vim-unimpaired - pairs of handy bracket mappings
  • vim-multiple-cursors - True Sublime Text style multiple selections for Vim
  • splitjoin.vim - A Vim plugin that simplifies the transition between multiline and single-line code
  • vim-repeat - enable repeating supported plugin maps with "."
  • tsuquyomi - A Vim plugin for TypeScript
  • vim-highlightedyank - Make the yanked region apparent!

Shortcuts and re-Mappings

Key Command
jj <Esc> in insert and command modes
<SPACE> <Leader>
<Leader>v Load .vimrc
<Leader>V Activate changes to .vimrc (Make sure to save it before)
<F2> Close current split (window)
<F3> Toggle NERD tree
<F5> Toggle Tagbar
<Leader>S Remove trailing whitespace
<CTRL>hjkl Window movement commands
<CTRL>arrow Window movement commands
<Leader>d Delete buffer, keep the split
-, + Resize horizontal splits
<ALT>< <ALT>> Resize vertical splits
<F9> Toggle logical (RTL, e.g: Hebrew) editing
<F8> Toggle visual (RTL, e.g: Hebrew) editing
g/ :grep!
g* :grep! -w current_word
ga :grepadd! (add results to the current search)
gr :CtrlPBufTag (fuzzy tag search in current file)

Virtualenv settings

If you're running from virtualenv activated, make sure to point nvim and ale to correct locations. By default, settings are:

let g:python3_host_prog = '/usr/bin/python'
let g:ale_python_flake8_executable = '/usr/bin/flake8'

If needed, override those settings to the locations on your machine.