dotfiles/files/.vimrc

213 lines
5.7 KiB
VimL
Raw Permalink Normal View History

2016-09-04 13:58:13 +02:00
filetype plugin on
2017-09-14 13:20:33 +02:00
syntax on
2016-09-04 13:58:13 +02:00
set colorcolumn=80
set background=dark
set number
set relativenumber
2016-09-04 13:58:13 +02:00
set tabstop=4
2017-04-03 09:11:59 +02:00
"set softtabstop=4
2016-09-04 13:58:13 +02:00
set shiftwidth=4
2017-03-16 15:58:47 +01:00
set expandtab
2016-09-04 13:58:13 +02:00
set smartindent
2016-12-13 16:06:25 +01:00
set incsearch
set ttimeoutlen=100
set scrolloff=5
2017-02-16 14:48:40 +01:00
set tw=79
2016-09-04 13:58:13 +02:00
2017-03-07 00:28:29 +01:00
" Tab completion
set wildmode=longest,list,full
set wildmenu
2017-04-03 09:11:59 +02:00
" Splitting
set splitbelow
set splitright
2017-06-05 12:50:51 +02:00
" Split delimiter
set fillchars+=vert:\│
hi! VertSplit ctermbg=243 ctermfg=16
2017-06-05 13:28:07 +02:00
hi! SignColumn ctermbg=16
2017-06-05 12:50:51 +02:00
"" Replaced by christoomey/vim-tmux-navigator
" nnoremap <C-J> <C-W><C-J>
" nnoremap <C-K> <C-W><C-K>
" nnoremap <C-L> <C-W><C-L>
" nnoremap <C-H> <C-W><C-H>
2017-04-03 09:11:59 +02:00
2016-09-04 13:58:13 +02:00
set exrc
set secure
2017-03-07 00:28:29 +01:00
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
2016-09-04 13:58:13 +02:00
"""""""""""""""""" Vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
" Plugins
Plugin 'VundleVim/Vundle.vim'
Plugin 'LucHermitte/lh-vim-lib'
Plugin 'LucHermitte/local_vimrc'
2017-03-06 23:55:00 +01:00
Plugin 'tpope/vim-fugitive'
2016-09-04 13:58:13 +02:00
"Plugin 'Smart-Tabs'
Plugin 'hynek/vim-python-pep8-indent'
Plugin 'tpope/vim-git'
Plugin 'fs111/pydoc.vim'
2018-10-23 10:21:50 +02:00
" Plugin 'vim-syntastic/syntastic'
Plugin 'w0rp/ale'
2017-03-06 23:55:00 +01:00
Plugin 'itchyny/vim-haskell-indent'
2017-03-07 00:28:29 +01:00
Plugin 'junegunn/goyo.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
2017-04-03 09:11:59 +02:00
"Plugin 'davidhalter/jedi-vim'
2017-03-16 14:19:57 +01:00
Plugin 'vim-scripts/a.vim'
2017-04-03 09:11:59 +02:00
Plugin 'rhysd/vim-clang-format'
2017-09-14 13:20:33 +02:00
Plugin 'chrisbra/csv.vim'
Plugin 'let-def/vimbufsync'
Plugin 'the-lambda-church/coquille'
2018-10-23 10:21:50 +02:00
Plugin 'vim-latex/vim-latex'
Plugin 'christoomey/vim-tmux-navigator'
2020-03-25 18:08:07 +01:00
Plugin 'let-def/ocp-indent-vim'
Plugin 'psf/black'
2023-02-10 09:53:00 +01:00
Plugin 'rust-lang/rust.vim'
2016-09-04 13:58:13 +02:00
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""" Syntastic
2017-03-07 00:28:29 +01:00
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
2020-10-05 14:37:41 +02:00
"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
"let g:syntastic_enable_signs=1
"let g:syntastic_cpp_check_header = 1
"let g:syntastic_cpp_remove_include_errors = 1
"let g:syntastic_quiet_messages = {"regex":'pragma once in'}
""let g:syntastic_auto_jump=1
2016-09-04 13:58:13 +02:00
"" LaTeX
let g:syntastic_tex_checkers = [ 'chktex' ]
2020-03-25 18:08:07 +01:00
2016-09-04 13:58:13 +02:00
"" Python
let g:syntastic_python_python_exec = '/usr/bin/python3'
"" C++
2016-12-13 16:06:25 +01:00
let g:syntastic_cpp_compiler_options = '-std=c++14 -Wall -Wextra'
2016-09-04 13:58:13 +02:00
"" Disabled languages
"let g:syntastic_mode_map = { 'passive_filetypes': ['python'] }
2017-03-07 00:28:29 +01:00
let g:syntastic_python_checkers = ['flake8']
" let g:syntastic_ignore_files = []
2016-09-04 13:58:13 +02:00
2020-03-25 18:08:07 +01:00
""""""""""""""""" ALE
let g:ale_c_clangtidy_checks = ['clang-diagnostic-*', 'clang-analyzer-*', '*', '-google-readability-*', '-llvm-include-order', '-hicpp-braces-around-statements', '-readability-braces-around-statements', '-cppcoreguidelines-avoid-magic-numbers', '-readability-magic-numbers']
let g:ale_c_parse_makefile=1
2023-02-10 09:53:00 +01:00
let g:ale_python_flake8_options="--append-config ~/.config/flake8"
""" ALE Rust
let g:ale_rust_cargo_use_clippy = executable('cargo-clippy')
let g:rustfmt_autosave = 1
let g:rustfmt_fail_silently = 1
2020-03-25 18:08:07 +01:00
""""""""""""""""" LaTeX
augroup tex_mappings
autocmd!
autocmd FileType tex,latex,context,plaintex nmap <buffer> <c-h> <Plug>IMAP_JumpForward
autocmd FileType tex,latex,context,plaintex imap <buffer> <c-h> <Plug>IMAP_JumpForward
augroup END
2016-09-04 13:58:13 +02:00
""""""""""""""""" OCaml
2018-10-23 10:21:50 +02:00
au BufEnter *.ml setf ocaml
au BufEnter *.mli setf ocaml
au FileType ocaml call FT_ocaml()
function FT_ocaml()
set shiftwidth=2
set tabstop=2
endfunction
2016-09-04 13:58:13 +02:00
let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
execute "set rtp+=" . g:opamshare . "/merlin/vim"
2018-10-23 10:21:50 +02:00
execute "set rtp+=" . g:opamshare . "/merlin/vimbufsync"
execute "set rtp+=" . g:opamshare . "/ocp-indent/vim"
2016-09-04 13:58:13 +02:00
2017-03-12 01:04:51 +01:00
""""""""""""""""" Python
2020-10-09 15:13:49 +02:00
function Autoblack()
if g:black_auto
execute ':Black'
endif
endfunction
2020-03-25 18:08:07 +01:00
augroup python_settings
autocmd!
2020-10-09 15:13:49 +02:00
autocmd BufWritePre *.py call Autoblack()
2020-03-25 18:08:07 +01:00
autocmd FileType python nmap <LocalLeader>b <Esc>:Black<CR>
autocmd FileType python set colorcolumn=88
autocmd FileType python set textwidth=87
augroup END
2017-03-12 01:04:51 +01:00
let g:jedi#goto_definitions_command = "<LocalLeader>l"
let g:jedi#completions_enabled = 0
2020-10-09 15:13:49 +02:00
let g:black_auto = 1
2017-03-12 01:04:51 +01:00
2017-03-07 00:28:29 +01:00
""""""""""""""""" Airline
set laststatus=2
let g:airline_powerline_fonts = 1
2017-03-12 01:04:51 +01:00
let g:airline#extensions#tabline#enabled = 1
2017-03-07 00:28:29 +01:00
set noshowmode
2020-03-25 18:08:07 +01:00
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
2017-03-07 00:28:29 +01:00
2017-04-03 09:11:59 +02:00
""""""""""""""""" clang-format
let g:clang_format#detect_style_file = 1
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
2016-09-04 13:58:13 +02:00
""""""""""""""""" Trailing whitespaces
fun! TrimWhitespace()
let l:save_cursor = getpos('.')
%s/\s\+$//e
call setpos('.', l:save_cursor)
endfun
" Show trailing whitepace and spaces before a tab:
highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
match ExtraWhitespace /\s\+$\| \+\ze\t/
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
""""""""""""""""" Key bindings
2017-03-07 01:52:21 +01:00
nnoremap <F1> :w<CR>:!make<CR>
inoremap <F1> <esc>:echo 'F1 help disabled'<CR>
nnoremap <F2> :!git status<CR>
nnoremap __ :lprev<CR>
nnoremap ++ :lnext<CR>
nnoremap _+ :ll<CR>
2016-09-04 13:58:13 +02:00
nnoremap <Leader>w :call TrimWhitespace()<CR>
2017-03-06 23:55:00 +01:00
xnoremap <Leader>x <esc>:'<,'>:w !xclip -selection clipboard<CR><esc>
2017-03-12 01:04:51 +01:00
cmap w!! w !sudo tee % > /dev/null
2017-03-06 23:55:00 +01:00
set tw=79
2017-02-16 14:48:40 +01:00
" Disable arrow keys - use hjkl, ffs.
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
2017-03-07 00:28:29 +01:00
xnoremap <leader>b <esc>:'<,'>:w !
xnoremap <Leader>x <esc>:'<,'>:w !xclip -selection clipboard<CR><esc>
2018-10-23 10:21:50 +02:00
noremap <leader>a <esc>:ALEToggle<CR><esc>