vimrc (4487B)
1 set nocompatible 2 set encoding=utf-8 3 4 " Remove any autocmds defined by the system for consistency. 5 if has("autocmd") 6 autocmd! 7 endif 8 9 call plug#begin('~/.vim/plugged') 10 " Formatting. 11 Plug 'rhysd/vim-clang-format' " clang-format. 12 Plug 'vim-scripts/spacehi.vim' " Highlight bad whitespace. 13 14 " Language support plugins. 15 Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } 16 Plug 'rust-lang/rust.vim' 17 call plug#end() 18 19 " Bind fancier manpage plugin to Shift-k. 20 runtime ftplugin/man.vim 21 set keywordprg=:Man 22 23 let mapleader=',' 24 let s:cpo_save=&cpo 25 set cpo&vim 26 27 " Enable middle-mouse paste. 28 map! <S-Insert> <MiddleMouse> 29 map <S-Insert> <MiddleMouse> 30 31 " Kill ex mode. 32 noremap Q <NOP> 33 34 " Disable visual-mode mouse select. 35 set mouse= 36 37 " Kill arrow keys, for great justice. 38 noremap <Up> <NOP> 39 noremap <Down> <NOP> 40 noremap <Left> <NOP> 41 noremap <Right> <NOP> 42 43 " Retain selection on <,>. 44 vmap < <gv 45 vmap > >gv 46 let &cpo=s:cpo_save 47 unlet s:cpo_save 48 49 " Basic options 50 set incsearch " Turn on incrememental searching. 51 set hlsearch " Highlight search. 52 set visualbell " Less noise. 53 set number " Use line numbering. 54 set ruler " Show row/col in status. 55 set laststatus=1 " Only show status line if > 1 window. 56 set showmatch " Highlight matching bracket. 57 set history=50 " Keep 50 lines of cmdline history. 58 set wildmenu " Nicer autocomplete. 59 set wildmode=longest,full 60 set wildignore=*.o,*.pyc " Ignore some filetypes during completion. 61 set spelllang=en_ca " Set the spelling language. 62 63 " Omnicomplete 64 set completeopt+=longest 65 66 " Indentation/tabulation 67 set autoindent " Copy indent from current line when starting a new line. 68 set smartindent " Attempt to autoindent when starting a new line. 69 set smarttab " Use shiftwidth rather than tabstop at start of line. 70 set tabstop=2 " Number of spaces per tab. 71 set shiftwidth=2 " Number of spaces for each step of autoindent. 72 set softtabstop=2 " Number of spaces per tab when editing. 73 set expandtab " Insert spaces in place of tabs. 74 75 " Configure whitespace highlighting. 76 let g:spacehi_spacecolor="ctermbg=red" 77 let g:spacehi_tabcolor="ctermbg=red" 78 79 " Configure tag file locations. 80 set tags+=~/.local/tags/system.tags 81 set tags+=~/.local/tags/cxx.tags 82 83 " Snippets 84 nmap <leader>sch :0r ~/.vim/snippets/cc.h<CR> 85 nmap <leader>sci :0r ~/.vim/snippets/cc.cc<CR> 86 nmap <leader>scn :.-1r ~/.vim/snippets/namespace.cc<CR> 87 nmap <leader>scs :.-1r ~/.vim/snippets/struct.cc<CR> 88 nmap <leader>scc :.-1r ~/.vim/snippets/class.cc<CR> 89 nmap <leader>sjn :.-1r ~/.vim/snippets/journal.md<CR> 90 91 " Configure colour scheme and syntax highlighting. 92 if &t_Co > 2 93 syntax enable 94 set background=dark 95 96 " No background colour in terminal. 97 hi Normal ctermbg=none 98 99 " Visual selection colour. 100 hi Visual ctermbg=237 101 102 " Spelling mistake hightlight colour. 103 hi SpellLocal cterm=underline ctermbg=58 104 hi SpellBad cterm=underline ctermbg=88 105 106 " Completion menu colour. 107 hi Pmenu ctermbg=0 ctermfg=8 108 hi PmenuSel ctermbg=8 ctermfg=15 109 110 " Line number colour. 111 hi LineNr ctermfg=7 112 113 " Highlight cursor line, max column. 114 set cursorline 115 hi ColorColumn ctermbg=235 116 hi CursorLine ctermbg=235 cterm=bold 117 hi CursorLineNr ctermbg=235 cterm=bold 118 119 if has("autocmd") 120 " Cursor line highlighting 121 au WinLeave * setlocal nocursorline 122 au WinEnter * setlocal cursorline 123 au BufLeave * setlocal nocursorline 124 au BufEnter * setlocal cursorline 125 126 " Highlight over-length lines 127 au BufEnter,InsertLeave * set colorcolumn=80 128 au BufEnter,InsertLeave *.txt,*.md,*.wiki set colorcolumn=80 129 au BufEnter,InsertLeave *.txt,*.md,*.wiki set textwidth=80 130 au BufEnter,InsertLeave *.java,*.m,*.mm set colorcolumn=100 131 au BufEnter,InsertLeave *.java,*.m,*.mm set textwidth=100 132 133 " Highlight trailing space 134 au BufEnter,InsertLeave *.bzl,*.c,*.cc,*.cpp,*.cs,*.dart,*.h,*.java,*.m,*.mm,*.py,*.s SpaceHi 135 136 " Fix python's indent overrides. 137 au FileType python setl ts=2 sw=2 sts=2 et 138 endif 139 endif 140 141 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 142 " Functions 143 144 " Toggle absolute/relative numbering. 145 function! ToggleNumbering() 146 if (&number == 0) 147 set number 148 elseif (&relativenumber == 0) 149 set relativenumber 150 else 151 set norelativenumber 152 set nonumber 153 endif 154 endfunc 155 nmap <C-n> :call ToggleNumbering()<CR>