|
| 1 | +" Copyright (c) 2019 Kai-Ming Guo. All rights reserved. |
| 2 | +" Use of this source code is governed by a BSD-style license that can be |
| 3 | +" found in the LICENSE file. |
| 4 | + |
| 5 | + |
| 6 | +" |
| 7 | +" --------------------------------------------------------------------------- |
| 8 | +" _. General {{{ |
| 9 | + |
| 10 | +" Sets how many lines of history Vim has to remember |
| 11 | +set history=500 |
| 12 | + |
| 13 | +" Set 'nocompatible' to ward off unexpected things that your distro might |
| 14 | +" have made, as well as sanely reset options when re-sourcing .vimrc |
| 15 | +if has('vim_starting') |
| 16 | + " Set compatibility to Vim only |
| 17 | + if &compatible | set nocompatible | endif |
| 18 | +endif |
| 19 | + |
| 20 | +" Attempt to determine the type of a file based on its name and possibly its |
| 21 | +" contents. Use this to allow intelligent auto-indenting for each filetype, |
| 22 | +" and for plugins that are filetype specific |
| 23 | +filetype indent plugin on |
| 24 | + |
| 25 | +" Set to auto read when a file is change from the outside |
| 26 | +set autoread |
| 27 | + |
| 28 | +" }}} |
| 29 | + |
| 30 | +" --------------------------------------------------------------------------- |
| 31 | +" _. Vim User Interface {{{ |
| 32 | + |
| 33 | +" Set 7 lines to the cursor - when moving vertically using j/k |
| 34 | +set so=7 |
| 35 | + |
| 36 | +" Avoid garbled characters in Chinese language windows OS |
| 37 | +set langmenu=en |
| 38 | +exec 'source ' . $VIMRUNTIME . '/delmenu.vim' |
| 39 | +exec 'source ' . $VIMRUNTIME . '/menu.vim' |
| 40 | + |
| 41 | +" Better command-line completion |
| 42 | +set wildmenu |
| 43 | + |
| 44 | +" Ignore compiled files |
| 45 | +set wildignore+=*.o,*.obj,*.exe,*.so,*.dll,*.pyc,.svn,.hg,.bzr,.git, |
| 46 | + \.sass-cache,*.class,*.scssc,*.cssc,sprockets%*,*.lessc,*/node_modules/*, |
| 47 | + \rake-pipeline-* |
| 48 | + |
| 49 | +" Display the cursor position on the last line of the screen or in the status |
| 50 | +" line of a window |
| 51 | +set ruler |
| 52 | + |
| 53 | +" Display line numbers on the left |
| 54 | +set number |
| 55 | + |
| 56 | +" Always display the status line, even if only one window is displayed |
| 57 | +set laststatus=2 |
| 58 | + |
| 59 | +" A buffer becomes hidden when it is abandoned |
| 60 | +set hidden |
| 61 | + |
| 62 | +" Configure backspace so it acts as it should act |
| 63 | +set backspace=eol,start,indent |
| 64 | +set whichwrap+=<,>,h,l |
| 65 | + |
| 66 | +" Use case insensitive search, except when using capital letters |
| 67 | +set ignorecase |
| 68 | +set smartcase |
| 69 | + |
| 70 | +" Highlight search results |
| 71 | +set hlsearch |
| 72 | + |
| 73 | +" Vim loves to redraw the screen during things it probably doesn't need |
| 74 | +" to--like in the middle of macros. This tells Vim not to bother redrawing |
| 75 | +" during these scenarios, leading to faster macros |
| 76 | +set lazyredraw |
| 77 | + |
| 78 | +" For regular expressions turn magic on |
| 79 | +set magic |
| 80 | + |
| 81 | +" With `showmatch`, when your cursor moves over a parenthesis-like |
| 82 | +" character, the matching one will be highlighted as well |
| 83 | +set showmatch |
| 84 | + |
| 85 | +" How many tenths of a second to blink when matching brackets |
| 86 | +set mat=5 |
| 87 | + |
| 88 | +" No annoying sound on errors |
| 89 | +set noerrorbells visualbell t_vb= |
| 90 | + |
| 91 | +" Color the 80th column differently as a wrapping guide |
| 92 | +if exists('+colorcolumn') |
| 93 | + set colorcolumn=80 |
| 94 | +endif |
| 95 | + |
| 96 | +" Quickly time out on keycodes, but never time out on mappings |
| 97 | +set notimeout ttimeout ttimeoutlen=200 |
| 98 | + |
| 99 | +" }}} |
| 100 | + |
| 101 | +" --------------------------------------------------------------------------- |
| 102 | +" _. Colors and Fonts {{{ |
| 103 | + |
| 104 | +" Enable syntax highlighting |
| 105 | +if has('syntax') && !exists('g:syntax_on') |
| 106 | + syntax enable |
| 107 | +endif |
| 108 | + |
| 109 | +" Force 256 color mode if available |
| 110 | +if $TERM =~ '-256color' |
| 111 | + set t_Co=256 |
| 112 | + set t_ut= |
| 113 | +endif |
| 114 | + |
| 115 | +" Set utf8 as standard encoding and en_US as the standard language |
| 116 | +set encoding=utf8 |
| 117 | + |
| 118 | +" Use Unix as the standard file type |
| 119 | +set fileformats=unix,dos,mac |
| 120 | + |
| 121 | +" Display different types of white spaces. |
| 122 | +set list |
| 123 | +set listchars=tab:›\ ,trail:•,extends:#,nbsp:. |
| 124 | + |
| 125 | +" }}} |
| 126 | + |
| 127 | +" --------------------------------------------------------------------------- |
| 128 | +" _. Files and Backups {{{ |
| 129 | + |
| 130 | +" Double // causes backups to use full file path |
| 131 | +exec 'set backupdir=' . g:vimdir . '/.backup//' |
| 132 | +exec 'set directory=' . g:vimdir . '/.tmp//' |
| 133 | + |
| 134 | +" Turn on backups |
| 135 | +set backup |
| 136 | + |
| 137 | +" }}} |
| 138 | + |
| 139 | +" --------------------------------------------------------------------------- |
| 140 | +" _. Text, Tab and Indent Related {{{ |
| 141 | + |
| 142 | +" Yanks go on clipboard instead |
| 143 | +if has('clipboard') |
| 144 | + if has('unnamedplus') |
| 145 | + " When possible use + register for copy-paste |
| 146 | + set clipboard=unnamed,unnamedplus |
| 147 | + else |
| 148 | + " On macOS and Windows, use * register for copy-paste |
| 149 | + set clipboard=unnamed |
| 150 | + endif |
| 151 | +endif |
| 152 | + |
| 153 | +" Linebreak on 500 characters |
| 154 | +set linebreak |
| 155 | +set textwidth=500 |
| 156 | + |
| 157 | +" Use multiple of shiftwidth when indenting with '<' and '>' |
| 158 | +set shiftround |
| 159 | + |
| 160 | +" Auto-indent spaces with C in Vim |
| 161 | +set autoindent |
| 162 | +set cindent |
| 163 | + |
| 164 | +" }}} |
| 165 | + |
| 166 | +" --------------------------------------------------------------------------- |
| 167 | +" _. Moving Around, Tabs and Buffers {{{ |
| 168 | + |
| 169 | +" Specify the behavior when switching between buffers |
| 170 | +try |
| 171 | + set switchbuf=useopen,usetab,newtab |
| 172 | + set stal=2 |
| 173 | +catch |
| 174 | +endtry |
| 175 | + |
| 176 | +" }}} |
| 177 | + |
| 178 | +" --------------------------------------------------------------------------- |
| 179 | +" _. Status Line {{{ |
| 180 | + |
| 181 | +" Set the command window height to 2 lines, to avoid many cases of having to |
| 182 | +" `press <Enter> to continue` |
| 183 | +set cmdheight=2 |
| 184 | + |
| 185 | +" Default status line format |
| 186 | +set statusline=%<%f\ %h%m%r\ %y%=%{v:register}\ %-14.(%l,%c%V%)\ %P |
| 187 | + |
| 188 | +" }}} |
| 189 | + |
| 190 | +" --------------------------------------------------------------------------- |
| 191 | +" _. Status Line {{{ |
| 192 | + |
| 193 | +" Enable mouse |
| 194 | +set mouse=a |
| 195 | +if has('neovim') |
| 196 | + if has('mouse_sgr') |
| 197 | + set ttymouse=sgr |
| 198 | + else |
| 199 | + set ttymouse=xterm2 |
| 200 | + endif |
| 201 | +endif |
| 202 | + |
| 203 | +" Hide when characters are typed |
| 204 | +set mousehide |
| 205 | + |
| 206 | +" }}} |
0 commit comments