-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
338 lines (256 loc) · 8.83 KB
/
.vimrc
File metadata and controls
338 lines (256 loc) · 8.83 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
" From defaults.vim
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
" Avoid side effects when it was already reset.
if &compatible
set nocompatible
endif
" When the +eval feature is missing, the set command above will be skipped.
" Use a trick to reset compatible only when the +eval feature is missing.
silent! while 0
set nocompatible
silent! endwhile
" Allow backspacing over everything in insert mode.
set backspace=indent,eol,start
set history=500 " keep command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set wildmenu " display completion matches in a status line
set ttimeout " time out for key codes
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
" Show @@@ in the last line if it is truncated.
set display=lastline
" Do incremental searching when it's possible to timeout.
if has('reltime')
set incsearch
endif
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
" confusing.
set nrformats-=octal
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
if has('win32')
set guioptions-=t
endif
" Don't use Ex mode, use Q for formatting.
" Revert with ":unmap Q".
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
" Revert with ":iunmap <C-U>".
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
if has("mouse")
set mouse=a
endif
" Search recursively
set path+=**
" Swap / backup / undo niceties from:
" https://begriffs.com/posts/2019-07-19-history-use-vim.html
set swapfile
set directory^=~/.vim/swap//,.
" Protect against crash-during-write
set writebackup
" but do not persist backup after successful write
set nobackup
" use rename-and-write-new method whenever safe
set backupcopy=auto
" patch required to honor double slash at end
if has("patch-8.1.0251")
" consolidate the writebackups -- not a big
" deal wither way, since they usually get deleted
set backupdir^=~/.vim/backup//,.
end
" persist the undo tree for each file
set undofile
set undodir^=~/.vim/undo//,.
" It's tempting to do something similar with swap files, but they're less
" annoying, and I don't really want to worry about filename collisions.
" Indentation
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" Scroll sideways in small increments
set sidescroll=10
" Scrolling off near the top or bottom is extremely annoying
set scrolloff=0
" Play nicely with system clipboard
set clipboard^=unnamed,unnamedplus
" Line wrapping
set nowrap
set textwidth=0 wrapmargin=0
" Line numbering
set number
set relativenumber
" Line highlighting
set cursorline
"set cursorcolumn
" Spell checking
set spell
" Re-define *all* of the xterm function key sequences that vim forgets about
" when using tmux. Doing this correctly probably requires an inordinately long
" list, and it seems like you can avoid all this if you just pretend to be
" xterm (see below). The real solution is probably to create a proper terminfo
" for tmux.
" See also: terminalkeys, fixkey plugins
"if &term =~ '^tmux'
" " Need to enable xterm-keys in tmux
" execute "set <xUp>=\e[1;*A"
" execute "set <xDown>=\e[1;*B"
" execute "set <xRight>=\e[1;*C"
" execute "set <xLeft>=\e[1;*D"
"endif
" Pretend to be xterm when using tmux or alacritty
if &term =~ '^tmux\|^screen\|^alacritty'
set title
set ttymouse=sgr
if &term =~ '256color\|^alacritty'
set term=xterm-256color
else
set term=xterm
endif
endif
if &term =~ '256color'
" Use 256 colors
set t_Co=256
" Use true colors
if has("termguicolors")
set termguicolors
endif
" disable Background Color Erase (BCE) so that color schemes
" render properly when inside 256-color tmux and GNU screen.
" see also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut=
endif
" Workaround for https://github.com/vim/vim/issues/3480
set t_Cs=
" Color scheme
set background=dark
try
" Looks great, but needs a true-color terminal, or annoying changes to the
" default palette. One of these days I might try to make an almost-seti
" colorscheme that can work with the default 256-color palette.
"let base16colorspace=256 " Shouldn't need this; not using base16-shell.
"colorscheme base16-seti
let g:gruvbox_number_column = 'bg1'
let g:gruvbox_vert_split = 'bg1'
colorscheme gruvbox
" Original colors are slightly too warm for my taste.
"let g:molokai_original=1
" Rehash is barely noticeable in true-color terminals, but looks better in
" 256 color terminals with a default palette.
"let g:rehash256=1
"colorscheme molokai
catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default
" The default colorscheme resets background to light
set background=dark
endtry
if &term =~ '^xterm\|^tmux\|^alacritty'
let &t_SI = "\<Esc>[6 q" "SI = INSERT mode
let &t_SR = "\<Esc>[4 q" "SR = REPLACE mode
let &t_EI = "\<Esc>[2 q" "EI = NORMAL mode
" 1 or 0 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
endif
" NERDTree Config
map <C-n> :NERDTreeToggle<CR>
" ALE Config
" Enable completion where available.
" " This setting must be set before ALE is loaded.
" "
" " You should not turn this setting on if you wish to use ALE as a completion
" " source for other completion plugins, like Deoplete.
let g:ale_completion_enabled = 1
let g:ale_linters = {'rust': ['analyzer', 'rustc']}
" More stuff from defaults.vim
" Switch syntax highlighting on when the terminal has colors or when using the
" GUI (which always has colors).
if &t_Co > 2 || has("gui_running")
" Revert with ":syntax off".
syntax on
" I like highlighting strings inside C comments.
" Revert with ":unlet c_comment_strings".
let c_comment_strings=1
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
" Revert with ":filetype off".
filetype plugin indent on
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
if has('langmap') && exists('+langremap')
" Prevent that the langmap option applies to characters that result from a
" mapping. If set (default), this may break plugins (but it's backward
" compatible).
set nolangremap
endif
" From vimrc_example.vim
" Highlight search results
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
if has('packages')
packadd! matchit
endif
endif
au! BufNewFile,BufRead *.svelte set ft=html
" Put these lines at the very end of your vimrc file.
" Load all plugins now.
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
silent! helptags ALL