Skip to content
My GitHub Profile My Twitter Profile

[My MacOS] NeoVim Setup

Install NeoVim.

Copy the following code in your ~/.config/nvim/init.vim file.

call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
 Plug 'dracula/vim'
 Plug 'ryanoasis/vim-devicons'
 Plug 'SirVer/ultisnips'
 Plug 'honza/vim-snippets'
 Plug 'scrooloose/nerdtree'
 Plug 'preservim/nerdcommenter'
 Plug 'mhinz/vim-startify'
 Plug 'neoclide/coc.nvim', {'branch': 'release'}
 Plug 'luochen1990/rainbow'
 Plug 'nvim-lua/plenary.nvim'
 Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
 Plug 'tpope/vim-fugitive'                   " Git integration in to nvim
 Plug 'Yggdroot/indentLine'                  " Line Indentations
 Plug 'farmergreg/vim-lastplace'             " Continue from where you left last time
 Plug 'raimondi/delimitmate'                 " Provides insert mode auto-completion for special-characters
 Plug 'tpope/vim-markdown'                   " Markdown runtime files
 Plug 'tpope/vim-surround'                   " Change paranthesis and quotes into other forms quickly
 Plug 'vim-scripts/indentpython.vim'         " Indentation script for python
 Plug 'alvan/vim-closetag'                   " Makes a close tag for html quickly
 Plug 'airblade/vim-gitgutter'               " Shows git diffs in the sign columns
 Plug 'lilydjwg/colorizer'                   " Provides color for the #rrggbb or #rgb color format in files
 Plug 'vim-airline/vim-airline'              " Powerline Theme / Status line
 Plug 'vim-airline/vim-airline-themes'       " Themes for vim-airline
 Plug 'rafi/awesome-vim-colorschemes'        " Change colorschemes on the fly for vim and nvim
call plug#end()

let g:loaded_ruby_provider = 0
let g:loaded_node_provider = 0
let g:loaded_perl_provider = 0
let g:rainbow_active = 1

syntax enable
colorscheme dracula
set splitright
set splitbelow

set nocompatible
set showmatch
set mouse=v
set hlsearch
set incsearch
set number
set mouse=a
set clipboard=unnamedplus
set cursorline
set ttyfast

" open file in a text by placing text and gf
nnoremap gf :vert winc f<cr>
" copies filepath to clipboard by pressing yf
:nnoremap <silent> yf :let @+=expand('%:p')<CR>
" copies pwd to clipboard: command yd
:nnoremap <silent> yd :let @+=expand('%:p:h')<CR>
" Vim jump to the last position when reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
    \| exe "normal! g'\"" | endif
endif

" move line or visually selected block - alt+j/k
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
" move split panes to left/bottom/top/right
nnoremap <A-h> <C-W>H
nnoremap <A-j> <C-W>J
nnoremap <A-k> <C-W>K
nnoremap <A-l> <C-W>L
" move between panes to left/bottom/top/right
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" Press i to enter insert mode, and ii to exit insert mode.
inoremap ii <Esc>
inoremap jk <Esc>
inoremap kj <Esc>
vnoremap jk <Esc>
vnoremap kj <Esc>

We are using vim-plug as our plugin manager. So, we need to install it first.

Unix, Linux

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Linux (Flatpak)

curl -fLo ~/.var/app/io.neovim.nvim/data/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Windows (PowerShell)

iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
    ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force

After installing vim-plug, open your init.vim file and run :PlugInstall command. This will install all the plugins that we have mentioned in the init.vim file.