-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
185 lines (175 loc) · 6.23 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
" I couldn't care less about Vi. (nvim default)
set nocompatible
" Modelines may be a security hole.
set nomodeline
" Remove previously set autocommands, in case this is reloaded.
autocmd!
" Vundle Settings
" 2017/06/28: Make sure to link ~/.vimrc to ~/.config/nvim/init.vim, for Neovim.
" Clone Vundle (https://github.com/VundleVim/Vundle.vim.git) to one of the locations below.
" Then run `:PluginInstall` or `vim +PluginInstall +qall` from the command line.
filetype off
if has('nvim')
if has('win64') || has('win32')
let vundle_path = '$HOME/AppData/Local/nvim/bundle/Vundle.vim'
else
let vundle_path = '~/.config/nvim/bundle/Vundle.vim'
endif
else
let vundle_path = '~/.vim/bundle/Vundle.vim'
endif
let &runtimepath .= ',' . vundle_path
call vundle#begin(vundle_path)
Plugin 'VundleVim/Vundle.vim' " Load Vundle.
Plugin 'vim-airline/vim-airline' " A powerline replacement. Makes the bottom line pretty.
Plugin 'Townk/vim-autoclose' " Closes matched pairs automatically.
Plugin 'airblade/vim-gitgutter' " In a git repo, show the file's git state in the gutter.
if has('nvim') || (v:version >= 800) " Ale errors on install for Vim 7.4- the Ubuntu 16.04 default
Plugin 'w0rp/ale' " Automatically lint files.
endif
Plugin 'jnurmine/Zenburn' " Colorscheme.
Plugin 'rust-lang/rust.vim' " Rust linting
call vundle#end()
filetype plugin indent on
" vim-airline Settings
" Be sure to use a patched Powerline font.
" For iTerm2, make sure the profile's non-ASCII font is the same as the ASCII font,
" and transparency is turned off, and text contrast is set to minimum.
let g:airline_powerline_fonts = 1
" Explicitly make the terminal colorful. (This shouldn't be necessary. Use -2 with tmux.)
"set t_Co=256
" Mode is displayed by airline, so don't show it twice.
set noshowmode
" Always show the status line. (nvim default)
set laststatus=2
" Show ALE errors and warnings
let g:airline#extensions#ale#enabled = 1
" vim-autoclose Settings
" Add angle brackets to autoclose for HTML
autocmd Filetype html,xml,eruby let b:AutoClosePairs_add = '<>'
" vim-gitgutter Settings.
let g:gitgutter_diff_args = '-w'
" GUI Settings
if has('gui_running')
set guioptions-=T " No toolbar.
" Font included in https://github.com/rotated8/dotfiles
set guifont=Iosevka:h10:cANSI:qDRAFT
set showtabline=0 " Never show tab bar. File name is in airline. Use buffers and splits!
endif
" Windows Settings
if has('win64') || has('win32')
augroup windows
autocmd!
"autocmd GUIEnter * simalt ~x " Fullscreen.
augroup END
endif
" Tabs are four spaces...
set autoindent " Copy indent from current line when starting a new one. (nvim default)
set expandtab " Never tabs, always convert to spaces.
set tabstop=4
set shiftwidth=4
set softtabstop=4
" ...unless you're using Ruby.
augroup rubytabs
autocmd!
autocmd FileType ruby,eruby setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup END
" Turn syntax highlighting on.
syntax on
" Use the Zenburn colorscheme we downloaded with Vundle
" (Don't complain if it hasn't been downloaded)
silent! colorscheme zenburn
" Number lines
set number
" Don't wrap lines until column 111
set textwidth=111
" Lightly highlight column 99
set colorcolumn=99
highlight ColorColumn ctermbg=238 guibg=#444444
" Highlight the line the cursor is on
set cursorline
" Make tab completion interactable. (nvim default)
set wildmenu
" Don't redraw during macros, and other untyped input.
set lazyredraw
" Vertical splits split to the right
set splitright
" Regular splits split below.
set splitbelow
" Keep five lines at top or bottom of the screen if possible.
set scrolloff=5
" If the last line is too long, show as much of it as possible. (nvim default)
set display=lastline
" No more annoying file.ext~ backup files!
set nobackup
" Allow backspace/delete affect what it likes. (nvim default)
set backspace=indent,eol,start
" UTF-8 by default.
set encoding=utf-8
" Attempt to coerce unix line endings
set fileformats=unix,dos
set fileformat=unix
" Tilde changes case. Now it's also an operator.
set tildeop
" Search ignores case, unless I capitalize.
set ignorecase
set smartcase
" Do not highlight search matches.
set nohlsearch
" Angle brackets, doublequotes, and singlequotes are matched.
" Reflects the settings from vim-autoclose
set matchpairs +=<:>
set matchpairs +=":"
set matchpairs +=':'
set matchpairs +=`:`
" NO BELLS
set noerrorbells
set visualbell
"set vb t_vb= " Removes any bell.
" Bad whitespace shows up in red.
highlight BadWhitespace ctermbg=1 guibg=Red
" This function will clear bad whitespace highlighting in help files.
" It is necessary because Filetype events fire after BufEnter ones. See below.
function! IgnoreHelpFiles()
if &filetype ==? 'help'
call clearmatches()
endif
endfunction
" Match whenever we enter a buffer. (These happen in order)
augroup badwhitespace
autocmd!
" Tabs at the beginning of a line are bad. Especially if they are mixed in with spaces.
autocmd BufEnter * call matchadd('BadWhitespace', '^\( *\t\+\)\+')
" Trailing whitespace is bad, too.
autocmd BufEnter * call matchadd('BadWhitespace', '\s\+$')
" Remove matches in help files.
autocmd BufEnter * call IgnoreHelpFiles()
augroup END
" Enable the mouse in help files only.
set mouse=h
" F1 and arrow keys should not do anything.
noremap <F1> <Nop>
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" Shift-Up gives a list of open buffers. Unbind Shift-Down to prevent confusion.
nnoremap <S-Up> :ls<CR>
nnoremap <S-Down> <Nop>
" Shift-Left and Shift-Right move between buffers in normal mode.
" Only works if your terminal does not use the same combo to switch tabs.
nnoremap <S-Left> :bprevious<CR>
nnoremap <S-Right> :bnext<CR>
" Make it easy to open and reload this file.
" Leader is '\' by default.
nnoremap <leader>ev :edit $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
" Make it easy to open other dotfiles too.
nnoremap <leader>ez :edit ~/.zshrc<CR>
nnoremap <leader>eb :edit ~/.bashrc<CR>
nnoremap <leader>eg :edit ~/.gitconfig<CR>
" Allow quick font resizing for presentations and colleagues.
nnoremap <F11> :set guifont=Iosevka_Fixed:h12:cANSI<CR>
nnoremap <F12> :set guifont=Iosevka_Fixed:h27:cANSI<CR>
" In a terminal, allow <Esc> to exit terminal-mode.
:tnoremap <Esc> <C-\><C-n>