-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
executable file
·273 lines (232 loc) · 6.9 KB
/
vimrc
File metadata and controls
executable file
·273 lines (232 loc) · 6.9 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
set encoding=utf-8
scriptencoding utf-8
let s:lite = (&term ==? 'cygwin' || &term ==? 'win32' || exists('g:gui_oni'))
let s:vimdir = expand('<sfile>:p:h')
filetype plugin indent on
syntax enable
" Various preferences
set laststatus=2
set shortmess=oOtT
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
set backspace=indent,eol,start
set autoindent breakindent
set formatoptions+=j
set cursorline
set scrolloff=2 sidescroll=1 sidescrolloff=5
set display=lastline
set foldlevel=99
set wildmenu wildmode=longest,list:full
if !has('nvim')
set completeopt+=popup
endif
set splitbelow splitright
set clipboard^=unnamed
set hidden
set fileencoding=utf-8 fileformats=unix,dos
set nrformats-=octal
set isfname-==
set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:␣,space:·,eol:↲
set noswapfile
set ttyfast
set lazyredraw
set synmaxcol=8000
set history=2000
set title
set showcmd
set hlsearch
set ttimeoutlen=100
set mouse=a
if exists('+shellslash')
set shellslash
endif
if has('patch-8.1.0360')
set diffopt+=vertical,algorithm:patience,indent-heuristic,hiddenoff
endif
" Custom statusline
set statusline=
set statusline+=\ %f\ %<%m%r%y\
set statusline+=%=\ %{&fileencoding}[%{&fileformat}]\ \|
set statusline+=\ %3l/%L:%2v\ \|\ %P\
" Prettify
if !s:lite
if &term =~# '^tmux'
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
set termguicolors
endif
colorscheme mysticaltutor
" Don't save swap files on remote etc and set undodir
let &directory = s:vimdir .. '/temp//'
let &undodir = s:vimdir .. '/undo//'
augroup UndoTypes
autocmd!
autocmd FileType c,cpp,python,sh,fish,perl,dosbatch,vim setlocal swapfile undofile
augroup END
" Easier command mode
nnoremap <CR> :
xnoremap <CR> :
augroup CRExceptions
autocmd!
autocmd BufWinEnter quickfix noremap <buffer> <CR> <CR>
autocmd CmdwinEnter * noremap <buffer> <CR> <CR>
augroup END
" Buffer nav shortcuts
nnoremap <Bslash> :ls<CR>:buffer
nnoremap <BS> <C-^>
nnoremap Q :bwipe<CR>
nnoremap [b :bprev<CR>
nnoremap ]b :bnext<CR>
nnoremap [B :bfirst<CR>
nnoremap ]B :blast<CR>
" Refresh buffer and 'tail'
nnoremap <F5> :e<CR>G
" Show non-ascii characters
command! NonAscii normal! /[^\x00-\x7F]<CR>
" Alternate windows
nnoremap <Space><Space> <C-w>p
" Toggles for some options
nnoremap <Space>h :set invhlsearch <Bar> set hlsearch?<CR>
nnoremap <Space>w :set invwrap <Bar> set wrap?<CR>
nnoremap <Space>l :set invlist <Bar> set list?<CR>
" Quick edit config files
nnoremap <Space>v :edit $MYVIMRC<CR>
nnoremap <Space>gv :edit $MYGVIMRC<CR>
" Quick diff
nnoremap <silent> <Space>dd :call misc#toggle_diff()<CR>
" Saner yank shortcut
nnoremap Y y$
" Continue indenting in visual mode
xnoremap < <gv
xnoremap > >gv
" * and # in visual mode
xnoremap * "jy/<C-r>j<CR>
xnoremap # "jy?<C-r>j<CR>
" vim-unimpaired inspired shortcuts
nnoremap [q :cprev<CR>
nnoremap ]q :cnext<CR>
nnoremap [Q :cfirst<CR>
nnoremap ]Q :clast<CR>
nnoremap [l :lbefore<CR>
nnoremap ]l :lafter<CR>
nnoremap [L :lfirst<CR>
nnoremap ]L :llast<CR>
nnoremap [a :previous<CR>
nnoremap ]a :next<CR>
nnoremap [A :first<CR>
nnoremap ]A :last<CR>
" Place custom signs and display marks
nnoremap <silent> <Space>m :call misc#place_sign(0)<CR>
nnoremap <silent> <Space>M :call misc#remove_signs()<CR>
nnoremap <silent> m :call misc#place_sign(1)<CR>
" Redirect command outputs
command! -nargs=1 -complete=command Redir silent call misc#redir(<f-args>)
" MRU
nnoremap <silent> <F3> :call misc#MRU()<CR>
" Quick sum
command! -range Sum execute "echo " .. join(getline(<line1>, <line2>), " + ")
" Goto last position when opening file
augroup LastPos
autocmd!
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif
augroup END
" Highlight yanked region
augroup HlYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call misc#hl_yank() | endif
augroup END
" Yank with OSC 52
if !has('gui_running') && has('unix')
augroup ClipboardSync
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call misc#osc52_yank(@0) | endif
augroup END
endif
" Tmux mouse support
if exists('$TMUX') && !has('nvim')
set ttymouse=sgr
endif
" Disable netrw
let loaded_netrwPlugin = 1
" plugin for :[CL]filter[!]
packadd! cfilter
" vim-lion shortcut for whole file alignment, e.g. 'gl%<Tab>'
nnoremap <silent> gl% :call misc#align_buffer(nr2char(getchar()))<CR>
" Undotree
let g:undotree_SetFocusWhenToggle = 1
nnoremap <Space>u :packadd undotree <Bar> UndotreeToggle<CR>
" DiffChar settings
let g:DiffUnit = 'Word1'
let g:DiffColors = 0
let g:DiffPairVisible = 3
let g:NoDiffChar = 1
function! DiffToggle()
let g:NoDiffChar = g:NoDiffChar ? 0: 1
windo diffoff | windo diffthis
endfunction
nnoremap <Space>dc :call DiffToggle()<CR>
" Tab and CR behavior when completing
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <C-c> pumvisible() ? "\<C-e>" : "\<C-c>"
" Complete from buffer with tab when searching
if has('patch-8.0.1206') || has('nvim')
augroup SearchCompletion
autocmd!
autocmd CmdlineEnter /,\? cnoremap <Tab> <C-f>a<C-n>
autocmd CmdlineLeave /,\? silent! cunmap <Tab>
augroup END
endif
" Terminal normal mode shortcut
if has('patch-8.0.1108') || has('nvim')
tnoremap <C-q> <C-\><C-n>
endif
" Faster grep
if executable('rg')
set grepprg=rg\ --vimgrep
set grepformat^=%f:%l:%c:%m
endif
" Recolor inactive windows
if !has('nvim')
augroup WindowHl
autocmd!
autocmd WinLeave * set wincolor=Cursorline
autocmd WinEnter * set wincolor&
augroup END
else
hi! link NormalNC Cursorline
endif
if !s:lite
" mintty settings for variable cursor type
if !has('nvim')
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
let &t_Cs="\<Esc>[4:3m"
let &t_Ce="\<Esc>[4:0m"
endif
" " Smooth scroll
" nnoremap <silent> <C-u> :call smooth_scroll#scroll('u', &scroll, 5, 1)<CR>
" nnoremap <silent> <C-d> :call smooth_scroll#scroll('d', &scroll, 5, 1)<CR>
" nnoremap <silent> <C-b> :call smooth_scroll#scroll('u', &scroll*2, 2.5, 1)<CR>
" nnoremap <silent> <C-f> :call smooth_scroll#scroll('d', &scroll*2, 2.5, 1)<CR>
" do not auto-enable vim-lsp
let g:lsp_auto_enable = 0
let g:lsp_diagnostics_float_cursor = 1
augroup lsp_install
autocmd!
autocmd User lsp_buffer_enabled call lspconfig#config()
augroup END
endif
" Smart predict
let s:predict_folder = '/mnt/d/Hack/hack-2018'
if isdirectory(s:predict_folder)
let g:predict_server_command =
\ s:predict_folder .. '/../venv/bin/python '
\ .. s:predict_folder .. '/predict-server.py -d '
\ .. s:predict_folder .. '/../data -n 10'
packadd! predict
endif