dotfiles/nvim/init.vim
Sanchayan Maity 988222400d nvim: Update neovim configuration
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2019-02-18 23:04:03 +05:30

218 lines
7.2 KiB
VimL

" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.config/nvim/plugged')
" Automatically match brackets as you type
Plug 'Raimondi/delimitMate'
" Tab completion
Plug 'ervandew/supertab'
" EasyMotion - Allows <leader><leader>(b|e) to jump to (b)eginning or (end)
" of words.
Plug 'easymotion/vim-easymotion'
" Fuzzy file search
Plug 'ctrlpvim/ctrlp.vim'
"Plug '~/.fzf'
Plug 'junegunn/fzf.vim'
" Remove extraneous whitespace when edit mode is exited
Plug 'thirtythreeforty/lessspace.vim'
" Status bar mods
Plug 'bling/vim-airline'
Plug 'airblade/vim-gitgutter'
" Manage Project sessions
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
" Explore filesystem
Plug 'scrooloose/nerdtree'
" Commenter
Plug 'scrooloose/nerdcommenter'
" Theme
Plug 'sickill/vim-monokai'
" Autoload and read from dish if file changes
Plug 'tmux-plugins/vim-tmux-focus-events'
" For LaTeX support
Plug 'donRaphaco/neotex', { 'for': 'tex' }
" For git support
Plug 'jreybert/vimagit'
" For tmux yank
Plug 'vim-utils/vim-husk'
" For Go
Plug 'zchee/deoplete-go', { 'do': 'make' }
" Lisp
Plug 'eraserhd/parinfer-rust', { 'do': 'cargo build --release' }
" Haskell
Plug 'neovimhaskell/haskell-vim', { 'for': [ 'haskell', 'cabal' ] }
" Language Client
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'fish install.sh',
\ }
" For autocompletion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" Initialize plugin system
call plug#end()
syntax on
filetype plugin indent on
" Highlight 80th column
set colorcolumn=80
" Always show status bar
set laststatus=2
" Let plugins show effects after 500ms, not 4s
set updatetime=500
" Disable mouse click to go to position
set mouse-=a
" Don't let autocomplete affect usual typing habits
set completeopt=menuone,preview,noinsert
" Let vim-gitgutter do its thing on large files
let g:gitgutter_max_signs=10000
" Set up leaders
let mapleader="\<SPACE>"
set encoding=utf-8
set exrc " Allow loading local .nvimrc files
set secure " Disallow use of autocmd, shell and write in local rc
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set showmode " Show current mode.
set ruler " Show the line and column numbers of the cursor.
set number " Show the line numbers on the left side.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set softtabstop=4 " Finetunes the amount of white space to be added.
set tabstop=4 " Render TABs using this many spaces.
set shiftwidth=4 " Indentation amount for < and > commands.
set smarttab " Indent with tabs, align with spaces.
set expandtab " When on, uses space instead of tabs.
set noerrorbells " No beeps.
set modeline " Enable modeline.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set nostartofline " Do not jump to first character with page commands.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
set autoread " Autoload file if it changes on disk
set rtp+=/usr/bin/fzf
set rtp+=~/.config/nvim/plugged/LanguageClient-neovim
set completeopt-=preview
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" Search and Replace
nmap <Leader>s :%s//g<Left><Left>
"nnoremap ; : " Use ; for commands.
"nnoremap Q @q " Use Q to execute default register.
" Open file menu
nnoremap <Leader>o :CtrlP<CR>
" Open buffer menu
nnoremap <Leader>b :CtrlPBuffer<CR>
" Open most recently used files
nnoremap <Leader>f :CtrlPMRUFiles<CR>
" Open NerdTree
nnoremap <Leader>n :NERDTree<CR>
" Open fuzzy file search
nnoremap <Leader>t :Files<CR>
" Manage splits
set splitbelow
set splitright
nnoremap <Leader>w <c-w>w
" Theme
syntax enable
colorscheme monokai
" Key Bindings to help with terminal mode
:tnoremap <Esc> <C-\><C-n>
" Key bindings to move between window splits
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
" Disable Arrow Keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" For Haskell
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:haskell_classic_highlighting = 1
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2
" Use deoplete
let g:deoplete#enable_at_startup = 1
let g:airline#extensions#tabline#enabled = 2
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = ' '
let g:airline#extensions#tabline#right_alt_sep = '|'
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
" For Language Client
set hidden
let g:LanguageClient_serverCommands = {
\ 'haskell': ['hie-wrapper'],
\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
\ 'python': ['/usr/bin/pyls'],
\ }
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml', 'Cargo.toml']
nnoremap <Leader>lc :call LanguageClient_contextMenu()<CR>
nnoremap <Leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <Leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <Leader>ln :call LanguageClient#textDocument_rename()<CR>
nnoremap <Leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <Leader>lr :call LanguageClient#textDocument_references()<CR>
nnoremap <Leader>la :call LanguageClient#textDocument_codeAction()<CR>
nnoremap <Leader>ls :call LanguageClient#textDocument_documentSymbol()<CR>