-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.neovimrc
528 lines (407 loc) · 14.3 KB
/
.neovimrc
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
let $NVIM_COC_LOG_LEVEL = 'debug'
set nocompatible
set smartindent
filetype off
set inccommand=split
" start plugins
call plug#begin('~/.vim/plugged')
" make backspace work like other apps
set backspace=2
" Set up tags
set tags=tags
" Visualize code indentations
Plug 'nathanaelkane/vim-indent-guides'
" let g:indent_guides_auto_colors = 0
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=white
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=gray
autocmd FileType python setlocal sw=2 sts=2 expandtab
" autocmd VimEnter * UpdateRemotePlugins
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
" Quote / bracket / paren autocomplete
Plug 'Raimondi/delimitMate'
let delimitMate_expand_cr=1
" Better motions"
Plug 'easymotion/vim-easymotion'
Plug 'justinmk/vim-sneak'
let g:sneak#label = 1
" case insensitive sneak
let g:sneak#use_ic_scs = 1
" immediately move to the next instance of search, if you move the cursor sneak is back to default behavior
let g:sneak#s_next = 1
" remap so I can use , and ; with f and t
map gS <Plug>Sneak_,
" Change the colors
highlight Sneak guifg=black guibg=#00C7DF ctermfg=black ctermbg=cyan
highlight SneakScope guifg=red guibg=yellow ctermfg=red ctermbg=yellow
" Cool prompts
let g:sneak#prompt = '🕵'
let g:sneak#prompt = '🔎'
Plug 'unblevable/quick-scope'
" Trigger a highlight in the appropriate direction when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
augroup qs_colors
autocmd!
autocmd ColorScheme * highlight QuickScopePrimary guifg='#5fffff' gui=underline ctermfg=155 cterm=underline
autocmd ColorScheme * highlight QuickScopeSecondary guifg='#afff5f' gui=underline ctermfg=81 cterm=underline
augroup END
let g:qs_max_chars=150
" Override search
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion.
" Without these mappings, `n` & `N` works fine. (These mappings just provide
" different highlight method and have some other features )
" map n <Plug>(easymotion-next)
" map N <Plug>(easymotion-prev)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
autocmd FileType vim if bufname('%') == '[Command Line]' | let b:coc_suggest_disable = 1 | endif
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-tsserver',
\ 'coc-html',
\ 'coc-css',
\ 'coc-yaml',
\ 'coc-highlight',
\ 'coc-explorer',
\ 'coc-snippets',
\ 'coc-yank',
\ 'coc-prettier',
\ ]
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Coc autocomplete setup (see :h coc-completion-example)
" inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>"
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~ '\s'
" endfunction
" " Insert <tab> when previous text is space, refresh completion if not.
" inoremap <silent><expr> <TAB>
" \ coc#pum#visible() ? coc#pum#next(1):
" \ <SID>check_back_space() ? "\<Tab>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
" else
" inoremap <silent><expr> <c-@> coc#refresh()
" endif
" inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>"
" inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" inoremap <silent><expr> <TAB>
" \ coc#pum#visible() ? 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>'
Plug 'ludovicchabant/vim-gutentags'
let g:gutentags_exclude_filetypes = ['gitcommit', 'gitconfig', 'gitrebase', 'gitsendemail', 'git', 'lock', 'json', 'yaml']
Plug 'majutsushi/tagbar'
Plug 'liuchengxu/vista.vim'
let g:vista_default_executive = 'coc'
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" 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
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Javascript syntax highlighting
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
" Javascript syntax highlighting
Plug 'jelera/vim-javascript-syntax'
hi link javaScriptTemplateVar Identifier
hi link javaScriptTemplateString String
" Javascript library syntax highlighting
Plug 'othree/javascript-libraries-syntax.vim'
" highlighting for Pug
Plug 'digitaltoad/vim-pug'
" highlighting for Vue
Plug 'posva/vim-vue'
" Lightline status bar
Plug 'itchyny/lightline.vim'
set laststatus=2
Plug 'majutsushi/tagbar'
let g:lightline = {
\ 'colorscheme': 'embark',
\ 'active': {
\ 'left': [ ['mode', 'paste'],
\ ['gitbranch', 'filename', 'modified'] ],
\ 'right': [ ['lineinfo'],
\ ['percent'],
\ ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok'] ]
\ },
\ 'component_function': {
\ 'filename': 'LightLineFilename',
\ 'gitbranch': 'fugitive#head'
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK'
\ },
\ 'component_type': {
\ 'readonly': 'error',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ },
\ }
function! LightLineFilename()
return expand('%')
endfunction
function! LightlineLinterWarnings() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ▲', all_non_errors)
endfunction
function! LightlineLinterErrors() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
endfunction
function! LightlineLinterOK() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✓ ' : ''
endfunction
" Update and show lightline but only if it's visible (e.g., not in Goyo)
autocmd User ALELint call s:MaybeUpdateLightline()
function! s:MaybeUpdateLightline()
if exists('#lightline')
call lightline#update()
end
endfunction
" Add gutter indicators for lines that have been changed
Plug 'airblade/vim-gitgutter'
" GitGutter update time
set updatetime=500
" GitGutter styling to use · instead of +/-
let g:gitgutter_sign_added = '∙'
let g:gitgutter_sign_modified = '∙'
let g:gitgutter_sign_removed = '∙'
let g:gitgutter_sign_modified_removed = '∙'
" Integrated Git commands
Plug 'tpope/vim-fugitive'
" Brackets and quotes
Plug 'tpope/vim-surround'
" async liniting
Plug 'w0rp/ale'
let g:ale_sign_warning = '▲'
let g:ale_sign_error = '✗'
highlight link ALEWarningSign String
highlight link ALEErrorSign Title
" Syntax highlighting for jsx
Plug 'mxw/vim-jsx'
let g:jsx_ext_required = 0
" Syntax highlighting for tsx
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
" Auto align text
Plug 'godlygeek/tabular'
" Markdown syntax highlighting
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
set wildignore+=node_modules
" Fuzzy find files
Plug 'junegunn/fzf'
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
let g:fzf_tags_command = 'ctags -R'
" Other file finder
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'kyazdani42/nvim-web-devicons'
" Search file text
Plug 'mileszs/ack.vim'
let g:ackprg = 'ag --column'
" JSON highlighting
Plug 'elzr/vim-json'
" Key mappings
Plug 'tpope/vim-unimpaired'
" For Ruby on Rails development
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
" Colorscheme
Plug 'w0ng/vim-hybrid'
" Colorscheme
Plug 'morhetz/gruvbox'
let g:gruvbox_contrast_dark='medium'
" Colorscheme
Plug 'embark-theme/vim', { 'as': 'embark' }
" let g:embark_terminal_italics = 1
" Colorscheme
Plug 'sonph/onehalf', {'rtp': 'vim/'}
" Colorscheme
Plug 'ayu-theme/ayu-vim'
let ayucolor="mirage"
" Expand shorthand markup notation
Plug 'mattn/emmet-vim'
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
Plug 'norcalli/nvim-colorizer.lua'
call plug#end()
filetype plugin indent on
filetype plugin on
set number
set linespace=1
set showtabline=2
set incsearch
set ignorecase
set noswapfile
set tabstop=2
set shiftwidth=2
set expandtab
" Set up colors
set termguicolors
set background=dark
colorscheme embark
" set background=light
" colorscheme onehalflight
if has('gui_running')
" set background=dark
" colorscheme gruvbox
" set guifont=Monaco
noremap <C-Tab> :tabnext<CR>
noremap <C-S-Tab> :tabprev<CR>
" Switch to specific tab numbers with Command-number
noremap <D-1> :tabn 1<CR>
noremap <D-2> :tabn 2<CR>
noremap <D-3> :tabn 3<CR>
noremap <D-4> :tabn 4<CR>
noremap <D-5> :tabn 5<CR>
noremap <D-6> :tabn 6<CR>
noremap <D-7> :tabn 7<CR>
noremap <D-8> :tabn 8<CR>
noremap <D-9> :tabn 9<CR>
" Command-0 goes to the last tab
noremap <D-0> :tablast<CR>
endif
inoremap jk <ESC>
let mapleader = "\<Space>"
syntax on
set encoding=utf-8
nnoremap <leader>z 1z=
nnoremap <leader>s :set spell! <enter>
nnoremap <leader>l :set number! <enter>
nnoremap <leader>lr :set relativenumber! <enter>
nnoremap <leader>v :vsplit <enter>
nnoremap <leader>h :split <enter>
nnoremap <leader>q :q <enter>
nnoremap <leader>w :w <enter>
nnoremap <leader>e :e <enter>
nnoremap <leader>n :CocCommand explorer <enter>
nnoremap <leader>p <c-^>
nnoremap <silent><leader>i :bprev<cr>
nnoremap <silent><leader>o :bnext<cr>
nnoremap <leader>gd :Git diff <enter>
nnoremap <leader>gs :Git status <enter>
nnoremap <leader>gb :Git blame <enter>
nnoremap <leader>gds :Gvdiffsplit <C-r>0 <enter>
nnoremap <leader>gh :0Gclog <enter>
nnoremap <leader>t :term /bin/bash --rcfile /home/ubuntu/.bash_profile<enter>
nnoremap <leader>frs :term /bin/bash --rcfile /home/ubuntu/.bash_profile<enter>frs<enter>
nnoremap <leader>rs :term /bin/bash --rcfile /home/ubuntu/.bash_profile<enter>rs<enter>
nnoremap <leader>ct :term /bin/bash --rcfile /home/ubuntu/.bash_profile<enter>tc<enter>
nnoremap <leader>ts :tselect<CR>
nnoremap <leader>d <C-]>
nnoremap <leader>td <C-W><C-]>
nnoremap <leader>b <C-t>
nnoremap <Leader>rn :%s/\<<C-r><C-w>\>/
nnoremap <leader>tb :TagbarToggle<CR>
nnoremap <leader>an :set norelativenumber<CR>
map <leader>; <Plug>(easymotion-prefix)
map <C-n> <Plug>(easymotion-prefix)
nnoremap <silent><space>y :<C-u>CocList -A --normal yank<cr>
nnoremap <leader><space> <c-^>
vnoremap . :norm.<CR>
:autocmd InsertEnter,InsertLeave * set cul!
" Split switching
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
"ctrl p to :FZF for file search
" nnoremap <C-p> :FZF <Enter>
nnoremap <C-p> :Telescope find_files <Enter>
"ctrl f to search file content
nnoremap <C-f> :Ack<space>
" ctrl g to do a global search for the work under the cursor
nnoremap <C-g> :Ack <c-r>=expand("<cword>")<cr> <enter>
" Quickly navigate between ALE errors
nmap <silent> <C-q> <Plug>(ale_previous_wrap)
nmap <silent> <C-w> <Plug>(ale_next_wrap)
augroup AutoSaveFolds
autocmd Syntax * setlocal foldmethod=syntax
autocmd Syntax javascript,python,vim,css,html,scss normal zR
augroup END
" Make it so that a curly brace automatically inserts an indented line
inoremap {<CR> {<CR>}<Esc>O<BS><Tab>
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <leader>ch :nohl<CR><C-l>
nnoremap <silent><leader><leader> :bprev<cr>
" relative numbers in normal mode, absolute in instert
" augroup numbertoggle
" autocmd!
" autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
" autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
" augroup END
set t_Co=256
set spell