-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
300 lines (245 loc) · 7.78 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
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
" jshap's vimrc
" there are many like it, but this one is mine
scriptencoding utf-8
" -----------------------------------------
""" Load vim-plug
if !has('win32')
let autoload_dir=$HOME."/.vim/autoload"
else
let autoload_dir=$HOME."/vimfiles/autoload"
endif
if empty(glob(autoload_dir."/plug.vim"))
if !isdirectory(autoload_dir)
call mkdir(autoload_dir, "p")
endif
execute '!curl -fLo '.autoload_dir.'/plug.vim '
\ .'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
endif
"let color_match = matchstr(&term, '256')
let color_match = matchstr(&term, '\(256\|alacritty\)')
if !empty(color_match)
set t_Co=256
" FIXME: figure out how to detect truecolor support instead of assuming it
" with 256 support :)
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" version with literal escape characters
" let &t_8f = "[38;2;%lu;%lu;%lum"
" let &t_8b = "[48;2;%lu;%lu;%lum"
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
set termguicolors
endif
" NOTE: to get 24-bit color in tmux, you must have the following in your
" tmux.conf, as well as ensuring $TERM is set to either `screen-256color' or
" `tmux-256color' based on your setup's support:
" set -ga terminal-overrides ",xterm-256color:Tc,tmux-256color:Tc"
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
"Plug 'junegunn/seoul256.vim'
"Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
"Plug 'chriskempson/base16-vim'
Plug 'iCyMind/NeoSolarized'
"Plug 'scrooloose/nerdcommenter'
Plug 'ervandew/supertab'
Plug 'airblade/vim-gitgutter'
Plug 'tikhomirov/vim-glsl'
Plug 'tmux-plugins/vim-tmux'
Plug 'pboettch/vim-cmake-syntax'
Plug 'wlangstroth/vim-racket'
Plug 'JuliaEditorSupport/julia-vim'
call plug#end()
" -----------------------------------------
""" looks
set background=dark
" set colo for 256-term
if !empty(color_match)
"let g:seoul256_background=235
"colo seoul256
let g:neosolarized_bold = 1
let g:neosolarized_underline = 1
let g:neosolarized_italic = 1
colo NeoSolarized
endif
" set colo & font for gvim
if has("gui_running")
" fonts
if has('macunix')
set guifont=Menlo\ Regular:h14
elseif has('unix')
" fun fact: on mac, `has('unix')` returns true.
" so we must check for mac first, then for *nix
set guifont=Consolas
elseif has('win32')
set guifont=Consolas:h9:cANSI
endif
" window
set lines=44
set columns=120
" colorz
let g:neosolarized_bold = 1
let g:neosolarized_underline = 1
let g:neosolarized_italic = 1
colo NeoSolarized
" config for smart terminals other than gvim
elseif &term =~ "^xterm\\|rxvt\\|tmux\\|alacritty"
" vertical bar for insert
let &t_SI .= "\<Esc>[5 q"
" underline for replace
let &t_SR .= "\<Esc>[3 q"
" normal blink when leaving
let &t_EI .= "\<Esc>[1 q"
" fix ctrl+arrow keys
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
map <Esc>[B <Down>
" tmux knows the extended mouse mode
"set ttymouse=xterm2
set ttymouse=sgr
endif
" Remove gvim toolbar b/c it's ugly
set guioptions-=T
""" misc settings
" completion keybinding
let g:SuperTabDefaultCompletionType = "<c-n>"
" turn on git gutter by default
let g:gitgutter_enabled = 1
" Turn on line numbering. Turn it off with "set nonu"
set number
" set relativenumber
" set cuc
" hi CursorColumn guibg=#3a3a3a
" set cul
" hi CursorLine guibg=#3a3a3a
" allow inserting past end of line, like `a`
set virtualedit=onemore
" Turn on column coloring at 80 and 120
set colorcolumn=80,120
" Set syntax on
syntax on
" set case insensitive dir browsing
let g:netrw_sort_options = "i"
" Search
"
" Case insensitive search w/ smartcase matching
set ignorecase
set smartcase
"
" Higlhight search
set hlsearch
"
" Move cusor while matching
set incsearch
" 🍌 splits...
set splitbelow " Splits open below instead of above
set splitright " Vsplits open on the right instead of the left
" Wrap text instead of being on one line
set lbr
" Unix line endings are definitively better. fight me.
set fileformat=unix
set fileformats=unix,dos
" Spellcheck, because I'm a horrible speller
" set spell spelllang=en_us
highlight SpellBad cterm=underline ctermbg=darkred
highlight SpellBad gui=undercurl
" set indent rules
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" Render some whitespace
set listchars=tab:>·,trail:·
set list
" enable mouse
set mouse=a
" Optimize for fast terminal connections
set ttyfast
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamedplus
" tab complete into the statusbar
set wildmenu
set wildoptions=pum,fuzzy
set wildignorecase
" diffopt
if has("patch-8.1.0360")
set diffopt+=internal,algorithm:patience
endif
" Status tweaks
"turn on statusline
set laststatus=2
"custom statusline
set statusline=\ [%n]
set statusline+=\ %F\ "filename
"misc info
set statusline+=%h "help file flag
set statusline+=%r "read only flag
set statusline+=%y "filetype
set statusline+=\ %m "modified flag
set statusline+=%= "left/right separator
"encoding info
set statusline+=[%{strlen(&fenc)?&fenc:'none'}] "file encoding
"set statusline+=\ %{&ff} "file format
"cursor location info
set statusline+=\ %3l "cursor line
set statusline+=:%c "cursor column
set statusline+=/%L "total lines
set statusline+=\ %P\ "percent through file
" -----------------------------------------
""" custom commands/fun!
" fun easy way to make aliases for commands!
" (I don't remember where this came from, appologies original creator)
fun! SetupCommandAlias(from, to)
exec 'cnoreabbrev <expr> '.a:from
\ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
\ .'? ("'.a:to.'") : ("'.a:from.'"))'
endfun
" make super easy 'diff buffer against saved' command
command MyDiffOrig vert new | set bt=nofile | r ++edit # | 0d_
\ | diffthis | wincmd p | diffthis
"call SetupCommandAlias("diff","w !diff % -")
call SetupCommandAlias("diff","MyDiffOrig")
" Allow saving of files as sudo when I forgot to start vim using sudo.
call SetupCommandAlias("w!!", "w !sudo tee > /dev/null %")
" Fun to highlight bad words because I have a potty mouth
highlight BadWordsMatch ctermbg=red ctermfg=white
function Fuck()
" actual bad words
" ('fuck' is a special case and has a more advanced search)
let wordlist = "\\w\\{-}fuc\\?k\\(ing\\)\\?\\|shit\\|dick\\|ass\\|bitch"
" other bad garbage that probably just shouldn't make it into code
let wordlist = wordlist . "\\|stuff\\|lol\\|welp\\|oops"
" less intense but maybe still bad
let wordlist = wordlist . "\\|eff\\(ing\\|ed\\)\\?\\|balls"
execute 'match BadWordsMatch /\c\<\(' . wordlist . '\)\>/'
endfunction
call SetupCommandAlias("fuck", "call Fuck()")
"
" enable by default on certain file types
autocmd FileType markdown call Fuck()
autocmd FileType text call Fuck()
" -----------------------------------------
""" misc tweaks
nmap ga <Plug>(EasyAlign)
xmap ga <Plug>(EasyAlign)
augroup vimrc
" Remove all vimrc autocommands so they're not duplicated
au!
au BufNewFile,BufRead *.glsl,*.vs,*.fs set ft=glsl
" autocmd FilterWritePost *.glsl,*.vs,*.fs setf glsl
au BufNewFile,BufRead *.cuh set ft=cuda
au BufNewFile,BufRead make.inc set ft=make
au BufNewFile,BufRead *.rkt set ft=racket
augroup END
""" misc workarounds
" can't turn off the bell sound in mintty or native wsl ;_;
set noerrorbells visualbell t_vb=
" backspace wasn't working for some reason
if has('win32')
set backspace=2
set clipboard=unnamed
endif