254 lines
7.7 KiB
VimL
254 lines
7.7 KiB
VimL
" 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="," " leader is comma
|
|
|
|
" jk is escape
|
|
inoremap jk <esc>
|
|
|
|
" in normal mode F2 will save the file
|
|
nmap <F2> :w<CR>
|
|
|
|
" in insert mode F2 will exit insert, save, enters insert again
|
|
imap <F2> <ESC>:w<CR>i
|
|
|
|
" in normal mode <leader>y will save to the selection clipboard
|
|
nmap <leader>y "*yy
|
|
|
|
" in normal mode <leader>p will paste from the selection clipboard
|
|
nmap <leader>p "*p
|
|
|
|
" }}}
|
|
|
|
" VUNDLE {{{
|
|
|
|
filetype off
|
|
" set the runtime path to include Vundle and initialize
|
|
set rtp+=~/.vim/bundle/Vundle.vim
|
|
call vundle#begin()
|
|
" alternatively, pass a path where Vundle should install plugins
|
|
"call vundle#begin('~/some/path/here')
|
|
|
|
" Keep Plugin commands between vundle#begin/end.
|
|
|
|
" let Vundle manage Vundle, required
|
|
Plugin 'VundleVim/Vundle.vim'
|
|
|
|
" AUTOCOMPLETION 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
|
|
|
|
" 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
|
|
Plugin 'junegunn/goyo.vim' " Distraction free writing by removing UI elements and centering everything
|
|
Plugin 'junegunn/limelight.vim' " Dim paragraphs above and below the active paragraph
|
|
|
|
|
|
" All of your Plugins must be added before the following line
|
|
call vundle#end() " required
|
|
filetype plugin indent on " required
|
|
" To ignore plugin indent changes, instead use:
|
|
"filetype plugin on
|
|
"
|
|
" Brief help
|
|
" :PluginList - lists configured plugins
|
|
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
|
|
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
|
|
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
|
|
"
|
|
" see :h vundle for more details or wiki for FAQ
|
|
" Put your non-Plugin stuff after this line
|
|
|
|
" }}}
|
|
|
|
" 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:ycm_extra_conf_globlist = ['!~/*'] " is overwritten in autogroups for c
|
|
let g:ycm_autoclose_preview_window_after_insertion = 1
|
|
|
|
let NERDTreeIgnore=['^__pycache__$', '\.pyc', '\~$'] " ignore files in NERDTree
|
|
|
|
let g:indentLine_char = '▏'
|
|
|
|
" in normal mode ,ne will open NERDTree
|
|
nmap <leader>ne :NERDTree<CR>
|
|
|
|
" }}}
|
|
|
|
" COLORS {{{
|
|
|
|
colorscheme badwolf
|
|
let g:airline_theme='badwolf'
|
|
|
|
syntax on
|
|
|
|
" Disable BCE (background color erase)
|
|
let &t_ut=''
|
|
|
|
" }}}
|
|
|
|
" SPACES & TABS {{{
|
|
|
|
set expandtab " expand tabs to spaces
|
|
set shiftwidth=4
|
|
set softtabstop=4 " number of spaces in tab when editing
|
|
|
|
" }}}
|
|
|
|
" UI CONFIG {{{
|
|
|
|
" The default cursor in normal mode is block but this will be overridden by
|
|
" any shell configuration.
|
|
|
|
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 " show 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 {{{
|
|
|
|
" Find files in sub-folders too
|
|
set path+=**
|
|
|
|
set incsearch " search as characters are entered
|
|
set hlsearch " highlight matches
|
|
" turn off search hightlight after search with `,<space>`
|
|
nnoremap <leader><space> :nohlsearch<CR>
|
|
|
|
" }}}
|
|
|
|
" 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 <space> za
|
|
|
|
" }}}
|
|
|
|
" MOVEMENT {{{
|
|
|
|
" move vertically by visual line (don't jump wrapped lines)
|
|
nnoremap j gj
|
|
nnoremap k gk
|
|
|
|
" highlight last inserted text
|
|
nnoremap gV `[v`]
|
|
|
|
" }}}
|
|
|
|
" AUTOGROUPS {{{
|
|
|
|
" set language-specific settings for certain filetype/file extensions
|
|
" augroup makes the command only apply once
|
|
" autocmd! directive clears all the autocmds for the current group
|
|
|
|
augroup configgroup
|
|
autocmd!
|
|
|
|
" reset cursor on start:
|
|
autocmd VimEnter * silent !echo -en "\e[2 q"
|
|
|
|
autocmd VimEnter * highlight clear SignColumn
|
|
|
|
" Automatically open NERDTree when vim starts up without files specified
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
|
|
|
" Close vim if the only window left open is a NERDTree
|
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
|
|
|
" Run StripWhitespace function on write
|
|
autocmd BufWritePre * :StripWhitespace
|
|
" Run Flake8 on write in python files
|
|
autocmd BufWritePost *.py call flake8#Flake8()
|
|
|
|
autocmd FileType c let g:ycm_extra_conf_globlist = ['~/*']
|
|
autocmd FileType java setlocal noexpandtab
|
|
autocmd FileType java setlocal list
|
|
autocmd FileType java setlocal listchars=tab:+\ ,eol:-
|
|
autocmd FileType java setlocal formatprg=par\ -w80\ -T4
|
|
autocmd FileType php setlocal expandtab
|
|
autocmd FileType php setlocal list
|
|
autocmd FileType php setlocal lischars=tab:+\ ,eol:-
|
|
autocmd FileType php setlocal formatprg=par\ -w80\ -T4
|
|
autocmd FileType ruby setlocal tabstop=2
|
|
autocmd FileType ruby setlocal shiftwidth=2
|
|
autocmd FileType ruby setlocal softtabstop=2
|
|
autocmd FileType ruby setlocal commentstring=#\ %s
|
|
autocmd FileType python setlocal commentstring=#\ %s
|
|
autocmd FileType python 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 FileType yaml setlocal foldmethod=indent
|
|
autocmd BufEnter *.cls setlocal filetype=java
|
|
autocmd BufEnter *zsh-theme setlocal filetype=zsh
|
|
autocmd BufEnter Makefile setlocal noexpandtab
|
|
autocmd BufEnter Makefile setlocal tabstop=6
|
|
autocmd BufEnter Makefile setlocal shiftwidth=6
|
|
autocmd BufEnter Makefile setlocal softtabstop=0
|
|
autocmd BufEnter *.asm setlocal noexpandtab
|
|
autocmd BufEnter *.asm setlocal tabstop=6
|
|
autocmd BufEnter *.asm setlocal shiftwidth=6
|
|
autocmd BufEnter *.asm setlocal softtabstop=0
|
|
autocmd BufEnter *.html setlocal foldmethod=indent
|
|
autocmd BufEnter *.sh setlocal tabstop=2
|
|
autocmd BufEnter *.sh setlocal shiftwidth=2
|
|
autocmd BufEnter *.sh setlocal softtabstop=2
|
|
autocmd BufEnter *.sh setlocal foldmethod=marker
|
|
autocmd BufEnter *.sh setlocal foldlevel=0
|
|
augroup END
|
|
|
|
" }}}
|
|
|
|
set modelines=1
|
|
" vim:foldmethod=marker:foldlevel=0
|