-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
719 lines (605 loc) · 22.4 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
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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
set shell=bash
set nocompatible " be iMproved, required
filetype off " required
call plug#begin()
Plug 'tpope/vim-fugitive'
Plug 'wincent/command-t'
Plug 'Yggdroot/indentLine'
Plug 'godlygeek/tabular'
Plug 'flazz/vim-colorschemes'
Plug 'morhetz/gruvbox'
Plug 'Haron-Prime/Antares'
Plug 'altercation/vim-colors-solarized'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'Konfekt/FastFold'
Plug 'airblade/vim-gitgutter'
Plug 'eparreno/vim-matchit'
Plug 'idbrii/vim-hiinterestingword' " allows for highlighting interesting words in sepparate colors
Plug 'junegunn/vim-peekaboo'
Plug 'michaeljsmith/vim-indent-object'
Plug 'spiiph/vim-space'
Plug 'tpope/vim-surround'
Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-rsi', { 'on': [] }
Plug 'unblevable/quick-scope' " shows good targets for f/t to move far on line in specific color
Plug 'vim-scripts/camelcasemotion'
Plug 'mbbill/undotree'
Plug 'kana/vim-operator-user'
Plug 'haya14busa/vim-operator-flashy'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'antoinemadec/coc-fzf', {'branch': 'release'}
Plug 'chrisbra/matchit'
Plug 'daeyun/vim-matlab', { 'as': 'neovim-matlab' }
Plug 'tdehaeze/matlab-vim'
Plug 'TheZoq2/neovim-auto-autoread'
Plug 'yuezk/vim-js'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'nvie/vim-flake8'
Plug 'milkypostman/vim-togglelist'
" Plug 'ekalinin/Dockerfile.vim'
Plug 'lifepillar/pgsql.vim'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npm install' }
Plug 'srivathsanmurali/OpenAPIValidate.vim'
Plug 'chr4/nginx.vim'
Plug 'embear/vim-uncrustify'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'fannheyward/telescope-coc.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'kyazdani42/nvim-web-devicons'
Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh' }
Plug 'hashivim/vim-terraform'
" Plug 'github/copilot.vim', {'branch': 'release'}
" All of your Plugins must be added before the following line
call plug#end() " required
filetype plugin indent on " required
" Put your non-Plugin stuff after this line
" Load ESLint 8 compatible CoC plugin
set runtimepath^=~/repos/coc-eslint
set autoread
"Autoreload files when changed externally
" if has('nvim') "Prevent errors when using standard vim
" autocmd VimEnter * AutoreadLoop
" endif
" auto-reload
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <silent> <leader>w :w!<cr>
" Fast editing of the _vimrc
map <silent> <leader>v :e! ~/.config/nvim/init.vim<cr>
autocmd! bufwritepost init.vim source ~/.config/nvim/init.vim " When vimrc is edited, reload it
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cwd :cd %:p:h<cr>
map <leader>c Yp:.!bc -l<cr>
map <leader>e :e <C-r>=expand("%:p:h") . "/"<cr>
autocmd CmdwinEnter * nnoremap <CR> <CR>
autocmd BufReadPost quickfix nnoremap <CR> <CR>
let g:calendar_monday = 1
let g:calendar_weeknm = 2 " WK 1
let g:calendar_mark = 'right'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set scrolloff=7 " Set 7 lines to the cursor - when moving vertical
set ruler " Always show current position
set cmdheight=1 " The commandbar height
set hid " Change buffer - without saving
set ignorecase " Ignore case when searching
set smartcase " Override ignorecase if the pattern contains upper case
set hlsearch " Highlight search things
set incsearch " Make search act like search in modern browsers
set nowrapscan " Turn off search wrapping
set nolazyredraw " Don't redraw while executing macros
set magic " Set magic on, for regular expressions
set showmatch " Show matching bracets when text indicator is over them
set matchtime=2 " How many tenths of a second to blink
set wildmenu " Turn on WiLd menu
set wildmode=longest,list,full " Bash style completion
set wildignorecase "When set case is ignored when completing file names and directories
set hidden " When on a buffer becomes hidden when it is abandoned
set showcmd " Show (partial) command in the last line of the screen
set ttyfast " 'smooth' scrolling
set virtualedit=block " allow cursor to be moved into empty space in visual
set splitbelow " intuitive split placement
set splitright " intuitive split placement
set backspace=2
set shortmess=aW " Abbreviate messages to avoid 'hit-enter' prompts
set cmdheight=2
" Automatically resize vertical splits.
autocmd WinEnter * :set winfixheight
autocmd WinEnter * :wincmd =
" Cursor color
if &term =~ "xterm\\|rxvt|terminator|screen-256color"
" use an green cursor in insert mode
let &t_SI = "\<Esc>]12;green\x7"
" use a red cursor otherwise
let &t_EI = "\<Esc>]12;red\x7"
silent !echo -ne "\033]12;red\007"
" reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]112\007"
" use \003]12;gray\007 for gnome-terminal and rxvt up to version 9.21
endif
" Cursor shape (not working in terminator)?
if &term =~ '^xterm\\|rxvt\\|terminator|screen-256color'
" solid underscore
let &t_SI .= "\<Esc>[4 q"
" solid block
let &t_EI .= "\<Esc>[2 q"
" 1 or 0 -> blinking block
" 3 -> blinking underscore
" Recent versions of xterm (282 or above) also support
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab " Use the appropriate number of spaces to insert a <Tab>
set shiftwidth=2 " Number of spaces to use for each step of (auto)indent
set tabstop=2 " Number of spaces that a <Tab> in the file counts for
set smarttab " <Tab> in front of a line indents to 'shiftwidth'
set linebreak " Wrap lines at a char in 'breakat' rather than last char
set textwidth=88 " Maximum width of text that is being inserted
set formatoptions-=c " Don't wrap comments
set autoindent " Auto indent
set smartindent " Do smart autoindenting when starting a new line
set nowrap " Wrap lines
set number
set cursorline " highlights the line cursor is at
set cursorcolumn " highlights the column cursor is at
set formatoptions-=t " disable automatic linebreak at textwidth for non-comments
set formatoptions-=c " disable automatic linebreak at textwidth for comments
set formatoptions+=r
set formatoptions+=q
set formatoptions+=o
set formatoptions+=l
" cursorcolumn only in active window
autocmd WinEnter * setlocal cursorcolumn
autocmd WinLeave * setlocal nocursorcolumn
" relative number only in active window
autocmd WinEnter * setlocal relativenumber
autocmd WinLeave * setlocal norelativenumber
" Copy/Paste with os buffer
noremap <leader>y "+y
noremap <leader>Y "+y$
noremap <leader>p "+p
noremap <leader>P "+P
noremap <leader>d "+d
noremap <leader>D "+D
" Y consistent with D
nnoremap Y 0y$
" operator flashy - flashes the target of a y<target> command
map y <Plug>(operator-flashy)
" nmap Y <Plug>(operator-flashy)$
" center window after jumping forward
nnoremap n nzz
nnoremap N Nzz
nnoremap } }zz
nnoremap { {zz
" swap ^$ with HL (move to fourth row from top/bottom)
nnoremap H ^
nnoremap ^ H
nnoremap L $
nnoremap $ L
" move by row rather than line
nnoremap j gj
nnoremap k gk
" reverse swap
nnoremap gj j
nnoremap gk k
" Insert and Append on wrapped lines
nnoremap gI g0i
nnoremap gA g$i
set guioptions=aegitc
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" buffer movement
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
set history=500
set ruler
set showcmd
set incsearch
set hlsearch
" tags
" set tags=tags;
" filetype detection
if has("autocmd")
filetype plugin indent on
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd FileType c,cpp setlocal shiftwidth=2 tabstop=8
autocmd FileType python setlocal shiftwidth=4 tabstop=4
" jump to last known position
autocmd BufReadPost *
\ if line("'\"") <= line("$") |
\ exec "normal g`\"" |
\ endif
augroup END
else
set autoindent
endif
" Whitespace handling
match Todo /\s\+$/
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd FileType * autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
set noshowmode
nnoremap <silent><C-n> :call ToggleRelativeNumber()<cr>
" toggle relative number for lines
function! ToggleRelativeNumber()
if(&relativenumber == 1)
set relativenumber!
set number
else
set relativenumber
endif
endfunc
" {{{ EasyAlign "
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" Don't add spaces around separator
let g:easy_align_left_margin = 0
let g:easy_align_right_margin = 0
" }}} EasyAlign "
" {{{ word motions inside camel/snake case"
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" }}} word motions inside camel/snake case"
" {{{ GitGutter Sign colors '
highlight GitGutterAdd ctermbg=232 ctermfg=22
highlight GitGutterChange ctermbg=232 ctermfg=yellow
highlight GitGutterDelete ctermbg=232 ctermfg=red
highlight GitGutterChangeDelete ctermbg=232 ctermfg=yellow
" }}} GitGutter Sign colors "
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set nowritebackup
set noswapfile
" persistent undo
set undodir=~/.vim/undodir
set undofile
set undolevels=700
set undoreload=700
let g:gundo_preview_bottom=1
let g:gundo_right=1
let g:gundo_help=0
nnoremap <Leader>u :UndotreeToggle<CR>
let g:undotree_WindowLayout = 'botright'
let g:undotree_SetFocusWhenToggle = 1
let g:undotree_DiffpanelHeight = 20
" nnoremap <silent> <C-P> :FZF<CR>
command! FZFag call fzf#run({
\ 'source': 'find . -path "*.venv*" -prune -o -path "*node_modules*" -prune -o -path ./.svn -prune -o -path ./.git -prune -o -path "*pyc" -o -path ./vps/services/build -prune -prune -o -type f -print 2> /dev/null',
\ 'sink': 'e',
\ 'down': '40%',
\ 'options': '--expect=ctrl-t,ctrl-v,ctrl-x'})
nnoremap <silent> <C-P> :FZFag<CR>
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(expand('<cword>')), 1,
\ fzf#vim#with_preview(), <bang>0)
nnoremap <Leader>f :Rg<CR>
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
nnoremap <Leader>F :RG<CR>
nnoremap <leader>b :Buffers<CR>
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
""""""""""""""""""""""""""""""
" => Statusline
""""""""""""""""""""""""""""""
set laststatus=2 " Always hide the statusline
" Format the statusline
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
set statusline^=%{coc#status()}
function! CurDir()
let curdir = substitute(getcwd(), '/Users/fsvenson', "~", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Development
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" {{{ Completion
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
if has('nvim-0.5.0')
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
endif
" GitHub Co-pilot
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
let g:copilot_node_command =
\ "/se/r3dm/sw/centos-7-x86_64/inst/nodejs/16.13.0/bin/node"
" allow to scroll in the preview
set mouse=a
" mappings
nnoremap <silent> <space><space> :<C-u>CocFzfList<CR>
nnoremap <silent> <space>a :<C-u>CocFzfList diagnostics<CR>
nnoremap <silent> <space>b :<C-u>CocFzfList diagnostics --current-buf<CR>
nnoremap <silent> <space>c :<C-u>CocFzfList commands<CR>
nnoremap <silent> <space>e :<C-u>CocFzfList extensions<CR>
nnoremap <silent> <space>l :<C-u>CocFzfList location<CR>
nnoremap <silent> <space>o :<C-u>CocFzfList outline<CR>
nnoremap <silent> <space>s :<C-u>CocFzfList symbols<CR>
nnoremap <silent> <space>p :<C-u>CocFzfListResume<CR>
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)
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Quickfix
nmap <leader>qf :<C-u>CocCommand tsserver.executeAutofix<CR>
" }}} Completion
" {{{ Location Quickfix
" toggle location and quickfix lists
" mnemonic: list/ ( quick | location )
nnoremap <leader>ll :call ToggleLocationList()<CR>
nnoremap <leader>lq :call ToggleQuickfixList()<CR>
" }}} Location Quickfix
au! BufRead,BufNewFile *.json set filetype=json
map <silent> gt <C-]>
noremap <silent> <Leader>d m':%s/\r$//<cr>:set fileformat=dos<cr>`'
set foldmethod=syntax
set foldlevel=20 " by defualt open folds to level 20
set nofoldenable
let g:xml_syntax_folding=1
set colorcolumn=80 " Show where column 80 is.
" colorscheme
set t_Co=256
set background=dark
colorscheme hybrid
set guifont=Inconsolatazi4\ Medium\ 10
syntax on
set statusline+=%#warningmsg#
set statusline+=%*
" Matlab syntax
augroup filetypedetect
au! BufRead,BufNewFile *.m,*.oct set filetype=matlab
au! BufRead,BufNewFile *.plt set filetype=gnuplot
augroup END
" Use keywords from Octave syntax language file for autocomplete
if has("autocmd") && exists("+omnifunc")
autocmd Filetype matlab
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
set path+=..
" Find this C symbol
nmap <leader>cs :cs find s <C-R>=expand("<cword>")<CR><CR><C-O>:cw<CR>
" Find this definition
nmap <leader>cg :cs find g <C-R>=expand("<cword>")<CR><CR>
" Find functions calling this function
nmap <leader>cc :cs find c <C-R>=expand("<cword>")<CR><CR>
" Find this text string
nmap <leader>ct :cs find t <C-R>=expand("<cword>")<CR><CR>
" Find this egrep pattern
nmap <leader>ce :cs find e <C-R>=expand("<cword>")<CR><CR>
" Find this file
nmap <leader>cf :cs find f <C-R>=expand("<cfile>")<CR><CR>
" Find files #including this file
nmap <leader>ci :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" Find functions called by this function
nmap <leader>cd :cs find d <C-R>=expand("<cword>")<CR><CR>
" Add cscope.out
nmap <leader>ca :cs add .git/cscope.out .<cr>
" Move about the quickfix list more easily
nmap <leader>n :cnext<cr>
nmap <leader>N :clast<cr>
nmap <leader>p :cprev<cr>
nmap <leader>P :cfirst<cr>
" Change indentation continuously
vmap < <gv
vmap > >gv
" Git status for project
nmap <leader>gs :Gstatus<cr>
" Commit staged files
nmap <leader>gc :Gcommit -v<cr>
" Commit current buffer
nmap <leader>gC :Gcommit -v %<cr>
" Git log for project
nmap <silent> <leader>gl :Glog -256 --<cr>:copen<cr>
" Git log with stat for project
nmap <silent> <leader>gL :Git! log -256 --stat<cr>
" Git log with patch for project
nmap <silent> <leader>gP :Git! log -256 -p<cr>
" Git diff for project
nmap <silent> <leader>gD :Git! diff<cr>
" Git diff current buffer
nmap <silent> <leader>gd :Gdiff<cr>
" {{{ Fugitive GitGutter and Git "
" populate quicklist with commited version of current file - fugitive
nnoremap <leader>gl :silent Glog<CR>
nnoremap <leader>gc :Gcommit<CR>
nnoremap <leader>gr :GitGutterRevertHunk<CR>
nnoremap <leader>ga :GitGutterStageHunk<CR>
nnoremap <leader>gp :GitGutterPreviewHunk<cr>
autocmd FileType gitcommit setlocal textwidth=72
" }}} Fugitive "
" git conflic marker search
nnoremap <leader>gC /^.*\(<<<\\|====\\|>>>>\).*$<cr>
" set errorformat=\"%f\"\\,\ line\ %l\:\ %m
"
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<c-tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-tab>"
" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" let g:UltiSnipsSnippetDirectories=['~/UltiSnips']
" function! ExpandLspSnippet()
" call UltiSnips#ExpandSnippetOrJump()
" if !pumvisible() || empty(v:completed_item)
" return ''
" endif
" " only expand Lsp if UltiSnips#ExpandSnippetOrJump not effect.
" let l:value = v:completed_item['word']
" let l:matched = len(l:value)
" if l:matched <= 0
" return ''
" endif
" " remove inserted chars before expand snippet
" if col('.') == col('$')
" let l:matched -= 1
" exec 'normal! ' . l:matched . 'Xx'
" else
" exec 'normal! ' . l:matched . 'X'
" endif
" if col('.') == col('$') - 1
" " move to $ if at the end of line.
" call cursor(line('.'), col('$'))
" endif
" " expand snippet now.
" call UltiSnips#Anon(l:value)
" return ''
" endfunction
" imap <C-b> <C-R>=ExpandLspSnippet()<CR>
" SCONS
autocmd BufRead,BufNewFile SConstruct set filetype=python
autocmd BufRead,BufNewFile SConscript set filetype=python
" R or S
autocmd BufRead,BufNewFile *.r set filetype=R
" autocmd BufRead,BufNewFile *.json set filetype=javascript
autocmd BufRead,BufNewFile Dockerfile* set filetype=dockerfile
autocmd BufRead,BufNewFile *.dock set filetype=dockerfile
" Template files
nmap <silent> ,d <Plug>(coc-definition)
nmap <silent> <C-,> <Plug>(coc-references)
nn <silent> K :call CocActionAsync('doHover')<cr>
set updatetime=300
au CursorHold * sil call CocActionAsync('highlight')
au CursorHoldI * sil call CocActionAsync('showSignatureHelp')
let g:sql_type_default = 'pgsql'
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 Prettier :call CocAction('runCommand', 'prettier.formatFile')
let g:coc_disable_startup_warning = 1
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" {{{
" ccls specifics
" bases
nn <silent> xb :call CocLocations('ccls','$ccls/inheritance')<cr>
" bases of up to 3 levels
nn <silent> xb :call CocLocations('ccls','$ccls/inheritance',{'levels':3})<cr>
" derived
nn <silent> xd :call CocLocations('ccls','$ccls/inheritance',{'derived':v:true})<cr>
" derived of up to 3 levels
nn <silent> xD :call CocLocations('ccls','$ccls/inheritance',{'derived':v:true,'levels':3})<cr>
" caller
nn <silent> xc :call CocLocations('ccls','$ccls/call',{'hierarchy':v:true})<cr>
" callee
nn <silent> xC :call CocLocations('ccls','$ccls/call',{'callee':v:true})<cr>
" $ccls/member
" member variables / variables in a namespace
nn <silent> xm :call CocLocations('ccls','$ccls/member')<cr>
" member functions / functions in a namespace
nn <silent> xf :call CocLocations('ccls','$ccls/member',{'kind':3})<cr>
" nested classes / types in a namespace
nn <silent> xs :call CocLocations('ccls','$ccls/member',{'kind':2})<cr>
nmap <silent> xt <Plug>(coc-type-definition)<cr>
nn <silent> xv :call CocLocations('ccls','$ccls/vars')<cr>
nn <silent> xV :call CocLocations('ccls','$ccls/vars',{'kind':1})<cr>
nn xx x
autocmd FileType python let b:coc_root_patterns = ['pyrightconfig.json', '.git']
" }}}
" }}}
"
if has('nvim') | set inccommand=split | endif
let g:clipboard = {
\ 'name': 'xclip',
\ 'copy': {
\ '+': 'xclip -selection clipboard',
\ '*': 'xclip -selection clipboard',
\ },
\ 'paste': {
\ '+': 'xclip -selection clipboard -o',
\ '*': 'xclip -selection clipboard -o',
\ },
\ 'cache_enabled': 1,
\ }
" Markdown preview
let g:mkdp_open_to_the_world = 1
let g:mkdp_echo_preview_url = 1
let g:mkdp_port = '5000'
let g:mkdp_refresh_slow = 1
let g:python3_host_prog = '/se/home/fresv/.pyvenvs/vps_dev/bin/python3'
" Telescope
lua require('telescope').load_extension('coc')
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
" " tree-sitter
" lua <<EOF
" require'nvim-treesitter.configs'.setup {
" ensure_installed = {"python", "javascript", "c", "cpp", "bash", "json", "tsx"}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages
" ignore_install = {}, -- List of parsers to ignore installing
" highlight = {
" enable = true, -- false will disable the whole extension
" disable = {"bash"}, -- list of language that will be disabled
" },
" }
" EOF