" flyingscorpio's VIM Configuration File " most of this comes from https://dougblack.io/words/a-good-vimrc.html set nocompatible " disable vi compatibility (emulation of old bugs) " UTF-8 ENCODING {{{ set enc=utf-8 set fenc=utf-8 set termencoding=utf-8 " }}} " LEADER SHORTCUTS {{{ let mapleader="," " jk is escape inoremap jk " F2 to save file nmap :w imap :wi " global copy/paste nmap y "*yy nmap p "*p " }}} " VUNDLE {{{ filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required " AUTOCOMPLETION, FORMATTING AND LINTING Plugin 'ycm-core/YouCompleteMe' " Main autocompletion Plugin 'nvie/vim-flake8' " PEP8 linting for Python Plugin 'dense-analysis/ale' " Vim integration for various linters Plugin 'psf/black' " Black autoformatter for Python " HIGHLIGHTING Plugin 'ntpeters/vim-better-whitespace' " Whitespace highlighting and removal Plugin 'python-mode/python-mode' " Python syntax highlighting Plugin 'c.vim' " C syntax highlighting Plugin 'rust-lang/rust.vim' " Rust syntax highlighting Plugin 'godlygeek/tabular' | Plugin 'plasticboy/vim-markdown' " Markdown syntax highlighting " STATUSLINE Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' " MISC. Plugin 'preservim/nerdtree' " A tree explorer plugin Plugin 'Xuyuanp/nerdtree-git-plugin' " A NERDTree plugin showing git status Plugin 'Yggdroot/indentLine' " Display thin vertical lines at each indentation level call vundle#end() filetype plugin indent on " }}} " PLUGIN OPTIONS {{{ let g:ale_python_mypy_options = '--strict --strict-optional' let g:pymode_options_max_line_length = 90 let g:pymode_options_colorcolumn = 0 let g:pymode_lint_ignore = ["E203"] let g:ycm_extra_conf_globlist = ['!~/*'] " is overwritten in autogroups for c let g:ycm_autoclose_preview_window_after_insertion = 1 " in normal mode run YCM's GoTo subcommand nnoremap gd :YcmCompleter GoTo let NERDTreeIgnore=['^__pycache__$', '\.pyc', '\~$'] " ignore files in NERDTree " in normal mode open NERDTree nmap ne :NERDTree " let g:indentLine_char = '▏' let g:indentLine_fileType = ['html', 'htmldjango'] " }}} " COLORS {{{ colorscheme badwolf let g:airline_theme='badwolf' syntax on let &t_ut='' " Disable BCE (background color erase) " }}} " SPACES & TABS {{{ set expandtab " expand tabs to spaces set shiftwidth=4 set softtabstop=4 " number of spaces in tab when editing " }}} " UI CONFIG {{{ let &t_SI = "\e[5 q" " cursor beam on insert mode let &t_SR = "\e[3 q" " cursor underline on replace mode let &t_EI = "\e[2 q" " cursor block otherwise set number relativenumber " hybrid line numbers set spelllang=en,fr set showcmd " show command in bottom bar set cursorline " highlight current line filetype indent on " load filetype-specific indent files set autoindent " use indentation of previous line set smartindent " use intelligent indentation for C set wildmenu " visual autocomplete for command menu set lazyredraw " redraw only when necessary set showmatch " highlight matching braces " }}} " SEARCHING {{{ set path+=** " Find files in sub-folders too set incsearch " search as characters are entered set hlsearch " highlight matches " turn off search hightlight after search nnoremap :nohlsearch " }}} " FOLDING {{{ set foldenable " enable folding set foldlevelstart=10 " open most folds by default (0 to 99) set foldnestmax=10 " guard against too many nested folds set foldmethod=syntax " fold based on filetype " space opens and closes folds nnoremap za " }}} " MOVEMENT {{{ " move vertically by visual line (don't jump wrapped lines) nnoremap j gj nnoremap k gk " }}} " AUTOGROUPS {{{ augroup configgroup autocmd! " Reset cursor on start: the default cursor in normal mode is block but this " will be overridden by any shell/terminal configuration. autocmd VimEnter * silent !echo -en "\e[2 q" " Remove garbage in command section due to the above line autocmd VimEnter * redraw! autocmd VimEnter * highlight clear SignColumn " Run StripWhitespace function on write autocmd BufWritePre * :StripWhitespace " Run Flake8 on write in python files autocmd BufWritePost *.py call flake8#Flake8() " Toggle relative number and absolute number according to focus and insert autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber autocmd FileType c let g:ycm_extra_conf_globlist = ['~/*'] autocmd FileType rust nnoremap :RustFmt autocmd FileType python nnoremap :Black autocmd FileType html,htmldjango,python,yaml setlocal foldmethod=indent autocmd FileType python setlocal colorcolumn=80 autocmd FileType python let g:ycm_python_interpreter_path = '' autocmd FileType python let g:ycm_python_sys_path = [] autocmd FileType python let g:ycm_extra_conf_vim_data = ['g:ycm_python_interpreter_path', 'g:ycm_python_sys_path'] autocmd FileType python let g:ycm_global_ycm_extra_conf = '~/.global_extra_conf.py' autocmd BufEnter Makefile,*.asm setlocal noexpandtab tabstop=6 shiftwidth=6 softtabstop=0 autocmd BufEnter *.sh setlocal shiftwidth=2 tabstop=2 softtabstop=2 foldlevel=0 foldmethod=marker augroup END " }}} set modelines=1 " vim:foldmethod=marker:foldlevel=0