Skip to content

Instantly share code, notes, and snippets.

@Devligue
Last active August 8, 2018 11:40
Show Gist options
  • Save Devligue/e516f3c50facc7914c064710c3a507de to your computer and use it in GitHub Desktop.
Save Devligue/e516f3c50facc7914c064710c3a507de to your computer and use it in GitHub Desktop.
My personal installation and configuration guide for NeoVim
" Set font on start
:Guifont DejaVu Sans Mono for Powerline:10
"let $vundle="~/AppData/Local/nvim/bundle/Vundle.vim"
let $vimhome=fnamemodify(resolve(expand("~/.vimrc")), ':p:h')
let $vundle=$vimhome."/bundle/Vundle.vim"
" Be iMproved
set nocompatible
"=====================================================
"" Vundle settings
"=====================================================
filetype off
set rtp+=$vundle
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
"-------------------=== Code/Project navigation ===-------------
Plugin 'scrooloose/nerdtree' " Project and file navigation
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'majutsushi/tagbar' " Class/module browser
Plugin 'ctrlpvim/ctrlp.vim' " Fast transitions on project files
"-------------------=== Other ===-------------------------------
Plugin 'bling/vim-airline' " Lean & mean status/tabline for vim
Plugin 'vim-airline/vim-airline-themes' " Themes for airline
Plugin 'powerline/powerline' " Powerline fonts plugin
Plugin 'fisadev/FixedTaskList.vim' " Pending tasks list
Plugin 'rosenfeld/conque-term' " Consoles as buffers
Plugin 'tpope/vim-surround' " Parentheses, brackets, quotes, XML tags, and more
Plugin 'flazz/vim-colorschemes' " Colorschemes
Plugin 'airblade/vim-gitgutter.git' " Git support
Plugin 'rafi/awesome-vim-colorschemes.git' " Awesome Vim color schemes
"-------------------=== Snippets support ===--------------------
Plugin 'garbas/vim-snipmate' " Snippets manager
Plugin 'MarcWeber/vim-addon-mw-utils' " dependencies #1
Plugin 'tomtom/tlib_vim' " dependencies #2
Plugin 'honza/vim-snippets' " snippets repo
"-------------------=== Languages support ===-------------------
Plugin 'tpope/vim-commentary' " Comment stuff out
Plugin 'mitsuhiko/vim-sparkup' " Sparkup(XML/jinja/htlm-django/etc.) support
Plugin 'Rykka/riv.vim' " ReStructuredText plugin
"Plugin 'Valloric/YouCompleteMe' " Autocomplete plugin
Plugin 'jiangmiao/auto-pairs.git' " Braces magic
"-------------------=== Python ===-----------------------------
" Plugin 'klen/python-mode' " Python mode (docs, refactor, lints...)
Plugin 'scrooloose/syntastic' " Syntax checking plugin for Vim
call vundle#end() " required
filetype on
filetype plugin on
filetype plugin indent on
"=====================================================
"" General settings
"=====================================================
syntax enable " syntax highlight
set t_Co=256 " set 256 colors
"colorscheme wombat256mod " set color scheme
colorscheme onedark " set color scheme
set number " show line numbers
set ruler
set ttyfast " terminal acceleration
set relativenumber " toggle on relative numbers
set tabstop=4 " 4 whitespaces for tabs visual presentation
set shiftwidth=4 " shift lines by 4 spaces
set smarttab " set tabs for a shifttabs logic
set expandtab " expand tabs into spaces
set autoindent " indent when moving to the next line while writing code
set si " smart indent
set cursorline " shows line under the cursor's line
set showmatch " shows matching part of bracket pairs (), [], {}
set enc=utf-8 " utf-8 by default
set autoread " auto read when a file is changed from the outside
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set updatetime=500 " wait 0.5 sec after stoping typing to trigger plugins
set backspace=indent,eol,start " backspace removes all (indents, EOLs, start) What is start?
set scrolloff=10 " let 10 lines before/after cursor during scroll
set clipboard=unnamed " use system clipboard
set exrc " enable usage of additional .vimrc files from working directory
set secure " prohibit .vimrc files to execute shell, create files, etc...
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Highlight search results
set hlsearch
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
" Makes search act like search in modern browsers
set incsearch
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Add a bit extra margin to the left
set foldcolumn=1
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
let mapleader = ","
" Additional mappings for Esc (useful for MacBook with touch bar)
"inoremap jj <Esc>
"inoremap jk <Esc>
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"=====================================================
"" Moving around, tabs, windows and buffers
"=====================================================
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>:tabclose<cr>gT
" Close all the buffers
map <leader>ba :bufdo bd<cr>
map <leader>l :bnext<cr>
map <leader>h :bprevious<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Bracket, parenthesis and comments related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Stop from repeating comments
set formatoptions-=r
set formatoptions-=o
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
"=====================================================
"" Tabs / Buffers settings
"=====================================================
tab sball
set switchbuf=useopen
set laststatus=2
nmap <F9> :bprev<CR>
nmap <F10> :bnext<CR>
nmap <silent> <leader>q :SyntasticCheck # <CR> :bp <BAR> bd #<CR>
"" Search settings
"=====================================================
set incsearch " incremental search
set hlsearch " highlight search results
"=====================================================
"" AirLine settings
"=====================================================
let g:airline_theme='badwolf'
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#formatter='unique_tail'
let g:airline_powerline_fonts=1
"=====================================================
"" TagBar settings
"=====================================================
let g:tagbar_autofocus=0
" let g:tagbar_width=42
autocmd BufEnter *.py :call tagbar#autoopen(0)
autocmd BufWinLeave *.py :TagbarClose
"=====================================================
"" NERDTree settings
"=====================================================
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '__pycache__$'] " Ignore files in NERDTree
" let NERDTreeWinSize=40
autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments
nmap " :NERDTreeToggle<CR>
let g:nerdtree_tabs_open_on_console_startup=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 0
"=====================================================
"" SnipMate settings
"=====================================================
let g:snippets_dir='~/.vim/vim-snippets/snippets'
"=====================================================
"" Riv.vim settings
"=====================================================
let g:riv_disable_folding=1
"=====================================================
"" Python settings
"=====================================================
" python executables for different plugins
let g:pymode_python='python'
let g:syntastic_python_python_exec='python'
" rope
let g:pymode_rope=0
let g:pymode_rope_completion=0
let g:pymode_rope_complete_on_dot=0
let g:pymode_rope_auto_project=0
let g:pymode_rope_enable_autoimport=0
let g:pymode_rope_autoimport_generate=0
let g:pymode_rope_guess_project=0
" documentation
let g:pymode_doc=0
let g:pymode_doc_bind='K'
" lints
let g:pymode_lint=0
" virtualenv
let g:pymode_virtualenv=1
" breakpoints
let g:pymode_breakpoint=1
let g:pymode_breakpoint_key='<leader>b'
" syntax highlight
let g:pymode_syntax=1
let g:pymode_syntax_slow_sync=1
let g:pymode_syntax_all=1
let g:pymode_syntax_print_as_function=g:pymode_syntax_all
let g:pymode_syntax_highlight_async_await=g:pymode_syntax_all
let g:pymode_syntax_highlight_equal_operator=g:pymode_syntax_all
let g:pymode_syntax_highlight_stars_operator=g:pymode_syntax_all
let g:pymode_syntax_highlight_self=g:pymode_syntax_all
let g:pymode_syntax_indent_errors=g:pymode_syntax_all
let g:pymode_syntax_string_formatting=g:pymode_syntax_all
let g:pymode_syntax_space_errors=g:pymode_syntax_all
let g:pymode_syntax_string_format=g:pymode_syntax_all
let g:pymode_syntax_string_templates=g:pymode_syntax_all
let g:pymode_syntax_doctests=g:pymode_syntax_all
let g:pymode_syntax_builtin_objs=g:pymode_syntax_all
let g:pymode_syntax_builtin_types=g:pymode_syntax_all
let g:pymode_syntax_highlight_exceptions=g:pymode_syntax_all
let g:pymode_syntax_docstrings=g:pymode_syntax_all
" highlight 'long' lines (>= 80 symbols) in python files
augroup vimrc_autocmds
autocmd!
autocmd FileType python,rst,c,cpp highlight Excess ctermbg=DarkGrey guibg=Black
autocmd FileType python,rst,c,cpp match Excess /\%81v.*/
autocmd FileType python,rst,c,cpp set nowrap
autocmd FileType python,rst,c,cpp set colorcolumn=80
augroup END
" code folding
let g:pymode_folding=0
" pep8 indents
let g:pymode_indent=1
" code running
let g:pymode_run=1
let g:pymode_run_bind='<F5>'
" syntastic
let g:syntastic_always_populate_loc_list=1
let g:syntastic_auto_loc_list=1
let g:syntastic_enable_signs=1
let g:syntastic_check_on_wq=0
let g:syntastic_aggregate_errors=1
let g:syntastic_loc_list_height=5
let g:syntastic_error_symbol='X'
let g:syntastic_style_error_symbol='X'
let g:syntastic_warning_symbol='x'
let g:syntastic_style_warning_symbol='x'
let g:syntastic_python_checkers=['flake8', 'pydocstyle', 'python']
" YouCompleteMe
set completeopt-=preview
let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf.py'
let g:ycm_confirm_extra_conf=0
nmap <leader>g :YcmCompleter GoTo<CR>
nmap <leader>d :YcmCompleter GoToDefinition<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Moving around, tabs and buffers
" -> Status line
" -> Editing mappings
" -> vimgrep searching and cope displaying
" -> Spell checking
" -> Misc
" -> Helper functions
" -> VIM Plugins
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype plugins
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" :W sudo saves the file
" (useful for handling the permission-denied error)
" command W w !sudo tee % > /dev/null
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" Turn on the Wild menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=.git\*,.hg\*,.svn\*
else
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Properly disable sound on errors on MacVim
if has("gui_macvim")
autocmd GUIEnter * set vb t_vb=
endif
" Add a bit extra margin to the left
set foldcolumn=1
" Toggle on relative numbers
set relativenumber
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Enable 256 colors palette in Gnome Terminal
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
map <space> /
map <c-space> ?
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>:tabclose<cr>gT
" Close all the buffers
map <leader>ba :bufdo bd<cr>
map <leader>l :bnext<cr>
map <leader>h :bprevious<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Bracket, parenthesis and comments related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Stop from repeating comments
set formatoptions-=r
set formatoptions-=o
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Quickly open a buffer for scribble
map <leader>q :e ~/buffer<cr>
" Quickly open a markdown buffer for scribble
map <leader>x :e ~/buffer.md<cr>
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')
" Vim-Go
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Awesome Vim Color Schemes
Plug 'https://github.com/rafi/awesome-vim-colorschemes.git'
" Lightlink
Plug 'https://github.com/itchyny/lightline.vim.git'
" Vim-surround
Plug 'https://github.com/tpope/vim-surround.git'
" Vim-gitgutter
Plug 'https://github.com/airblade/vim-gitgutter.git'
" Auto Pairs
Plug 'https://github.com/jiangmiao/auto-pairs.git'
" NERD Commenter
Plug 'https://github.com/scrooloose/nerdcommenter.git'
" Initialize plugin system
call plug#end()
let g:go_term_mode = "split"
let g:go_term_height = 5
colorscheme onedark

