Skip to content

Instantly share code, notes, and snippets.

@lanedraex
Created May 27, 2017 20:56
Show Gist options
  • Save lanedraex/5d0b8ec25e385d78e6d6997c2601b06e to your computer and use it in GitHub Desktop.
Save lanedraex/5d0b8ec25e385d78e6d6997c2601b06e to your computer and use it in GitHub Desktop.
My neovim config.
----------------------------- BUNDLE ------------------------------------
" Plugin Manager: vim-plug
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.local/share/nvim/plugged')
" Make sure you use single quotes
" Deoplete is the abbreviation of "dark powered neo-completion".
" It provides an asynchronous keyword completion system in the current buffer.
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'sebastianmarkow/deoplete-rust'
" This is a Vim plugin that provides Rust file detection, syntax highlighting, formatting, Syntastic integration, and more.
Plug 'rust-lang/rust.vim'
" This plugin allows vim to use Racer for Rust code completion and navigation.
Plug 'racer-rust/vim-racer'
" A (Neo)vim plugin for formatting code.
Plug 'sbdchd/neoformat'
" fzf is a general-purpose command-line fuzzy finder.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" A light and configurable statusline/tabline for Vim
Plug 'itchyny/lightline.vim'
" Insert or delete brackets, parens, quotes in pair.
Plug 'https://github.com/jiangmiao/auto-pairs.git'
" Syntastic is a syntax checking plugin for Vim created by Martin Grenfell.
Plug 'https://github.com/vim-syntastic/syntastic.git'
" Vim plugin that uses clang for completing C/C++ code.
Plug 'https://github.com/Rip-Rip/clang_complete.git'
" +++++++++++++++++++++++++++++ Color schemes ++++++++++++++++++++++++++++++
Plug 'https://github.com/mhartington/oceanic-next.git'
Plug 'https://github.com/chriskempson/base16-vim.git'
Plug 'https://github.com/fmoralesc/molokayo.git'
Plug 'https://github.com/morhetz/gruvbox.git'
" ==========================================================================
" +++++++++++++++++++++++++++++ Better Language Support ++++++++++++++++++++++++++++++
Plug 'https://github.com/sheerun/vim-polyglot.git'
" ==========================================================================
" Initialize plugin system
call plug#end()
" ===============================================================================
" *************************************************************************
" Editor
set tabstop=8
set softtabstop=4
set shiftwidth=4
" round indent to nearest shiftwidth multiple
set shiftround
" uses spaces instead of tabs
set expandtab
set encoding=utf-8
set fileencodings=utf-8
set autoread
set relativenumber
set hidden
" Show the current row and column at the bottom right.
set ruler
set updatetime=300 " set updatetime to shorter value
if !has("gui_running")
" Mintty supports control sequences for chaning cursor style.
" Block cursor in normal mode, line cursor in insert mode.
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
" Avoiding [Escape] timeout issues in Vim.
let &t_ti.="\e[?7727h"
let &t_te.="\e[?7727l"
noremap <Esc>0[ <Esc>
noremap! <Esc>0[ <Esc>
endif
set termguicolors
set background=dark
colorscheme gruvbox
" Turn off sounds.
set visualbell t_vb=
au GuiEnter * set visualbell t_vb=
" Remove all trailing whitespace by pressing F12
nnoremap <F12> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" Clear search buffer (clears the last search highlights)
nnoremap <F11> :let @/=""<CR>
" Highlight keywords in comments like TODO, FIXME, WARNING, NOTE
augroup highlight_keyword
autocmd!
autocmd WinEnter,VimEnter * :silent! call matchadd('Todo', 'TODO\|FIXME\|WARNING\|NOTE\|Plugin:', -1)
augroup END
" For Windows Users to back to temp directory
set backup
set backupdir=~lanedraex/../../mnt/c/dev/temp
set backupskip=~lanedraex/../../mnt/c/dev/temp/*
set directory=~lanedraex/../../mnt/c/dev/temp
set writebackup
" Automatically closing the scratch window at the top of the vim window on finishing a
" complete or leaving insert.
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" deoplete tab-complete
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
" ===============================================================================
" *************************************************************************
" Plugin: deoplete
" Use deoplete.
let g:deoplete#enable_at_startup = 1
" ===============================================================================
" *************************************************************************
" Plugin: deoplete-rust
" Set fully qualified path to racer binary. If it is in your PATH already use which racer. (required)
let g:deoplete#sources#rust#racer_binary='/home/lanedraex/.cargo/bin/racer'
" Set Rust source code path (when cloning from Github usually ending on /src). (required)
let g:deoplete#sources#rust#rust_source_path='/home/lanedraex/.multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src'
" To disable default key mappings (gd & K) add the following
" let g:deoplete#sources#rust#disable_keymap=1
" Set max height of documentation split.
" let g:deoplete#sources#rust#documentation_max_height=20
" ===============================================================================
" *************************************************************************
" Plugin: vim-racer
let g:racer_cmd = "~/.cargo/bin"
" ===============================================================================
" *************************************************************************
" Plugin: neoformat
noremap <F3> :Neoformat<CR>
" Configure enabled formatters.
let g:neoformat_enabled_python = ['rustfmt']
" Enable alignment
let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1
" ===============================================================================
" *************************************************************************
" Plugin: fzf
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" ===============================================================================
" *************************************************************************
" Plugin: Lightline
let g:lightline = {
\ 'colorscheme': 'gruvbox',
\}
" ===============================================================================
" *************************************************************************
" Plugin: Syntastic
let g:syntastic_mode_map = { 'mode': 'passive' }
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++1z -stdlib=libc++'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" ===============================================================================
" *************************************************************************
" Plugin: Clang Complete
" Set the clang_library_path to the directory containing file named libclang.{dll,so,dylib}.
let g:clang_library_path = '/usr/lib/llvm-3.8/lib/libclang-3.8.so.1'
" ===============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment