-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
408 lines (343 loc) · 11.8 KB
/
init.vim
File metadata and controls
408 lines (343 loc) · 11.8 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
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
" Python path
let g:python3_host_prog = $HOME . '/.local/share/nvim/venv/bin/python3'
set pyxversion=3
set termguicolors
filetype plugin indent on
syntax on
set undofile
" Don't use Ex mode, use Q for formatting
map Q gq
" Bugfix for altgr key modifiers
inoremap <M-×> ×
inoremap <M-á> á
inoremap <M-é> é
" Disable alt-tab (reserved for system window manager)
noremap <m-tab> <F13>
inoremap <m-tab> <c-o><esc>
lnoremap <m-tab> <F13>
xnoremap <m-tab> <F13>
cnoremap <m-tab> <space><bs>
tnoremap <m-tab> <c-\><c-n>i
let &guifont='Hack Nerd Font:h12'
let g:neovide_cursor_vfx_mode = "ripple"
set mouse=n " Disable mouse support
set expandtab " Expand TABs to spaces
set tabstop=2 " The width of a TAB is set to 2.
set shiftwidth=2 " Indents will have a width of 2
set softtabstop=2 " Sets the number of columns for a TAB
set number " Show line numbers
set relativenumber " Show line numbers
set lazyredraw " Don't redraw the screen during commands/macros
set scrolloff=5 " Scrolloff
set formatoptions-=t " Disable hard line wrapping
set hidden " Buffers don't need to attach to a window
set gdefault " Global substitution by default
set inccommand=split " Live substitution
set foldlevel=99 " Unfold by default
set cmdheight=2 " 2 line command line
set updatetime=100
set timeout timeoutlen=500
" Unmap CTRL-] and backspace
noremap <bs> <nop>
noremap <c-]> <nop>
" Leader key
let mapleader=" "
let maplocalleader=","
noremap <leader> <nop>
noremap <localleader> <nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:config_dir = expand('<sfile>:p:h')
function! SourceRange() range
let tmpsofile = tempname()
call writefile(getline(a:firstline, a:lastline), l:tmpsofile)
execute "source " . l:tmpsofile
call delete(l:tmpsofile)
endfunction
command! -range Source <line1>,<line2>call SourceRange()
function! s:Source(fname)
execute 'source ' . g:config_dir . '/' . a:fname
endfunction
call s:Source('config/pre-config.vim')
" Vim Plug
set rtp+=$LOCAL_HOME/.local/share/nvim
call plug#begin('~/.local/share/nvim/plugged')
" Themes
Plug 'vim-airline/vim-airline-themes'
Plug 'gruvbox-community/gruvbox'
Plug 'cormacrelf/vim-colors-github'
Plug 'NLKNguyen/papercolor-theme'
Plug 'mkarmona/materialbox'
Plug 'joshdick/onedark.vim'
Plug 'lifepillar/vim-gruvbox8'
Plug 'lifepillar/vim-solarized8'
" Plugins
Plug 'neoclide/coc.nvim', { 'branch' : 'master', 'do': 'yarn install --frozen-lockfile' }
Plug 'w0rp/ale'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'Yggdroot/indentLine'
Plug 'tpope/vim-commentary'
Plug 'ervandew/supertab'
Plug 'tpope/vim-repeat'
Plug 'vim-airline/vim-airline'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-surround'
Plug 'lervag/vimtex'
Plug 'simeji/winresizer'
Plug 'junegunn/fzf', { 'dir': '~/.local/share/fzf', 'do': './install --all --no-update-rc' }
Plug 'junegunn/fzf.vim'
Plug 'mhinz/vim-signify'
Plug 'tpope/vim-fugitive'
Plug 'easymotion/vim-easymotion'
Plug 'tmsvg/pear-tree'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-vinegar'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'pboettch/vim-cmake-syntax'
Plug 'vim-python/python-syntax'
Plug 'jeetsukumaran/vim-pythonsense'
Plug 'liuchengxu/vim-which-key'
Plug 'unblevable/quick-scope'
Plug 'aelkazdadi/rainbow', { 'branch' : 'inline-endif-bugfix' }
Plug 'terryma/vim-expand-region'
Plug 'vim-scripts/matchit.zip'
Plug 'pbrisbin/vim-mkdir'
Plug 'dbakker/vim-projectroot'
Plug 'blueyed/vim-diminactive'
Plug 'kshenoy/vim-signature'
Plug 'mbbill/undotree'
Plug 'wellle/targets.vim'
Plug 'liuchengxu/vista.vim'
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
call plug#end()
" All possible highlighters
let g:Hexokinase_highlighters = [
\ 'virtual',
\ 'foreground',
\ ]
" Indent guides
let g:indentLine_char = '¦'
let g:indentLine_indentLevel = 100
let g:indent_blankline_char = '¦'
let g:indent_blankline_filetype_exclude = ['tex']
let g:indentLine_fileTypeExclude = ['tex']
"Gruvbox
let g:gruvbox_italic = 1
let g:gruvbox_contrast_light = "soft"
let g:gruvbox_contrast_dark = "medium"
let g:gruvbox_improved_strings = 1
let g:gruvbox_improved_warnings = 1
let g:rainbow_active = 1
augroup Rainbow
autocmd!
autocmd FileType cmake RainbowToggleOff
augroup end
let g:better_whitespace_operator = ''
let g:better_whitespace_filetypes_blacklist =
\['diff', 'gitcommit', 'unite', 'qf', 'help', 'markdown', 'fugitive', '']
" Window resizer
let g:winresizer_start_key='<c-space>.'
" Airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#hunks#enabled=0
let g:airline#extensions#branch#enabled=0
" Python syntax
let g:python_highlight_all = 1
" Tab completion direction
let g:SuperTabDefaultCompletionType = '<c-n>'
augroup SuperTabConfig
autocmd VimEnter * imap <silent> <tab> <plug>SuperTabForward
autocmd VimEnter * imap <silent> <s-tab> <plug>SuperTabBackward
augroup end
" Highlight yanked text
augroup highlight_yank
autocmd! TextYankPost * silent! lua require'vim.highlight'.on_yank("IncSearch", 300)
augroup end
" Quick Scope
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" Targets
let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr lb ar ab lB Ar aB Ab AB rr ll rb al rB Al bb aa bB Aa BB AA'
" Ale
let g:airline#extensions#ale#enabled = 1
let g:ale_virtualtext_cursor=1
let g:ale_sign_column_always = 1
let g:ale_linters_explicit = 1
nmap <silent> ]q <plug>(coc-diagnostic-next)
nmap <silent> [q <plug>(coc-diagnostic-prev)
" Vim visual star search
function! SearchSelection()
let temp = @"
normal! gvy
let @/ = substitute(@", '\\', '\\\\', 'g')
let @/ = substitute(@/, '\/', '\\\/', 'g')
let @/ = substitute(@/, '\n', '\\n', 'g')
let @/ = '\C\V' . @/
let @" = temp
endfunction
nnoremap <silent> * :let @/ = '\<'.expand('<cword>').'\>' <bar> let v:searchforward=1 <bar> set hlsearch<cr>
nnoremap <silent> # :let @/ = '\<'.expand('<cword>').'\>' <bar> let v:searchforward=0 <bar> set hlsearch<cr>
xnoremap <silent> * <esc>:call SearchSelection() <bar> let v:searchforward=1 <bar> set hlsearch<cr>
xnoremap <silent> # <esc>:call SearchSelection() <bar> let v:searchforward=0 <bar> set hlsearch<cr>
call s:Source('config/which_key.vim')
call s:Source('config/snippets.vim')
call s:Source('config/vimtex.vim')
call s:Source('config/fzf.vim')
call s:Source('config/git.vim')
call s:Source('config/easymotion.vim')
call s:Source('config/peartree.vim')
call s:Source('config/local.vim')
call s:Source('config/buffers.vim')
call s:Source('config/tabs.vim')
call s:Source('config/terminal.vim')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Other User Config "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:light_theme = "onedark"
let g:dark_theme ="onedark"
set background=dark
execute "colorscheme " . g:dark_theme
function ChangeTheme()
if &background == "light"
set background=dark
execute "colorscheme " . g:dark_theme
else
set background=light
execute "colorscheme " . g:light_theme
endif
endfunction
map <expr> <F2> ChangeTheme()
" Disable search highlighting
nnoremap <silent> <m-.> :nohlsearch <bar> echo<cr>
vnoremap <silent> <m-.> :<c-u>nohlsearch <bar> echo<cr>gv
inoremap <silent> <m-.> <c-o>:nohlsearch <bar> echo<cr>
tnoremap <silent> <m-.> <c-\><c-n>:nohlsearch <bar> echo<cr>i
tnoremap <silent> <c-space><m-.> <m-.>
nnoremap <leader><tab> <c-^>
let g:n_which_key_map['<Tab>'] = 'alternate-buffer'
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
cnoremap <c-p> <up>
cnoremap <c-n> <down>
cnoremap <c-h> <left>
cnoremap <c-j> <down>
cnoremap <c-k> <up>
cnoremap <c-l> <right>
cnoremap <m-h> <left><left>
cnoremap <m-l> <right><right>
cnoremap <c-a> <c-b>
cnoremap <c-e> <c-e>
cnoremap (( \(\)<left><left>
cnoremap !! \@!
cnoremap ** \{-}
cnoremap <bar><bar><bar> \(\<bar>\)<left><left><left><left>
noremap : ,
noremap \ :
" Window movement
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" Vertical split on the right, horizontal on the bottom
set splitright
set splitbelow
" Copy/Paste
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap Y y$
vnoremap P pgvy`>
nnoremap <m-p> "+p
vnoremap <m-p> "+p
nnoremap <m-P> "+P
nnoremap ]p o<esc>0Dp
nnoremap [p O<esc>0Dp
nnoremap ]P o<esc>0D"+p
nnoremap [P O<esc>0D"+p
let g:n_which_key_map.y = 'copy-clipboard'
let g:v_which_key_map.y = 'copy-clipboard'
" Moving in insert mode
inoremap <c-h> <left>
inoremap <c-l> <right>
" Switch HL / ^$
noremap H ^
noremap L $
noremap ^ H
noremap $ L
" Move selection
vnoremap <silent> J :<c-u>execute "'<,'>m '>+" . v:count1 <cr> gv=gv
vnoremap <silent> K :<c-u>execute "'<,'>m '<-" . (1+v:count1) <cr> gv=gv
" Highlight matches in search->cedit
augroup CmdWinHighlight
autocmd!
autocmd CmdwinEnter /,? let @/ = getline('.') |
\ autocmd TextChanged,TextChangedI,TextChangedP
\ <buffer> let @/ = getline('.')
augroup end
" Help in vertical split
cnoreabbrev h tab help
cnoreabbrev hh help
" vim-which-key bug workaround
let g:n_which_key_map_ctrl['<C-Space>']['<C-Space>'] = "terminal"
let g:n_which_key_map_ctrl['<C-Space>']['.'] = 'window-resizer'
let g:n_which_key_map_ctrl['<C-Space>'].d = 'close-window'
let g:n_which_key_map_ctrl['<C-Space>'].D = 'close-tab'
let g:n_which_key_map_ctrl['<C-Space>'].q = 'close-buffer'
let g:n_which_key_map_ctrl['<C-Space>'].Q = 'close-buffer'
let g:n_which_key_map_ctrl['<C-Space>']['='] = 'balance-splits'
let g:n_which_key_map_ctrl['<C-Space>'].s = 'term-split-horizontal'
let g:n_which_key_map_ctrl['<C-Space>'].v = 'term-split-vertical'
let g:n_which_key_map_ctrl['<C-Space>'].t = 'term-new-tab'
let g:n_which_key_map_ctrl['<C-Space>'].o = 'maximize-window'
nnoremap <silent> <c-space>d :close<cr>
nnoremap <silent> <c-space>D :tabclose<cr>
nnoremap <silent> <c-space>q :bdelete<cr>
nnoremap <silent> <c-space>Q :bdelete!<cr>
nnoremap <silent> <c-space>= <c-w>=
nnoremap <silent> <c-space><c-space> :terminal<cr>
nnoremap <silent> <m-cr> :terminal<cr>
nnoremap <silent> <c-space>v :vsplit <bar> terminal<cr>
nnoremap <silent> <c-space>s :split <bar> terminal<cr>
nnoremap <silent> <c-space>t :tabnew <bar> terminal<cr>
tnoremap <silent> <c-space>v <c-\><c-n>:vsplit <bar> terminal<cr>
tnoremap <silent> <c-space>s <c-\><c-n>:split <bar> terminal<cr>
tnoremap <silent> <c-space>t <c-\><c-n>:tabnew <bar> terminal<cr>
tnoremap <c-\> <c-\><c-\>
tnoremap <c-space><c-space> <c-space>
tnoremap <c-space>l <c-l>
tnoremap <c-h> <c-\><c-n><c-w>h
tnoremap <c-j> <c-\><c-n><c-w>j
tnoremap <c-k> <c-\><c-n><c-w>k
tnoremap <c-l> <c-\><c-n><c-w>l
tnoremap <m-q> <c-\><c-n>
tnoremap <m-p> <c-\><c-n>"+pa
tnoremap <m-P> <c-\><c-n>pa
tnoremap <c-space><c-h> <c-h>
tnoremap <c-space><c-j> <c-j>
tnoremap <c-space><c-k> <c-k>
tnoremap <c-space><c-l> <c-l>
tnoremap <c-space><m-q> <m-q>
tnoremap <c-space><m-p> <m-p>
tnoremap <c-space><m-P> <m-P>
" Fix <C-BS> for GUI vim
tnoremap <c-bs> <bs>
tnoremap <s-bs> <bs>
tnoremap <c-s-bs> <bs>
" Vim
let g:n_which_key_map.q = {}
let g:n_which_key_map.q.name = '+vim'
nnoremap <silent> <leader>qq
\ :echon 'Quit? (press y to confirm): ' <bar>
\ if tolower(nr2char(getchar())) == 'y' <bar>
\ execute 'bufdo bd' <bar> qa <bar>
\ else <bar> echo ''
\ <bar> endif<cr>
nnoremap <silent> <leader>qe :execute 'lcd ' . g:config_dir . '<bar> edit init.vim'<cr>
nnoremap <silent> <leader>qf :execute 'Files ' . g:config_dir<cr>
let g:n_which_key_map.q.q = 'quit'
let g:n_which_key_map.q.e = 'init-file'
let g:n_which_key_map.q.f = 'config-files'
" c++ template implementation file
augroup Tpp_extenstion
autocmd!
autocmd BufRead,BufNewFile *.tpp setlocal filetype=cpp
augroup end