dotfiles/nvim-init.vim
2018-05-29 12:25:21 +02:00

449 lines
15 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" General Options {{{1
" ====================
set nocompatible " ignored in NeoVim, tells Vim to break compatibility with vi
let mapleader=';' " set <leader>
syntax enable
set mouse=a " enable mouse selection
set number " line numbers on the left side
set relativenumber " number+relativenumber = relative numbers for all but current line
set showcmd " show the commands while typing
set splitright " open new splits on the right
set splitbelow " open new splits below
set autoread " autoreload file on change
set scrolloff=4 " keep the cursor 4 lines away from the top/bottom
set ruler " show the lines/% bottomright
set encoding=utf-8 " set default encoding
set laststatus=2 " always show the status line
set conceallevel=0 " don't use conceals, seriously
let g:tex_conceal='' " I said no conceals
" toggle hybrid relative numbers when entering/leaving insert mode
":augroup numbertoggle
": autocmd!
": autocmd InsertLeave * set relativenumber
": autocmd InsertEnter * set norelativenumber
":augroup END
" change cursor shape according to mode
:let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set shell=/bin/zsh " use zsh instead of bash
" wrap lines at 72 characters
"set formatprg=par\ -w72
"set formatoptions=tcrqnlmj
"set textwidth=72
set ignorecase smartcase " don't match case if typing in all-lowercase
" ignore motion for < >
nnoremap < <<
nnoremap > >>
" make < > shifts keep selection
vnoremap < <gv
vnoremap > >gv
inoremap  <esc>dbxa
" Switching buffers {{{2
nnoremap <silent> <F14> :bprev<cr> " s-F2
nnoremap <silent> <F15> :bnext<cr> " s-F3
nnoremap <silent> <F16> :bwipeout<cr> " s-F4
" Indentation {{{2
set tabstop=2 " tab is 2 wide
set shiftwidth=2 " for use with > and <
set noexpandtab " tab key puts tabs
"set list listchars=tab:‧\ ,trail:· " display tabs with a leading \cdot. Alternatives: \mapsto ↦, U+16EB runic single punctuation ᛫
" trailing whitespace looks like \cdot
set list listchars=tab:¦\ ,trail" show indentation lines for tabs, trailing whitespace looks like \cdot
" Misc {{{2
set foldlevelstart=3 " Not too much folding
" Escape from NeoVim terminals
tnoremap <Esc> <C-\><C-n>
" Just hit the [à0] button on an AZERTY, no need to do shift+à to for 0
nnoremap à 0
inoremap jj <Esc>
" Clear highlighting after a search
nnoremap <silent> <leader>n :noh<CR>
" Open a file in the current directory
nmap <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" sudo save
command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
" Navigate to bookmark, AZERTY has no backtick key
noremap <leader>m `
" Consistent aliases to jump to first non-whitespace character and last character
noremap <a-h> ^
noremap <a-l> $
inoremap <a-h> <esc>^i
inoremap <a-l> <esc>$a
noremap <home> ^
inoremap <home> <esc>^i
" System clipboard {{{2
" Copy to clipboard " Paste from clipboard
vnoremap <leader>y "+y | nnoremap <leader>p "+p
nnoremap <leader>Y "+yg_ | nnoremap <leader>P "+P
nnoremap <leader>y "+y | vnoremap <leader>p "+p
nnoremap <leader>yy "+yy | vnoremap <leader>P "+P
" Opening windows {{{2
nnoremap <C-j> <C-w>n
nmap <C-k> <C-w>N
nnoremap <C-l> <C-w>v
nmap <C-h> <C-w>V
imap <C-w> <esc><C-w>
vmap <C-w> <esc><C-w>
nnoremap <silent> <C-w>v :vnew<CR>
nnoremap <silent> <C-w>V :let spr=&spr<BAR>set nospr<BAR>vnew<BAR>let &spr=spr<CR>
nnoremap <silent> <C-w>N :let spr=&spr<BAR>set nospr<BAR>new<BAR>let &spr=spr<CR>
" Cool arrows {{{2
inoremap <leader>arse
inoremap <leader>arsw
inoremap <leader>arne
inoremap <leader>arnw
" Default visual block {{{2
nnoremap v <C-v>
nnoremap <C-v> v
" Color settings {{{2
" Decent color schemes: ron, delek, peachpuff, slate, murphy, elflord, desert
source /usr/share/nvim/runtime/colors/ron.vim
highlight LineNr ctermfg=08 ctermbg=None
highlight link Whitespace Conceal
" Adding modeline {{{2
" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <leader>ml :call AppendModeline()<CR>
" Plugins {{{1
" ============
" Plug {{{2
" ------------
call plug#begin('~/.config/nvim/plug')
" Colors
"Plug 'chriskempson/base16-vim'
" Language support
Plug 'sheerun/vim-polyglot' " color, indentation support for 100+ languages
Plug 'chrisbra/csv.vim', { 'for': 'csv' } " CSV files
"Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } " included in vim-polyglot
"Plug 'LaTeX-Box-Team/LaTeX-Box', { 'for': 'tex' } " included in vim-polyglot
"Plug 'rust-lang/rust.vim', { 'for': 'rust' } " included in vim-polyglot
" C/C++
"Plug 'vim-scripts/c.vim', { 'for': ['c', 'cpp', 'objc'] } " various IDE-like C features
Plug 'vim-scripts/DoxygenToolkit.vim', { 'for': ['c', 'cpp', 'python'] } " simplify Doxygen documentation in C, C++, Python
"Plug 'derekwyatt/vim-fswitch', { 'for': ['c', 'cpp', 'objc'] } " switch between companion source files (e.g. .h and .cpp)
Plug 'derekwyatt/vim-fswitch', { 'on': 'FSRight' } " switch between companion source files (e.g. .h and .cpp)
"Plug 'derekwyatt/vim-protodef', { 'for': ['c', 'cpp', 'objc'] } " pull in C++ function prototypes into implementation files
Plug 'vim-scripts/Conque-GDB', { 'for': ['c', 'cpp', 'objc'] } " GDB command line interface and terminal emulator
"Plug 'Shougo/vimproc.vim', { 'do': 'make' } " dependency of vim-vebugger, asynchronous execution library
"Plug 'idanarye/vim-vebugger', { 'for': ['c', 'cpp', 'objc', 'java', 'python', 'ruby'] } " debugger frontend for GDB, LDB, PDB, RDebug e.a.
" Edit
"Plug 'jiangmiao/auto-pairs' " insert or delete [], (), '' etc. in pairs
Plug 'sjl/gundo.vim' " visualise your undo tree
Plug 'scrooloose/nerdcommenter' " intensely orgasmic commenting
Plug 'SirVer/ultisnips' " ultimate snippet solution
Plug 'fadein/vim-FIGlet', { 'on': 'FIGlet' } " ASCII art
Plug 'honza/vim-snippets' " snippets for ultisnips
Plug 'junegunn/vim-easy-align' " easily align text in Alexander Approved™ ways
Plug 'matze/vim-move' " move lines and selections up and down
Plug 'kana/vim-operator-user' " define your own operator easily
"Plug 'junegunn/vim-peekaboo' " preview registers when pressing \" or @
Plug 'gcmt/wildfire.vim' " smart selection of the closest text object
Plug 'Valloric/YouCompleteMe', { 'do': 'git submodule update --init --recursive && ./install.py' } " code-completion engine
" Navigation
"Plug 'ctrlpvim/ctrlp.vim' " fuzzy file, buffer, mru, tag, etc. finder
Plug 'dyng/ctrlsf.vim' " search for code and edit it in-place
Plug 'Yggdroot/indentLine' " display the indention levels with thin vertical lines
Plug 'scrooloose/nerdtree' " filesystem tree explorer
Plug 'majutsushi/tagbar' " display tags in a window, ordered by scope
Plug 'easymotion/vim-easymotion' " quickly jump to any location on the screen
Plug 'airblade/vim-gitgutter' " show a Git diff in the gutter, stage/undo hunks
Plug 'mhinz/vim-grepper', { 'on': 'Grepper' } " asynchronous git grep search
"Plug 'ludovicchabant/vim-gutentags' " unobtrusively manage tag files
Plug 'tpope/vim-obsession' " continuously updated session files
" Powerline
Plug 'vim-airline/vim-airline' " statusline plugin in pure Vimscript
Plug 'vim-airline/vim-airline-themes' " themes for airline
" Analysis
Plug 'w0rp/ale' " asynchronous linting engine
"Plug 'dbmrq/vim-ditto' " highlight overused words
" Misc
Plug 'kassio/neoterm', { 'on': 'T' } " wrapper of some neovim's :terminal functions
"Plug 'tpope/vim-fugitive' " a Git wrapper
Plug 'vim-scripts/TeTrIs.vim' " Tetris clone
call plug#end()"
" Haskell {{{2
" ------------
let g:haskell_enable_quantification=1
let g:haskell_enable_recursivedo=1
let g:haskell_enable_arrowsyntax=1
let g:haskell_enable_pattern_synonyms=1
let g:haskell_enable_typeroles=1
let g:haskell_enable_static_pointers=1
" Markdown {{{2
" -------------
let g:vim_markdown_conceal = 0
" CSV.vim {{{2
" ------------
" Doxygen {{{2
" ------------
nnoremap <leader>df :Dox<CR>
nnoremap <leader>dl :DoxLic<CR>
nnoremap <leader>da :DoxAuthor<CR>
let g:DoxygenToolkit_authorName="Midgard"
" FSwitch {{{2
" ------------
let b:fswitchdst = ''
au! BufEnter *.cpp let b:fswitchdst = 'hpp,h' | let b:fswitchlocs = '.'
au! BufEnter *.hpp let b:fswitchdst = 'cpp' | let b:fswitchlocs = '.'
au! BufEnter *.c let b:fswitchdst = 'h' | let b:fswitchlocs = '.'
au! BufEnter *.h let b:fswitchdst = 'c,cpp' | let b:fswitchlocs = '.'
nmap <silent> <F2> :FSRight<cr>
" Protodef {{{2
" -------------
nnoremap ;def :call protodef#ReturnSkeletonsFromPrototypesForCurrentBuffer({})<cr>
" ConqueGDB {{{2
" --------------
let g:ConqueGdb_Leader = ','
" Commented entries are the defaults
"let g:ConqueGdb_Run = g:ConqueGdb_Leader . 'r'
"let g:ConqueGdb_Continue = g:ConqueGdb_Leader . 'c'
let g:ConqueGdb_Next = g:ConqueGdb_Leader . 'o' " step over
let g:ConqueGdb_Step = g:ConqueGdb_Leader . 'i' " step in
"let g:ConqueGdb_Print = g:ConqueGdb_Leader . 'p'
"let g:ConqueGdb_ToggleBreak = g:ConqueGdb_Leader . 'b'
let g:ConqueGdb_Finish = g:ConqueGdb_Leader . 'O' " step out
"let g:ConqueGdb_Backtrace = g:ConqueGdb_Leader . 't'
nnoremap <F12> :ConqueGdb --args build/tests --debug
" Vebugger {{{2
" -------------
"let g:vebugger_leader='<leader>v'
"
"nnoremap <F5> :VBGstepOver<cr>
"nnoremap <F6> :VBGstepIn<cr>
"nnoremap <F7> :VBGstepOut<cr>
"nnoremap <F8> :VBGcontinue<cr>
"nnoremap <F12> :VBGstartGDB ./huffman
" Auto-pairs {{{2
" ---------------
" Gundo {{{2
" ----------
nnoremap <F3> :GundoToggle<CR>
" NERDCommenter {{{2
" ------------------
nmap & <leader>c<space>
vmap & <leader>c<space>
" UltiSnips {{{2
" ---------------
let g:UltiSnipsExpandTrigger='²'
" EasyAlign {{{2
" --------------
xmap <leader>a <Plug>(EasyAlign)
nmap <leader>a <Plug>(EasyAlign)
" Move (lines) {{{2
" -----------------
" Operator user {{{2
" ------------------
" Peekaboo {{{2
" -------------
" Wildfire {{{2
" -------------
" YouCompleteMe {{{2
" ------------------
noremap <leader>g :YcmCompleter GoToImprecise<CR>
let g:ycm_error_symbol='!>'
let g:ycm_warning_symbol='-'
let g:ycm_enable_diagnostic_highlighting=0
let g:ycm_complete_in_comments=1
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_add_preview_to_completeopt=1
let g:ycm_autoclose_preview_window_after_insertion=1
let g:ycm_server_python_interpreter='/usr/bin/python3'
let g:ycm_global_ycm_extra_conf='~/.config/nvim/ycm_extra_conf.py'
let g:ycm_extra_conf_globlist = ['~/Nextcloud/*', '~/Documents/*','~/development/*','~/unief/*'] " ,'!~/*'
"let g:ycm_rust_src_path='/data/programming/rustc-1.7.0/src'
set completeopt=menu
" CtrlP {{{2
" ----------
let g:ctrlp_map='<leader>l'
let g:ctrlp_user_command=['.git/', 'git --git-dir=%s/.git ls-files . -co --exclude-standard']
nnoremap <leader>s :CtrlPTag<CR>"
" Ctrl-S-F {{{2
" -------------
" IndentLine {{{2
" ---------------
" NERDTree {{{2
" -------------
nnoremap <silent> <leader>t :NERDTreeToggle<CR><CR>
let NERDTreeIgnore=[
\ ".*\\.class$",
\ ".*\\.o$",
\ ".*\\.hi$",
\ ".*\\.pyc$",
\ ".*\\.bak$",
\ ".*\\~$"
\ ]
" automatically open NERDTree when opening vi
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Tagbar {{{2
" -----------
nnoremap <leader>o :Tagbar<CR>
let g:tagbar_autoclose=1
let g:tagbar_autofocus=1
let g:tagbar_sort=0
let g:tagbar_compact=1
let g:tagbar_iconchars=['▸', '▾']
let g:tagbar_type_make={
\ 'kinds': ['m:macros', 't:targets']
\ }
let g:tagbar_type_rust={
\ 'ctagstype': 'rust',
\ 'kinds': [
\ 'n:modules',
\ 's:structs',
\ 'i:interfaces',
\ 'c:implementations',
\ 'f:functions',
\ 'g:enums',
\ 't:typedefs',
\ 'v:variables',
\ 'M:macros',
\ 'm:fields',
\ 'e:enumerators',
\ 'F:methods',
\ ]
\ }
" EasyMotion {{{2
" ---------------
let g:EasyMotion_do_mapping=0
let g:EasyMotion_startofline=0
map <leader>f <Plug>(easymotion-s)
map <leader>j <Plug>(easymotion-j)
map <leader>k <Plug>(easymotion-k)
map <leader>w <Plug>(easymotion-bd-w)
nmap <leader>w <Plug>(easymotion-overwin-w)
" GitGutter {{{2
" --------------
" Grepper {{{2
" ------------
nnoremap <leader>G :Grepper<CR>
let g:grepper={
\ 'tools': ['rg', 'git', 'grep'],
\ 'open': 1,
\ 'jump': 0,
\ }
" Gutentags {{{2
" --------------
let g:gutentags_cache_dir = '~/.cache/gutentag'
" Obsession {{{2
" --------------
" Powerline {{{2
" --------------
" Airline {{{2
" ------------
let g:airline_powerline_fonts=1
let g:airline_theme='bubblegum'
let g:airline#extensions#ycm#enabled=1
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#ale#enabled=1
let g:ale_linters = {
\ 'c': [],
\ 'cpp': [],
\}
" Ale {{{2
" --------
let g:ale_lint_on_text_change='normal'
let g:ale_lint_on_insert_leave=1
let g:ale_completion_delay=''
let g:ale_lint_delay=500
" Ditto {{{2
" ----------
" Neoterm {{{2
" ------------
" Fugitive {{{2
" -------------
" TeTrIs {{{2
" -----------
" vim: set foldmethod=marker foldlevel=1 et ts=2 sw=2 ft=vim nowrap :