-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathinit.vim
More file actions
executable file
·455 lines (392 loc) · 12.5 KB
/
init.vim
File metadata and controls
executable file
·455 lines (392 loc) · 12.5 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'editorconfig/editorconfig-vim'
Plug 'huytd/vim-quickrun'
Plug 'sheerun/vim-polyglot'
Plug 'othree/html5.vim'
Plug 'cakebaker/scss-syntax.vim'
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
Plug 'itchyny/lightline.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'easymotion/vim-easymotion'
Plug 'unkiwii/vim-nerdtree-sync'
Plug 'vim-scripts/matchit.zip'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'haya14busa/incsearch.vim'
Plug 'tpope/vim-abolish' " For case perserved subtitue :%S
Plug 'scrooloose/nerdcommenter'
Plug 'terryma/vim-multiple-cursors'
Plug 'eugen0329/vim-esearch'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --no-bash' }
Plug 'junegunn/fzf.vim'
Plug 't9md/vim-choosewin'
Plug 'RRethy/vim-hexokinase', { 'do': 'make hexokinase' }
Plug 'kaicataldo/material.vim'
Plug 'Yggdroot/indentLine'
Plug 'atelierbram/Base2Tone-vim'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
Plug 'tyrannicaltoucan/vim-quantum'
call plug#end()
filetype plugin indent on
"Todo file
autocmd BufNewFile,BufRead *.todo set syntax=todo
" Auto remove trailing spaces
autocmd BufWritePre * %s/\s\+$//e
set encoding=UTF-8
set hidden
set nobackup
set nowritebackup
set mouse=a " enable mouse for all mode
set cursorline
set foldmethod=indent
set foldlevel=99
let g:is_posix = 1
set noswapfile
set nojoinspaces
set nowrap
set number
set ttyfast
set laststatus=2
set ttimeout
set ttimeoutlen=10
set termguicolors
set ignorecase
set relativenumber
" Vim color highlighting
let g:Hexokinase_highlighters = ['virtual']
let g:Hexokinase_virtualText = '▩'
" FZF config
let g:fzf_layout = { 'window': {
\ 'width': 0.9,
\ 'height': 0.7,
\ 'highlight': 'Comment',
\ 'rounded': v:false } }
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden'
" Indent Guide
let g:indentLine_char = '│'
let g:indentLine_color_gui = '#363442'
" Esearch config
let g:esearch = {
\ 'adapter': 'rg',
\ 'backend': 'nvim'
\}
call esearch#out#win#map('<Enter>', 'tab')
" JS config
let g:javascript_plugin_jsdoc = 1
let g:polyglot_disabled = ['jsx', 'tsx', 'js', 'ts']
let g:vim_jsx_pretty_template_tags = ['html', 'jsx', 'tsx']
" Custom icon for coc.nvim statusline
let g:coc_status_error_sign=" "
let g:coc_status_warning_sign=" "
" I don't use recording, don't judge me
map q <Nop>
inoremap jk <ESC>
vnoremap <M-/> <Esc>/\%V
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
nnoremap <ESC><ESC> :nohlsearch<CR>
nnoremap L l
nnoremap H h
nnoremap l w
nnoremap h b
vnoremap p "_dP
" Map Emacs like movement in Insert mode
" inoremap <C-n> <Down>
" inoremap <C-p> <Up>
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-e> <C-o>$
inoremap <C-a> <C-o>^
" Remap scrolling
nnoremap <C-k> <C-u>
nnoremap <C-j> <C-d>
set background=dark
" let g:quantum_black=1
colo bright-quantum
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
endif
set listchars=tab:>·,trail:~,extends:>,precedes:<
set list
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set tabstop=2
set softtabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
set smartindent
" Persistent undo
" Don't forget mkdir folder $HOME/.vim/undo
set undofile
set undodir=$HOME/.config/nvim/undo
set undolevels=1000
set undoreload=10000
set updatetime=300
let g:NERDSpaceDelims = 1
map mm <Plug>NERDCommenterToggle
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
set wildoptions=pum
set pumblend=1
" Floating Term
let s:float_term_border_win = 0
let s:float_term_win = 0
function! FloatTerm(...)
" Configuration
let height = float2nr((&lines - 2) * 0.6)
let row = float2nr((&lines - height) / 2)
let width = float2nr(&columns * 0.6)
let col = float2nr((&columns - width) / 2)
" Border Window
let border_opts = {
\ 'relative': 'editor',
\ 'row': row - 1,
\ 'col': col - 2,
\ 'width': width + 4,
\ 'height': height + 2,
\ 'style': 'minimal'
\ }
" Terminal Window
let opts = {
\ 'relative': 'editor',
\ 'row': row,
\ 'col': col,
\ 'width': width,
\ 'height': height,
\ 'style': 'minimal'
\ }
let top = "╭" . repeat("─", width + 2) . "╮"
let mid = "│" . repeat(" ", width + 2) . "│"
let bot = "╰" . repeat("─", width + 2) . "╯"
let lines = [top] + repeat([mid], height) + [bot]
let bbuf = nvim_create_buf(v:false, v:true)
call nvim_buf_set_lines(bbuf, 0, -1, v:true, lines)
let s:float_term_border_win = nvim_open_win(bbuf, v:true, border_opts)
let buf = nvim_create_buf(v:false, v:true)
let s:float_term_win = nvim_open_win(buf, v:true, opts)
" Styling
hi FloatWinBorder guifg=#87bb7c
call setwinvar(s:float_term_border_win, '&winhl', 'Normal:FloatWinBorder')
call setwinvar(s:float_term_win, '&winhl', 'Normal:Normal')
if a:0 == 0
terminal
else
call termopen(a:1)
endif
startinsert
" Close border window when terminal window close
autocmd TermClose * ++once :bd! | call nvim_win_close(s:float_term_border_win, v:true)
endfunction
" Key binding
let mapleader=" "
nnoremap <Leader>l :vsplit<CR>
nnoremap <Leader>k :split<CR>
nnoremap <Leader>wh :wincmd h<CR>
nnoremap <Leader>wl :wincmd l<CR>
nnoremap <Leader>wk :wincmd k<CR>
nnoremap <Leader>wj :wincmd j<CR>
nnoremap <Leader>w= :wincmd =<CR>
nnoremap <Leader>e :QuickRunExecute<CR>
nnoremap <Leader>wb :e#<CR>
nnoremap <Leader>qq :bd<CR>
nnoremap <Leader>qk :call DeleteCurrentFileAndBuffer()<CR>
nnoremap <Leader>ss :mksession! .vimsession<CR>
nnoremap <Leader>sr :so .vimsession<CR>
nnoremap <Leader><Leader>r :so ~/.config/nvim/init.vim<CR>
nnoremap <Leader>n :NERDTree<CR>
nnoremap <Leader>f :NERDTreeFind<CR>
"Buffer
nnoremap <Leader>tn :tabn<CR>
nnoremap <Leader>tp :tabp<CR>
nnoremap <Leader>tc :tabe<CR>
nnoremap <Leader>tx :tabclose<CR>
" Jump window
nmap <Leader>ww <Plug>(choosewin)
" Open terminal
nnoremap <Leader>at :call FloatTerm()<CR>
" Open tig, yes TIG, A FLOATING TIGGGG!!!!!!
nnoremap <Leader>ag :call FloatTerm('"tig"')<CR>
nnoremap <silent> <Leader>pf :Files<CR>
nnoremap <silent> <Leader>pt :Buffers<CR>
nnoremap <silent> <Leader>pb :Buffers<CR>
nnoremap <silent> <Leader>pr :History<CR>
nnoremap <silent> <c-\> :call esearch#init()<CR>
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
nnoremap <silent> \ :Rg<CR>
nnoremap <silent> <c-o> :CocList outline<CR>
" Choose win
let g:choosewin_overlay_enable = 1
" NERDTree config
let NERDTreeMinimalUI=1
let g:NERDTreeStatusline = '%#NonText#'
" Turn off whitespaces compare and folding in vimdiff
set splitright
silent! set splitvertical
set diffopt+=iwhite
set diffopt+=vertical
nnoremap <Leader>1 :diffget 1<CR>:diffupdate<CR>
nnoremap <Leader>2 :diffget 2<CR>:diffupdate<CR>
set clipboard=unnamed
function! DeleteCurrentFileAndBuffer()
call delete(expand('%'))
bdelete!
endfunction
function! DrawGitBranchInfo()
let branch = fugitive#head()
return len(branch) > 0 ? " " . branch : ""
endfunction
function! MyFiletype()
" return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : '') : ''
return ''
endfunction
function! LightLineFilename()
let name = ""
let subs = split(expand('%'), "/")
let i = 1
for s in subs
let parent = name
if i == len(subs)
let name = len(parent) > 0 ? parent . '/' . s : s
elseif i == 1
let name = s
else
let part = strpart(s, 0, 10)
let name = len(parent) > 0 ? parent . '/' . part : part
endif
let i += 1
endfor
return name
endfunction
let g:lightline = {
\ 'colorscheme': 'onehalfdark',
\ 'active': {
\ 'left': [ [], [ 'filename' ] ],
\ 'right': [ [], ['cocstatus', 'lineinfo', 'icongitbranch'] ]
\ },
\ 'inactive': {
\ 'left': [ ['fileicon'], [ 'filename' ] ],
\ 'right': []
\ },
\ 'component': { 'lineinfo': ' %2p%% %3l:%-2v' },
\ 'component_function': {
\ 'fileicon': 'MyFiletype',
\ 'icongitbranch': 'DrawGitBranchInfo',
\ 'iconline': 'DrawLineInfo',
\ 'gitbranch': 'fugitive#head',
\ 'cocstatus': 'coc#status',
\ 'filename': 'LightLineFilename',
\ },
\ }
" Use auocmd to force lightline update.
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
set shortmess+=c
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Remap for format selected region
xmap <leader><leader>f <Plug>(coc-format-selected)
nmap <leader><leader>f <Plug>(coc-format-selected)
" Create mappings for function text object, requires document symbols feature of languageserver.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>ar <Plug>(coc-rename)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
function! StatusDiagnostic() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'error', 0)
call add(msgs, 'E' . info['error'])
endif
if get(info, 'warning', 0)
call add(msgs, 'W' . info['warning'])
endif
return join(msgs, ' ') . ' ' . get(g:, 'coc_status', '')
endfunction
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc#status()}%{StatusDiagnostic()}
" Nerdtree Sync
let g:nerdtree_sync_cursorline = 1
let g:NERDTreeHighlightCursorline = 1
" Multiple Cursor
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_start_word_key = '<C-d>'
let g:multi_cursor_select_all_word_key = '<C-L>'
let g:multi_cursor_start_key = 'g<C-d>'
let g:multi_cursor_select_all_key = 'g<C-L>'
let g:multi_cursor_next_key = '<C-d>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-i>'
let g:multi_cursor_quit_key = '<Esc>'
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Some custom style
highlight Normal guibg=NONE
highlight SignColumn guibg=NONE
highlight EasyMotionTargetDefault guifg=#ffb400
highlight WildMenu guifg=#87bb7c
highlight VertSplit guifg=#1f2329 guibg=NONE
highlight CocInfoSign guifg=#55606d
highlight LineNr guifg=#454A54
highlight DiffAdd guibg=NONE
highlight DiffAdded guibg=NONE
highlight DiffChange guibg=NONE
highlight DiffDelete guibg=NONE
highlight EndOfBuffer guifg=#282c34