-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
417 lines (341 loc) · 9.47 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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
runtime defaults.vim
" use comma for commands
let mapleader=','
let maplocalleader="\<Space>"
if has( 'win32' )
set encoding=utf-8
endif
if has( 'nvim' )
let s:pyenv = ''
if exists( '$PYENV_ROOT' )
let s:pyenv = $PYENV_ROOT
elseif isdirectory( expand( '$HOME/.pyenv' ) )
let s:pyenv = expand( '$HOME/.pyenv' )
endif
if !empty( s:pyenv )
if isdirectory( s:pyenv . '/versions/nvim2' )
let g:python_host_prog=s:pyenv . 'versions/nvim2/bin/python'
endif
if isdirectory( s:pyenv . '/versions/nvim3' )
let g:python3_host_prog=s:pyenv . '/versions/nvim3/bin/python'
endif
endif
endif
" enable syntax hilighting
syn on
"Vundle plugins
runtime! vundle_plugins
"Local packages
runtime! packages.vim
set nocompatible
set wildmode=longest:full,full
if has( 'patch-8.2.4325' )
set wildoptions+=pum,fuzzy
endif
set wildmenu
" For gf and :find
set path+=**
" This is way too crashy
"silent! set cmdheight=0
" Persistent undo
set undofile
let &undodir = expand( '<sfile>:p:h' ) . '/undodir,.'
set nobackup
let &directory = expand( '<sfile>:p:h' ) . '/swap//,.'
set wildignore=*.pyc
" Don't open folds when jumping around
set foldopen-=block
" Allow editing columns without text in visual block mode
set virtualedit=block
" default to xterm behaviour
behave xterm
let s:modemap = {
\ 'n': 'NORMAL',
\ 'no': 'NORMAL',
\ 'v': 'VISUAL',
\ 'V': 'VISUAL',
\ '': 'VISUAL',
\ 's': 'SELECT',
\ 'S': 'SELECT',
\ 'i': 'INSERT',
\ 'ic': 'INSERT',
\ 'ix': 'INSERT',
\ 'R': 'REPLACE',
\ 'Rc': 'REPLACE',
\ 'Rx': 'REPLACE',
\ 'Rb': 'REPLACE',
\ 'c': 'COMMAND',
\ 'cv': 'COMMAND',
\ 'ce': 'COMMAND',
\ 'r': 'COMMAND',
\ 'rm': 'COMMAND',
\ 'r?': 'COMMAND',
\ '!': 'SHELL',
\ 't': 'SHELL+'
\ }
function! BenGetMode()
let l:m=mode()
if has_key( s:modemap, l:m )
return s:modemap[ l:m ]
endif
return 'ERROR'
endfunction
function! BenGetCustomInfo()
if !empty( &buftype )
return ''
endif
if !exists( '*vimspector#GetSessionName' ) ||
\ !exists( '*vimspector#GetSessionID' )
return ''
endif
return vimspector#GetSessionName()
\ .. ' ('
\ .. vimspector#GetSessionID()
\ .. ')'
endfunction
set statusline=
" Set User1 highlight
set statusline+=%1*
" Show mode
set statusline+=\ %{BenGetMode()}\
" Set User2 highlight
set statusline+=%2*
" truncate from here, print filename
set statusline+=\ %<%f
" Group(...) is removed if empty. Flags have commas removed
" (Modified, ReadOnly, Help flags)
set statusline+=%(\ [%M%R%H]%)
" Switch to right-aligned section
set statusline+=%=
" Custom info
set statusline+=%*
set statusline+=%(\ %.20{BenGetCustomInfo()}\ %)
" Set User3 highlight
set statusline+=%3*
" Filetype
set statusline+=\ %y
" Line:col/total lines
set statusline+=\ %l:%c/%L
set statusline+=\
let s:done_property_types = 0
function! BenGetCustomHighlighting()
" This is sufficient to make StatusLine _set_ and _different from
" StatusLineNC_, so that our statusline settings are applied sensibly to
" non-current windows
if !has( 'gui_running' ) && !&termguicolors
hi clear StatusLine
hi StatusLine gui=bold cterm=bold term=bold
endif
hi! link User1 PmenuSel
hi! link User2 CursorLineNr
hi! link User3 ModeMsg
" Make comments a bit more readable in Apprentice
if s:cs =~? '^apprentice'
hi Comment ctermfg=101 guifg=#87875f
" Disable undercurl (which doesn't render well in terminal)
" hi SpellBad cterm=NONE
" hi SpellCap cterm=NONE
endif
" let HIGHLIGHT_GROUP = {
" \ 'typeParameter': 'PreProc',
" \ 'parameter': 'Normal',
" \ 'variable': 'Normal',
" \ 'property': 'Normal',
" \ 'enumMember': 'Normal',
" \ 'event': 'Special',
" \ 'member': 'Normal',
" \ 'method': 'Function',
" \ 'class': 'Special',
" \ 'namespace': 'Special',
" \ }
" if !s:done_property_types
" for tokenType in keys( HIGHLIGHT_GROUP )
" call prop_type_add( 'YCM_HL_' . tokenType,
" \ { 'highlight': HIGHLIGHT_GROUP[ tokenType ] } )
" endfor
" let s:done_property_types = 1
" endif
"
"hi link YcmInlayHint Comment
hi link MessageWindow CursorLineNr
endfunction
augroup BenCustomHighlighting
autocmd!
autocmd ColorScheme * call BenGetCustomHighlighting()
augroup END
" let s:cs = 'apprentice'
" let s:cs = 'bronzage'
"
let s:cs_light = 'freyeday'
let s:cs_dark = 'saturnite'
" On macOS switch to light colorscheme when system theme is light
let s:cs = s:cs_dark
if executable( 'defaults' ) &&
\ system( 'defaults read -g AppleInterfaceStyle' ) !~# '^Dark'
let s:cs = s:cs_light
endif
if has('gui_running')
let s:cs = 'freyeday'
endif
if has( 'win32' )
set t_Co=256
let s:cs = 'apprentice_low'
endif
if exists( '$TMUX' ) || $TERM ==# 'screen-256color'
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Tmux doesn't support modifiyOtherKeys mode 2, so we have to use esc+<letter>
set timeoutlen=500 ttimeoutlen=0
for i in range( char2nr( 'a' ), char2nr( 'z' ) )
let ch = nr2char( i )
execute 'set <M-' . ch . '>=' . ch
execute 'set <M-' . toupper( ch ) . '>=\e' . toupper( ch )
endfor
endif
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
if s:cs ==# 'solarized'
silent! colorscheme solarized
elseif s:cs ==# 'apprentice_low'
silent! colorscheme apprentice
else
if $TERM_PROGRAM !=# 'Apple_Terminal'
set termguicolors
endif
exe 'silent! colorscheme' s:cs
endif
set cursorline
set noshowmode
" set the font
set guifont=Lucida_Console:h9:cDEFAULT
" visual selection copied to clipboard
set guioptions=at
" set the height and width (might be broken columns for diff)
" set lines=50 columns=80
" Set up indenting, and searching
set shiftwidth=2 expandtab incsearch showmatch smartcase autoindent
" use clever case searches when ignorecase is turned on
set smartcase
" use more stuff for the completions
set complete=.,w,b,u,i
" allow c++ like define macros
set define=^\\(#\\s*define\\|[a-z]*\\s*const\\s*[a-z]*\\)
" don't resize windows when splitting
set noequalalways
" have a status line for all windows
set laststatus=2
" don't count in octal for things like BEN001
set nrformats=hex
" always show where the cursor is
set ruler
" show partial commands
set showcmd
" make sure that there are always 5 lines of context when scrolling
set scrolloff=5
" Some shortcuts for commenting things
map ,! :s/^/!/<CR>
map !, :s/^\([ ]*\)!/\1/<CR>
map ,db ma%:'a,.d<CR>
map ,c :s/^/\/\//<CR>
map ,,c :s/^\([ ]*\)\/\//\1/<CR>
" Some windowsisms are hard to let go of
map <S-Insert> "+gP
imap <S-Insert> <C-R>+
cmap <S-Insert> <C-R>+
" Lazy typing in caps can be a pain
imap <S-Del> <BS>
" enable automatic comment stuff
set textwidth=80
" enable carriage return auto-commenting
set formatoptions+=r
" Highlight (textwidth? + 1)th colum
set colorcolumn=+1
" enable modelines
set modeline
set modelines=5
" don't have spelling turned on, it's too annoying
" set spell
" Better mouse support
set mouse+=a
if !has( 'nvim' )
set ttymouse=sgr
set clipboard+=autoselect
endif
set title
" These guys use mad non-breaking code
set linebreak
set breakindent
set showbreak=>\
set breakindentopt=shift:2,min:64
" don't indent namespaces
set cinoptions+=N-s
" align continuations within open parens with the start of the parens
set cinoptions+=(0
" but when the last char of the prev line is the open parens, just indent 1 sw
set cinoptions+=Ws
" line up close brackets on their own line like blocks
set cinoptions+=m1
" enable sane java and javascript indenting
set cinoptions+=j1,J1
" So i can see hard tabs
set listchars=tab:>-
set list
nnoremap <A-S-}> :tabnext<CR>
nnoremap <A-S-{> :tabprevious<CR>
nnoremap <leader>W :botright vertical terminal ++cols=100 ++close
\ env TERM=xterm-256color weechat<CR>
set shortmess+=c
set noshowmode
" OK i'm sick of typing : now
nnoremap ; :
" OK i'm also sick of typing escape just typing in insert mode is
inoremap jk <ESC>
" :help emacs-keys
" start of line
cnoremap <C-A> <Home>
" back one character
cnoremap <C-B> <Left>
" delete character under cursor
cnoremap <C-D> <Del>
" end of line
cnoremap <C-E> <End>
" forward one character
cnoremap <C-F> <Right>
" recall newer command-line
cnoremap <C-N> <Down>
" recall previous (older) command-line
cnoremap <C-P> <Up>
" back one word
cnoremap <M-b> <S-Left>
" forward one word
cnoremap <M-f> <S-Right>
" delete backward one word
cnoremap <M-BS> <C-w>
command! YcmLogErr :botright vertical 75YcmToggleLogs ycmd*stderr*
let g:netrw_liststyle = 3
" let g:netrw_list_hide = netrw_gitignore#Hide()
" Make ctrl-space work in terminal
tnoremap <Nul> <C-Space>
if !has( 'nvim' )
augroup BenTerminal
autocmd!
autocmd TerminalWinOpen * setlocal signcolumn=no textwidth=0 nonumber
augroup END
" Solid bar (StartInsert)
let &t_SI = "\<Esc>[6 q"
" Solid underline (StartReplace)
let &t_SR = "\<Esc>[4 q"
" Solid block (ExitInsert)
let &t_EI = "\<Esc>[2 q"
endif
nmap <localleader>yfw <Plug>(YCMFindSymbolInWorkspace)
nmap <localleader>yfd <Plug>(YCMFindSymbolInDocument)
" Disable modifiyOtherKeys mode 2 when entering terminal, as libvterm doesn't
" understand it
" if &t_TI =~ "\<Esc>\\[>4;[12]m"
" autocmd ModeChanged *:t call echoraw(&t_TE)
" autocmd ModeChanged t:* call echoraw(&t_TI)
" endif
"
let g:html_no_rendering = 1
set secure exrc