Configuration

Windows

config file location: ~/AppData/Local/nvim

nvim config file: init.vim

nvim gui config: ginit.vim

Linux

config file location: ~/.config/nvim/

nvim config file: init.vim

Configuration related github repos

Plugin Managers

Plugins

Powerline patched fonts can be downloaded here.

If exuberant ctags are not installed, download them here. Extract to any directory and add it to $PATH.

let $vundle="~/AppData/Local/nvim/bundle/Vundle.vim"
" Be iMproved
set nocompatible
"=====================================================
"" Vundle settings
"=====================================================
filetype off
set rtp+=$vundle
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
"-------------------=== Code/Project navigation ===-------------
Plugin 'scrooloose/nerdtree' " Project and file navigation
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'majutsushi/tagbar' " Class/module browser
Plugin 'ctrlpvim/ctrlp.vim' " Fast transitions on project files
"-------------------=== Other ===-------------------------------
Plugin 'bling/vim-airline' " Lean & mean status/tabline for vim
Plugin 'vim-airline/vim-airline-themes' " Themes for airline
Plugin 'powerline/powerline' " Powerline fonts plugin
Plugin 'fisadev/FixedTaskList.vim' " Pending tasks list
Plugin 'rosenfeld/conque-term' " Consoles as buffers
Plugin 'tpope/vim-surround' " Parentheses, brackets, quotes, XML tags, and more
Plugin 'flazz/vim-colorschemes' " Colorschemes
Plugin 'airblade/vim-gitgutter.git' " Git support
Plugin 'rafi/awesome-vim-colorschemes.git' " Awesome Vim color schemes
"-------------------=== Snippets support ===--------------------
Plugin 'garbas/vim-snipmate' " Snippets manager
Plugin 'MarcWeber/vim-addon-mw-utils' " dependencies #1
Plugin 'tomtom/tlib_vim' " dependencies #2
Plugin 'honza/vim-snippets' " snippets repo
"-------------------=== Languages support ===-------------------
Plugin 'tpope/vim-commentary' " Comment stuff out
Plugin 'mitsuhiko/vim-sparkup' " Sparkup(XML/jinja/htlm-django/etc.) support
Plugin 'Rykka/riv.vim' " ReStructuredText plugin
Plugin 'Valloric/YouCompleteMe' " Autocomplete plugin
Plugin 'jiangmiao/auto-pairs.git' " Braces magic
"-------------------=== Python ===-----------------------------
Plugin 'klen/python-mode' " Python mode (docs, refactor, lints...)
Plugin 'scrooloose/syntastic' " Syntax checking plugin for Vim
Plugin 'ambv/black' " Format python with black
call vundle#end() " required
filetype on
filetype plugin on
filetype plugin indent on
"=====================================================
"" General settings
"=====================================================
syntax enable " syntax highlight
set t_Co=256 " set 256 colors
"colorscheme wombat256mod " set color scheme
colorscheme onedark " set color scheme
set number " show line numbers
set ruler
set ttyfast " terminal acceleration
set relativenumber " toggle on relative numbers
set tabstop=4 " 4 whitespaces for tabs visual presentation
set shiftwidth=4 " shift lines by 4 spaces
set smarttab " set tabs for a shifttabs logic
set expandtab " expand tabs into spaces
set autoindent " indent when moving to the next line while writing code
set si " smart indent
set cursorline " shows line under the cursor's line
set showmatch " shows matching part of bracket pairs (), [], {}
set enc=utf-8 " utf-8 by default
set autoread " auto read when a file is changed from the outside
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set updatetime=500 " wait 0.5 sec after stoping typing to trigger plugins
set backspace=indent,eol,start " backspace removes all (indents, EOLs, start) What is start?
set scrolloff=10 " let 10 lines before/after cursor during scroll
set clipboard=unnamed " use system clipboard
set exrc " enable usage of additional .vimrc files from working directory
set secure " prohibit .vimrc files to execute shell, create files, etc...
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Highlight search results
set hlsearch
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
" Makes search act like search in modern browsers
set incsearch
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Add a bit extra margin to the left
set foldcolumn=1
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
let mapleader = ","
" Additional mappings for Esc (useful for MacBook with touch bar)
"inoremap jj <Esc>
"inoremap jk <Esc>
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"=====================================================
"" Moving around, tabs, windows and buffers
"=====================================================
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>:tabclose<cr>gT
" Close all the buffers
map <leader>ba :bufdo bd<cr>
map <leader>l :bnext<cr>
map <leader>h :bprevious<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Bracket, parenthesis and comments related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Stop from repeating comments
set formatoptions-=r
set formatoptions-=o
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^
" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
"=====================================================
"" Tabs / Buffers settings
"=====================================================
tab sball
set switchbuf=useopen
set laststatus=2
nmap <F9> :bprev<CR>
nmap <F10> :bnext<CR>
nmap <silent> <leader>q :SyntasticCheck # <CR> :bp <BAR> bd #<CR>
"" Search settings
"=====================================================
set incsearch " incremental search
set hlsearch " highlight search results
"=====================================================
"" AirLine settings
"=====================================================
let g:airline_theme='badwolf'
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#formatter='unique_tail'
let g:airline_powerline_fonts=1
"=====================================================
"" TagBar settings
"=====================================================
let g:tagbar_autofocus=0
" let g:tagbar_width=42
autocmd BufEnter *.py :call tagbar#autoopen(0)
autocmd BufWinLeave *.py :TagbarClose
"=====================================================
"" NERDTree settings
"=====================================================
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '__pycache__$'] " Ignore files in NERDTree
" let NERDTreeWinSize=40
autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments
nmap <F3> :NERDTreeToggle<CR>
let g:nerdtree_tabs_open_on_console_startup=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
endif
return ''
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 0
"=====================================================
"" SnipMate settings
"=====================================================
let g:snippets_dir='~/.vim/vim-snippets/snippets'
"=====================================================
"" Riv.vim settings
"=====================================================
let g:riv_disable_folding=1
"=====================================================
"" Python settings
"=====================================================
" python executables for different plugins
let g:pymode_python='C:\Program Files (x86)\Python36-32\python'
let g:syntastic_python_python_exec='C:\Program Files (x86)\Python36-32\python'
" rope
let g:pymode_rope=0
let g:pymode_rope_completion=0
let g:pymode_rope_complete_on_dot=0
let g:pymode_rope_auto_project=0
let g:pymode_rope_enable_autoimport=0
let g:pymode_rope_autoimport_generate=0
let g:pymode_rope_guess_project=0
" documentation
let g:pymode_doc=0
let g:pymode_doc_bind='K'
" lints
let g:pymode_lint=0
" virtualenv
let g:pymode_virtualenv=1
" breakpoints
let g:pymode_breakpoint=1
let g:pymode_breakpoint_key='<leader>b'
" syntax highlight
let g:pymode_syntax=1
let g:pymode_syntax_slow_sync=1
let g:pymode_syntax_all=1
let g:pymode_syntax_print_as_function=g:pymode_syntax_all
let g:pymode_syntax_highlight_async_await=g:pymode_syntax_all
let g:pymode_syntax_highlight_equal_operator=g:pymode_syntax_all
let g:pymode_syntax_highlight_stars_operator=g:pymode_syntax_all
let g:pymode_syntax_highlight_self=g:pymode_syntax_all
let g:pymode_syntax_indent_errors=g:pymode_syntax_all
let g:pymode_syntax_string_formatting=g:pymode_syntax_all
let g:pymode_syntax_space_errors=g:pymode_syntax_all
let g:pymode_syntax_string_format=g:pymode_syntax_all
let g:pymode_syntax_string_templates=g:pymode_syntax_all
let g:pymode_syntax_doctests=g:pymode_syntax_all
let g:pymode_syntax_builtin_objs=g:pymode_syntax_all
let g:pymode_syntax_builtin_types=g:pymode_syntax_all
let g:pymode_syntax_highlight_exceptions=g:pymode_syntax_all
let g:pymode_syntax_docstrings=g:pymode_syntax_all
" highlight 'long' lines (>= 80 symbols) in python files
augroup vimrc_autocmds
autocmd!
autocmd FileType python,rst,c,cpp highlight Excess ctermbg=DarkGrey guibg=Black
autocmd FileType python,rst,c,cpp match Excess /\%89v.*/
autocmd FileType python,rst,c,cpp set nowrap
autocmd FileType python,rst,c,cpp set colorcolumn=88
augroup END
" code folding
let g:pymode_folding=1
" pep8 indents
let g:pymode_indent=1
" code running
let g:pymode_run=1
let g:pymode_run_bind='<F5>'
" syntastic
let g:syntastic_always_populate_loc_list=1
let g:syntastic_auto_loc_list=1
let g:syntastic_enable_signs=1
let g:syntastic_check_on_wq=0
let g:syntastic_aggregate_errors=1
let g:syntastic_loc_list_height=5
let g:syntastic_error_symbol='E'
let g:syntastic_style_error_symbol='E'
let g:syntastic_warning_symbol='W'
let g:syntastic_style_warning_symbol='W'
let g:syntastic_python_checkers=['flake8', 'pydocstyle', 'python']
let g:syntastic_python_checker_args = '--ignore=E501'
" YouCompleteMe
set completeopt-=preview
let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf.py'
let g:ycm_confirm_extra_conf=0
nmap <leader>g :YcmCompleter GoTo<CR>
nmap <leader>d :YcmCompleter GoToDefinition<CR>
autocmd BufWritePre *.py execute ':Black'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment