.dotfiles/vim/vimrc

125 lines
3.2 KiB
VimL
Raw Normal View History

2023-01-06 18:57:26 +00:00
set nocompatible " iMproved only, no vi compatibility
set sessionoptions-=options " stop sessions from messing with 'runtimepath'
2022-04-16 19:21:45 +00:00
" Load plugins with Pathogen
execute pathogen#infect('bundle/{}', '~/.config/vim/bundle/{}')
syntax on
filetype plugin indent on
" get defaults
"source $VIMRUNTIME/defaults.vim
set backspace=indent,eol,start
set incsearch
2023-01-06 18:57:26 +00:00
set scrolloff=1000 " Center cursor, unless near edge
2022-04-16 19:21:45 +00:00
" other usability enhancements
set backupdir=~/.config/vim/backup/,.
set directory=~/.config/vim/swp/,.
set undodir=~/.config/vim/undo/,.
" Colorize and theme
set t_Co=16
let g:gruvbox_contrast_dark="hard"
let g:gruvbox_italic=1
let g:gruvbox_bold=1
let g:gruvbox_underline=1
let g:gruvbox_undercurl=1
let g:gruvbox_termcolors=256
set background=dark
colorscheme gruvbox
2022-04-16 19:21:45 +00:00
" autocmd vimenter * colorscheme gruvbox
"autocmd vimenter * colorscheme gruvbox
"theme autoload/airline/themes/gruvbox.vim
" colorscheme autoload/lightline/colorscheme/gruvbox.vim
2022-04-16 19:21:45 +00:00
" colorscheme base16-gruvbox-dark-hard
set ttyfast
set termguicolors
set laststatus=2
set guioptions-=e
set encoding=utf-8
set autoread
set autoindent
set hlsearch
set number
set noswapfile
set title
syn on se title
2023-01-06 18:57:26 +00:00
set ts=4
set softtabstop=4
set shiftwidth=4
2022-04-16 19:21:45 +00:00
set expandtab
" Show tabs and trailing spaces
set list listchars=tab:»\ ,trail
set spelllang=en_ca
" Strip whitespace on save
fun! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfun
"command -nargs=0 Stripwhitespace :call <SID>StripTrailingWhitespaces()
" Fix indentation in file
map <leader>i mmgg=G`m<CR>
" Toggle highlighting of search results
nnoremap <leader><space> :nohlsearch<cr>
" Unsmart Quotes
nnoremap guq :%s/\v[“”]/"/g<cr>
if has("autocmd")
" StripTrailingWhitespaces
" TODO: autocmd BufWritePre * DeleteTrailingWhitespace
" To spell check all git commit messages
au BufNewFile,BufRead COMMIT_EDITMSG set spell nonumber nolist wrap linebreak
" Set filetype tab settings
2023-01-06 18:57:26 +00:00
autocmd FileType python,doctest set ai ts=4 sw=4 sts=4 et
2022-04-16 19:21:45 +00:00
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
2023-01-06 18:57:26 +00:00
" 100 characters line
set colorcolumn=101
2023-01-06 18:57:26 +00:00
"execute "set colorcolumn=" . join(range(101,335), ',')
2022-04-16 19:21:45 +00:00
highlight ColorColumn ctermbg=Black ctermfg=DarkRed
" Highlight trailing spaces
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" Configure tabline
set showtabline=2
let g:tablabel =
\ "%N%{flagship#tabmodified()} %{flagship#tabcwds('shorten',',')}"
" Python
2023-01-06 18:57:26 +00:00
au FileType python set ts=4 sts=4 et sw=4 smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
2022-04-16 19:21:45 +00:00
source ${HOME}/.dotfiles/vim/abbreviations/personalAbbreviations.vim
source ${HOME}/.dotfiles/vim/abbreviations/codingAbbreviations.vim