Update .vimrc
6e1175c6c8660fd4392ec4f489144fa805d92098
1 parent
143a872a
.vimrc
+64 -47
| 16 | 16 | set ruler |
|
| 17 | 17 | set showmatch |
|
| 18 | 18 | set wildmenu |
|
| 19 | 19 | set wildmode=list,full |
|
| 20 | 20 | set nowrap |
|
| 21 | - | set breakindent " Preserve indentation when wrapping |
|
| 22 | 21 | set hidden |
|
| 23 | 22 | set modeline |
|
| 24 | 23 | set hlsearch |
|
| 25 | 24 | set incsearch |
|
| 26 | 25 | set autoread " Auto-reload modified files (with no local changes) |
| 54 | 53 | set colorcolumn=100 |
|
| 55 | 54 | set list |
|
| 56 | 55 | set listchars=tab:·\ ,eol:¬,trail:█ |
|
| 57 | 56 | set fillchars=diff:\ ,vert:│ |
|
| 58 | 57 | set diffopt=filler,vertical,foldcolumn:0 |
|
| 59 | - | set statusline=%<%f\ %h%m%r%=%y\ \ %-14(%{&sw}:%{&sts}:%{&ts}%)%-14.(%l,%c%V%)\ %P |
|
| 58 | + | set statusline=%<%f\ (%{gitbranch#name()})\ %h%m%r%=%y\ \ %-14(%{&sw}:%{&sts}:%{&ts}%)%-14.(%l,%c%V%)\ %P |
|
| 60 | 59 | set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor |
|
| 61 | 60 | set spelllang=en_us,en_gb |
|
| 62 | 61 | set completeopt=menu |
|
| 63 | 62 | ||
| 64 | 63 | " We don't use tabs much, but at least try and show less cruft |
| 100 | 99 | write |
|
| 101 | 100 | endif |
|
| 102 | 101 | endfunction |
|
| 103 | 102 | ||
| 104 | 103 | " Per file-type indentation |
|
| 105 | - | au FileType haskell setlocal sts=4 sw=4 expandtab formatprg=stylish-haskell |
|
| 106 | - | au FileType javascript setlocal sts=4 sw=4 expandtab |
|
| 107 | - | au FileType css setlocal ts=4 sw=4 noexpandtab |
|
| 108 | - | au FileType go setlocal ts=4 sw=4 noexpandtab |
|
| 109 | - | au FileType c,cpp,glsl setlocal ts=8 sw=8 noexpandtab |
|
| 110 | - | au FileType lua setlocal sw=2 expandtab |
|
| 111 | - | au FileType sh,zsh setlocal ts=2 sw=2 noexpandtab |
|
| 112 | - | au FileType vim,ruby setlocal sts=2 sw=2 expandtab |
|
| 113 | - | au FileType help setlocal ts=4 sw=4 noexpandtab |
|
| 114 | - | au FileType txt setlocal noai nocin nosi inde= wrap linebreak |
|
| 104 | + | au FileType haskell setlocal number sts=4 sw=4 expandtab formatprg=stylish-haskell |
|
| 105 | + | au FileType javascript setlocal number sts=4 sw=4 expandtab |
|
| 106 | + | au FileType css setlocal number ts=4 sw=4 noexpandtab |
|
| 107 | + | au FileType go setlocal number ts=4 sw=4 noexpandtab |
|
| 108 | + | au FileType c,cpp,glsl setlocal number ts=8 sw=8 noexpandtab |
|
| 109 | + | au FileType lua setlocal number sw=2 expandtab |
|
| 110 | + | au FileType sh,zsh setlocal number ts=2 sw=2 noexpandtab |
|
| 111 | + | au FileType vim,ruby setlocal number sts=2 sw=2 expandtab |
|
| 112 | + | au FileType help setlocal number ts=4 sw=4 noexpandtab |
|
| 113 | + | au FileType rust setlocal number signcolumn=yes nowrap |
|
| 114 | + | au FileType plain setlocal nonumber noai nocin nosi inde= wrap linebreak textwidth=80 |
|
| 115 | 115 | au FileType pandoc setlocal nonumber |
|
| 116 | 116 | au FileType markdown setlocal nonumber |
|
| 117 | - | au FileType rst setlocal nonumber sw=2 expandtab |
|
| 117 | + | au FileType rst setlocal nonumber sw=2 expandtab wrap linebreak textwidth=80 |
|
| 118 | 118 | au FileType fountain setlocal nonumber noai nocin nosi inde= wrap linebreak |
|
| 119 | 119 | au FileType tex setlocal |
|
| 120 | 120 | ||
| 121 | 121 | au BufRead,BufNewFile *.md setf markdown |
|
| 122 | 122 | au BufRead,BufNewFile *.tex setf tex |
|
| 123 | 123 | au BufRead,BufNewFile *.todo setf todo |
|
| 124 | 124 | au BufRead,BufNewFile *.tikz setf tex |
|
| 125 | 125 | au BufRead,BufNewFile *.toml setf toml |
|
| 126 | 126 | ||
| 127 | + | " If no file-type is detected, set to plain. |
|
| 128 | + | autocmd BufEnter * if &filetype == "" | setlocal ft=plain | endif |
|
| 129 | + | ||
| 127 | 130 | let c_no_curly_error = 1 |
|
| 128 | 131 | ||
| 129 | 132 | if has("nvim") |
|
| 130 | 133 | au TermOpen * set nonumber modifiable |
|
| 131 | 134 | endif |
| 245 | 248 | nnoremap <Leader>f :FuzzyGrep<CR> |
|
| 246 | 249 | ||
| 247 | 250 | " Navigate relative to the current file |
|
| 248 | 251 | cmap %/ %:p:h/ |
|
| 249 | 252 | ||
| 250 | - | map <Leader>m :make check<CR> |
|
| 253 | + | map <Leader>m :make<CR> |
|
| 251 | 254 | map <Leader>e :e ~/.vimrc<CR> |
|
| 252 | 255 | map <Leader>s :source ~/.vimrc<CR> |
|
| 253 | 256 | ||
| 254 | 257 | " Repeat previous command |
|
| 255 | 258 | map <Leader><Space> @: |
| 303 | 306 | Plug 'cloudhead/shady.vim' |
|
| 304 | 307 | Plug 'tikhomirov/vim-glsl' |
|
| 305 | 308 | Plug 'vim-pandoc/vim-pandoc-syntax' |
|
| 306 | 309 | Plug 'junegunn/goyo.vim' |
|
| 307 | 310 | Plug 'vim-scripts/fountain.vim' |
|
| 308 | - | Plug 'vimwiki/vimwiki' |
|
| 309 | 311 | Plug 'exu/pgsql.vim' |
|
| 310 | 312 | Plug 'hail2u/vim-css3-syntax' |
|
| 311 | 313 | Plug 'lervag/vimtex' |
|
| 312 | 314 | Plug 'vim-scripts/gnupg.vim' |
|
| 313 | - | Plug 'octol/vim-cpp-enhanced-highlight' |
|
| 314 | - | Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh', 'for': ['cpp', 'c', 'rust']} |
|
| 315 | - | Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins', 'for': ['cpp', 'c', 'rust'] } |
|
| 315 | + | Plug 'itchyny/vim-gitbranch' |
|
| 316 | 316 | Plug 'cespare/vim-toml' |
|
| 317 | 317 | Plug 'rust-lang/rust.vim', { 'for': ['rust'] } |
|
| 318 | + | Plug 'neoclide/coc.nvim', {'branch': 'release', 'for': ['rust'] } |
|
| 318 | 319 | ||
| 319 | 320 | call plug#end() |
|
| 320 | 321 | endif |
|
| 321 | 322 | ||
| 323 | + | " |
|
| 324 | + | " Quickfix Signs |
|
| 325 | + | " |
|
| 326 | + | sign define quickfix-error text=× texthl=ErrorSign |
|
| 327 | + | ||
| 328 | + | command! QuickfixSigns call s:QuickfixSigns() |
|
| 329 | + | ||
| 330 | + | " autocmd BufWrite * sign unplace * |
|
| 331 | + | autocmd CursorHold *.rs silent QuickfixSigns |
|
| 332 | + | ||
| 333 | + | function! s:QuickfixSigns() |
|
| 334 | + | silent! cgetfile |
|
| 335 | + | sign unplace * |
|
| 336 | + | for dict in getqflist() |
|
| 337 | + | if dict.type != 'E' |
|
| 338 | + | continue |
|
| 339 | + | endif |
|
| 340 | + | try |
|
| 341 | + | silent exe "sign" |
|
| 342 | + | \ "place" |
|
| 343 | + | \ dict.lnum |
|
| 344 | + | \ "line=" . string(dict.lnum) |
|
| 345 | + | \ "name=" . "quickfix-error" |
|
| 346 | + | \ "file=" . bufname(dict.bufnr) |
|
| 347 | + | catch |
|
| 348 | + | ||
| 349 | + | endtry |
|
| 350 | + | endfor |
|
| 351 | + | endfunction |
|
| 352 | + | ||
| 353 | + | command! Write setlocal spell | Goyo 80 |
|
| 354 | + | command! Code setlocal nospell | Goyo! |
|
| 355 | + | ||
| 322 | 356 | if has("nvim") |
|
| 323 | 357 | " Make sure we dont' load the rust cargo plugin from rust.vim! |
|
| 324 | 358 | let g:loaded_rust_vim_plugin_cargo = 1 |
|
| 325 | 359 | " Don't add errors to quickfix if rustfmt fails. |
|
| 326 | 360 | let g:rustfmt_fail_silently = 1 |
|
| 327 | 361 | autocmd BufWritePre *.rs :RustFmt |
|
| 328 | 362 | endif |
|
| 329 | 363 | ||
| 330 | - | " |
|
| 331 | - | " LSP |
|
| 332 | - | " |
|
| 333 | - | if has("nvim") |
|
| 334 | - | let g:LanguageClient_serverCommands = { |
|
| 335 | - | \ 'rust': ['env', 'CARGO_TARGET_DIR=./target', '~/.cargo/bin/rustup', 'run', 'stable', 'rls'], |
|
| 336 | - | \ 'cpp': ['clangd'], |
|
| 337 | - | \ } |
|
| 338 | - | endif |
|
| 339 | - | ||
| 340 | - | function! RunLanguageClient() |
|
| 341 | - | if has("nvim") |
|
| 342 | - | if has_key(g:LanguageClient_serverCommands, &filetype) |
|
| 343 | - | call deoplete#enable() |
|
| 344 | - | nnoremap <silent> <buffer> <C-]> :call LanguageClient#textDocument_definition()<CR> |
|
| 345 | - | nnoremap <silent> <buffer> <leader>d :call LanguageClient#textDocument_hover()<CR> |
|
| 346 | - | nnoremap <silent> <buffer> <leader>c :call LanguageClient_contextMenu()<CR> |
|
| 347 | - | nnoremap <silent> <buffer> <leader>rn :call LanguageClient#textDocument_rename()<CR> |
|
| 348 | - | ||
| 349 | - | let g:LanguageClient_diagnosticsSignsMax = 0 |
|
| 350 | - | let g:LanguageClient_selectionUI_autoOpen = 0 |
|
| 351 | - | let g:LanguageClient_diagnosticsList = "Quickfix" |
|
| 352 | - | let g:LanguageClient_hoverPreview = "Never" |
|
| 353 | - | let g:LanguageClient_settingsPath = "settings.json" |
|
| 354 | - | let g:LanguageClient_windowLogMessageLevel = "Error" |
|
| 355 | - | endif |
|
| 356 | - | endif |
|
| 364 | + | " coc.vim |
|
| 365 | + | function! SetupCoc() |
|
| 366 | + | nmap <silent> gd <Plug>(coc-definition) |
|
| 367 | + | nmap <silent> gi <Plug>(coc-implementation) |
|
| 368 | + | nmap <silent> gr <Plug>(coc-references) |
|
| 369 | + | nmap <silent> <leader>/ :CocList --interactive symbols<CR> |
|
| 370 | + | ||
| 371 | + | " This is a kind of hack to make <C-Y> not trigger snippet expansion. |
|
| 372 | + | " We use <C-p><C-n> to insert the selection without triggering anything, and |
|
| 373 | + | " then close the popup. |
|
| 374 | + | inoremap <silent><expr> <C-Y> pumvisible() ? "<C-p><C-n><Esc>a" : "\<C-Y>" |
|
| 357 | 375 | endfunction |
|
| 358 | - | autocmd FileType * call RunLanguageClient() |
|
| 359 | - | ||
| 376 | + | autocmd User CocNvimInit call SetupCoc() |
|
| 360 | 377 | ||
| 361 | 378 | " Use custom colors. |
|
| 362 | 379 | " This has to go after plugin initialization. |
|
| 363 | 380 | try |
|
| 364 | 381 | colorscheme shady |