-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
executable file
·811 lines (660 loc) · 24.8 KB
/
init.vim
File metadata and controls
executable file
·811 lines (660 loc) · 24.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
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
" Don't try to be vi compatible
set nocompatible
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
if isdirectory(expand('~/.vim/bundle/Vundle.vim'))
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'christoomey/vim-tmux-navigator'
" Plugin 'klen/python-mode'
Plugin 'mjbrownie/swapit'
" Plugin 'vim-airline/vim-airline'
" let g:airline_theme='angr'
" Plugin 'vim-airline/vim-airline-themes'
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plugin 'junegunn/fzf.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-obsession'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-abolish'
Plugin 'airblade/vim-gitgutter'
Plugin 'reedes/vim-pencil'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
Plugin 'baeuml/summerfruit256.vim'
Plugin 'projekt0n/github-nvim-theme'
Plugin 'majutsushi/tagbar'
Plugin 'tommcdo/vim-exchange'
Plugin 'rhysd/vim-clang-format'
" Plugin 'alok/notational-fzf-vim'
if has('nvim')
Plugin 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plugin 'Shougo/deoplete.nvim'
Plugin 'roxma/nvim-yarp'
Plugin 'roxma/vim-hug-neovim-rpc'
endif
" Plugin 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
Plugin 'JoshMcguigan/estream'
Plugin 'skywind3000/asyncrun.vim'
Plugin 'dbakker/vim-paragraph-motion'
Plugin 'vim-scripts/argtextobj.vim'
Plugin 'PeterRincker/vim-argumentative'
Plugin 'vim-scripts/DoxygenToolkit.vim'
" Plugin 'dense-analysis/ale'
Plugin 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plugin 'justinmk/vim-sneak'
Plugin 'godlygeek/tabular'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'fedorenchik/qt-support.vim'
" Plugin 'inkarkat/vim-ConflictMotions'
Plugin 'madox2/vim-ai'
Plugin 'peterhoeg/vim-qml'
Plugin 'Shougo/neosnippet.vim'
Plugin 'Shougo/neosnippet-snippets'
Plugin 'tpope/vim-repeat'
Plugin 'gorkunov/smartpairs.vim'
Plugin 'joshuavial/aider.nvim'
Plugin 'neovim/nvim-lspconfig', {'tag': 'v1.8.0', 'frozen': 1}
Plugin 'mason-org/mason.nvim', {'tag': 'v1.11.0', 'frozen': 1}
Plugin 'mason-org/mason-lspconfig.nvim', {'tag': 'v1.32.0', 'frozen': 1}
Plugin 'hrsh7th/nvim-cmp'
Plugin 'hrsh7th/cmp-nvim-lsp'
call vundle#end() " required
filetype plugin indent on " required
endif
" ======================================
" machine specific stuff
" ======================================
" F13 to grab data from dtrs
nnoremap <silent> <F12> :$read ! ~/scripts/grab-data-from-dtrs \| egrep "rawdata.lsd" \| rev \| cut -c12- \| rev <cr>
" F9 to compile or generate report
autocmd FileType c,cpp,cmake,qml,javascript nnoremap <buffer> <silent> <F9> :AsyncStop<cr> :AsyncRun -save=2 -cwd=<root> ~/scripts/build-script.sh<cr>
autocmd FileType markdown,mkd nnoremap <buffer> <silent> <F9> :AsyncRun -save=1 ~/scripts/make-pres %<cr>
let g:vim_ai_roles_config_file = '~/.config/openai.roles'
" remap leader key
nnoremap <SPACE> <Nop>
let mapleader=" "
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<C-k>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" deoplete configuration
let g:deoplete#enable_at_startup = 1
" Use ALE and also some plugin 'foobar' as completion sources for all code.
" call deoplete#custom#option('sources', {
" \ '_': ['ale'],
" \})
function! LspAttached() abort
" nnoremap <buffer> K <cmd>lua vim.lsp.buf.hover()<cr>
" nnoremap <buffer> gd <cmd>lua vim.lsp.buf.definition()<cr>
" nnoremap <buffer> gD <cmd>lua vim.lsp.buf.declaration()<cr>
" nnoremap <buffer> gi <cmd>lua vim.lsp.buf.implementation()<cr>
" nnoremap <buffer> go <cmd>lua vim.lsp.buf.type_definition()<cr>
" nnoremap <buffer> gr <cmd>lua vim.lsp.buf.references()<cr>
" nnoremap <buffer> gs <cmd>lua vim.lsp.buf.signature_help()<cr>
" nnoremap <buffer> <F2> <cmd>lua vim.lsp.buf.rename()<cr>
" nnoremap <buffer> <F3> <cmd>lua vim.lsp.buf.format({async = true})<cr>
" xnoremap <buffer> <F3> <cmd>lua vim.lsp.buf.format({async = true})<cr>
" nnoremap <buffer> <F4> <cmd>lua vim.lsp.buf.code_action()<cr>
endfunction
autocmd LspAttach * call LspAttached()
lua <<EOF
-- Configure LSP clients
-- Set default root markers for all clients
vim.lsp.config('*', {
root_markers = { '.git', '.root' },
})
-- Set default configuration for clangd but don't enable it
vim.lsp.config.clangd = {
cmd = {
'clangd',
'--clang-tidy',
'--background-index',
'--offset-encoding=utf-8',
},
root_markers = { '.clangd', 'compile_commands.json' },
filetypes = { 'c', 'cpp' },
}
-- Enable Language Server
vim.lsp.enable('clangd')
EOF
" special chatGPT commands
command! -range -nargs=? AITranslate <line1>,<line2>call AIEditRun(<range>, "Translate to English: " . <q-args>)
command! -range -nargs=? AICode <line1>,<line2>call AIRun(<range>, "Programming syntax is " . &filetype . ", " . <q-args>)
command! -range -nargs=? AIImprove <line1>,<line2>call AIEditRun(<range>, "Please improve phrasing and word choices: " . <q-args>)
command! -range -nargs=? AIFix <line1>,<line2>call AIEditRun(<range>, "Fix grammar and spelling: " . <q-args>)
nnoremap <silent> <F8> :TagbarToggle<CR>
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nmap <Leader>f :GFiles<CR>
nmap <Leader>F :Files<CR>
nmap <Leader>d :Buffers<CR>
nmap <Leader>h :History<CR>
nmap <Leader>t :BTags<CR>
nmap <Leader>T :Tags<CR>
nmap <Leader>l :BLines<CR>
nmap <Leader>L :Lines<CR>
nmap <Leader>' :Marks<CR>
nmap <Leader>/ :Rg<Space>
nmap <Leader>H :Helptags!<CR>
nmap <Leader>C :Commands<CR>
nmap <Leader>: :History:<CR>
nmap <Leader>M :Maps<CR>
nnoremap <silent> <Leader>q :Rg <C-R><C-W><CR>
vnoremap <silent> <Leader>q y:Rg <C-R>=escape(@",'/\')<CR><CR>
" nmap <Leader>s :Filetypes<CR>
" Get text in files with Rg
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --fixed-strings --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ fzf#vim#with_preview(), <bang>0)
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-q': 'fill_quickfix',
\ 'ctrl-y': {lines -> setreg('+', join(lines, "\n"))}}
command! -bang -nargs=* BLines
\ call fzf#vim#grep(
\ 'rg --with-filename --column --line-number --no-heading --smart-case . '.fnameescape(expand('%:p')), 1,
\ fzf#vim#with_preview({'options': '--layout reverse --query '.shellescape(<q-args>).' --with-nth=4.. --delimiter=":"'}, 'right:50%'))
" \ fzf#vim#with_preview({'options': '--layout reverse --with-nth=-1.. --delimiter="/"'}, 'right:50%'))
" Customize fzf colors to match your color scheme
" - fzf#wrap translates this to a set of `--color` options
let g:fzf_colors =
\ { 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],}
" neccessary as snap ctags can't access /tmp
let g:tagbar_use_cache = 0
let g:tmux_navigator_no_wrap = 0
let g:nv_search_paths = ['~/neoscan/notes', '~/notes', 'docs.md', './notes.md']
nnoremap <silent> <leader>s :NV<CR>
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
" Put your non-Plugin stuff after this line
"
let g:ackprg = 'ag --nogroup --nocolor --column'
" Source the termdebug plugin for vim 8.2
if v:version >= 802
packadd termdebug
noremap <silent> <leader>t :Termdebug<cr>
endif
" better termdebug layout
let g:termdebug_wide=1
" Turn on syntax highlighting with doxygen on top
let g:load_doxygen_syntax=1
syntax on
" Security
set modelines=0
" Show line numbers
set number
" Show file stats
set ruler
" Blink cursor on error instead of beeping (grr)
set vb t_vb=
" Encoding
set encoding=utf-8
" Whitespace
set wrap
set textwidth=0
set wm=0
set formatoptions=tcq
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set noshiftround
set fo+=t
" Cursor motion
set scrolloff=3
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
runtime! macros/matchit.vim
" Navigation
noremap K {
noremap J }
noremap H ^
noremap L $
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" indentation
nnoremap <Tab> >>
nnoremap <S-Tab> <<
vnoremap <Tab> >><Esc>gv
vnoremap <S-Tab> <<<Esc>gv
" consistent Y
nnoremap Y y$
" need to remap ctrl-i as equivalent to <Tab> otherwise
noremap <C-n> <C-i>
" allow ctrl-z in insert mode
inoremap <c-z> <esc><c-z>
set whichwrap+=<,>,h,l,[,]
" Allow hidden buffers
set hidden
" Rendering
set ttyfast
" Status bar
set laststatus=2
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
set statusline+=%{fugitive#statusline()}
" Last line
set showmode
set showcmd
" Searching
nnoremap / /\v
vnoremap / /\v
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
" press enter to clear last search highlighting
nnoremap <silent> <cr> :noh<CR><CR>
" * just highlights but don't jump
map <silent> * :let @/="\\<<c-r><c-w>\\>"<CR>:set hls<CR>
" highlight the visual selection after pressing enter.
xnoremap <silent> <cr> "*y:silent! let searchTerm = '\V'.substitute(escape(@*, '\/'), "\n", '\\n', "g") <bar> let @/ = searchTerm <bar> echo '/'.@/ <bar> call histadd("search", searchTerm) <bar> set hls<cr>
" Remap help key.
inoremap <F1> <ESC>:set invfullscreen<CR>a
nnoremap <F1> :set invfullscreen<CR>
vnoremap <F1> :set invfullscreen<CR>
" format to hard line wraps
nnoremap <silent> Q gqap
xnoremap <silent> Q gq
nnoremap <silent> <leader>Q vapJgqap
" fzf-vim close quick when hitting ESC
set timeoutlen=1000 ttimeoutlen=0
" useful shortcuts
inoremap <C-u> <esc>gUiWEa
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" gw to swap the current word with the next, keep cursor
:nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>:nohlsearch<CR>
" Visualize tabs and newlines
set listchars=tab:▸\ ,eol:¬
" Uncomment this to enable by default:
" set list " To enable by default
" Or use your leader key + l to toggle on/off
" map <leader>l :set list!<CR> " Toggle tabs and EOL
" avoid random characters at startup
set t_TI= t_TE=
" handling setting and unsetting BAT_THEME for fzf.vim
augroup update_bat_theme
autocmd!
autocmd colorscheme * call ToggleBatEnvVar()
augroup end
function ToggleBatEnvVar()
if (&background == "light")
let $BAT_THEME='Monokai Extended Light'
else
let $BAT_THEME=''
endif
endfunction
colorscheme github_light_high_contrast
" :hi DiffAdd ctermfg=black cterm=bold guibg=green guifg=black
" :hi DiffText ctermbg=yellow ctermfg=red cterm=bold guibg=yellow guifg=red
" :hi DiffChange ctermbg=none ctermfg=none cterm=bold guibg=white guifg=black
" :hi DiffDelete guibg=lightblue guifg=lightblue
" tmux knows the extended mouse mode
if &term =~ '^screen'
"tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" change the direction of new splits
set splitbelow
set splitright
" map splits similar to tmux
nmap <Leader>\ :vsplit<CR>
nmap <Leader>- :split<CR>
:hi debugPC term=reverse ctermbg=lightblue guibg=lightblue
" don't hide symbols in markdown
set conceallevel=0
" fix syntax highlighting in markdown
function! MathAndLiquid()
"" Define certain regions
" Block math. Look for "$$[anything]$$"
syn region math start=/\$\$/ end=/\$\$/
" inline math. Look for "$[not $][anything]$"
syn match math_block '\$[^$].\{-}\$'
" Liquid single line. Look for "{%[anything]%}"
syn match liquid '{%.*%}'
" Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
" Fenced code blocks, used in GitHub Flavored Markdown (GFM)
syn region highlight_block start='```' end='```'
"" Actually highlight those regions.
hi link math Statement
hi link liquid Statement
hi link highlight_block Function
hi link math_block Function
endfunction
" no syntax highlighting in prot.md
autocmd BufNewFile,BufRead prot.md setlocal syntax=OFF
" no error highlighting for markdown at all
hi link markdownError NONE
" Call everytime we open a Markdown file
autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
" make sure .e files are highlighted properly
au BufNewFile,BufRead *.e set filetype=c
" make sure .qml files are highlighted properly
au BufNewFile,BufRead *.qml set filetype=qml
" Read-only pdf through pdftotext
autocmd BufReadPre *.pdf silent set ro
autocmd BufReadPost *.pdf silent %!pdftotext -nopgbrk -layout -q -eol unix "%" - | fmt -w78
" Open word files with pandoc and not as a zip file
let g:zipPlugin_ext = '*.zip,*.jar,*.xpi,*.ja,*.war,*.ear,*.celzip,*.oxt,*.kmz,*.wsz,*.xap,*.docm,*.dotx,*.dotm,*.potx,*.potm,*.ppsx,*.ppsm,*.pptx,*.pptm,*.ppam,*.sldx,*.thmx,*.xlam,*.xlsx,*.xlsm,*.xlsb,*.xltx,*.xltm,*.xlam,*.crtx,*.vdw,*.glox,*.gcsx,*.gqsx'
autocmd BufReadPre *.doc,*.docx,*.rtf,*.odp,*.odt silent set ro
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent set modifiable
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent set filetype=markdown
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent set conceallevel=0 " don't hide symbols in markdown
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent %!pandoc --columns=100 -t markdown "%" -o /dev/stdout
set mouse=a
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
" Display all matching file when we tab complete
set wildmenu
set clipboard=unnamedplus
" make sure pasted-over content doesn't go to clipboard
xnoremap <expr> p 'pgv"'.v:register.'y`>'
set tags=tags,./tags
set path=.
" set autochdir
" cursor shape depending on mode
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" optional reset cursor on start:
augroup myCmds
au!
autocmd VimEnter * silent !echo -ne "\e[2 q"
augroup END
autocmd filetype c setlocal noexpandtab shiftwidth=4 softtabstop=4
autocmd FileType c,cpp,cs,java set commentstring=//\ %s
set directory=$HOME/.vim/swapfiles//
" vim -b : edit binary using xxd-format!
augroup Binary
au!
au BufReadPre *.lsd let &bin=1
au BufReadPost *.lsd if &bin | %!xxd
au BufReadPost *.lsd set ft=xxd | endif
au BufWritePre *.lsd if &bin | %!xxd -r
au BufWritePre *.lsd endif
au BufWritePost *.lsd if &bin | %!xxd
au BufWritePost *.lsd set nomod | endif
augroup END
" use vim for prose
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init({'wrap': 'hard', 'autoformat': 0, 'conceallevel': 0})
autocmd FileType text call pencil#init({'wrap': 'hard', 'autoformat': 0, 'conceallevel': 0})
augroup END
" open quickfix window automatically when AsyncRun is executed
" set the quickfix window 12 lines height.
let g:asyncrun_open = 12
" open quickfix window always at the bottom
" :autocmd FileType qf wincmd J
" Set global error format to match estream output
" set errorformat=%f\|%l\|%c,%f\|%l\|,%f\|\|
" Use global error format with asyncrun
" let g:asyncrun_local = 0
" Pipe any async command through estream to format it as expected
" by the errorformat setting above
" example: `:Async cargo test`
" command -nargs=1 Async execute "AsyncRun <args> |& $VIM_HOME/bundle/estream/bin/estream"
" Go to the previous/next quickfix item
nnoremap [q :cprev<CR>
nnoremap ]q :cnext<CR>
" ignore warnings when jumping with :cn
set errorformat^=%-G%f:%l:\ warning:%m
set errorformat^=%-G%f:%l:\ note:%m
" F4 to toggle quickfix window
nnoremap <F4> :call asyncrun#quickfix_toggle(12)<cr>
" logic to find the root directory
let g:asyncrun_rootmarks = ['.git', '.root']
autocmd FileType sh nnoremap <buffer> <silent> <F9> :AsyncStop! \| sleep 100m \| AsyncRun %:p<cr>
let g:clang_format#style_options = {
\ "UseTab": "Never",
\ "IndentWidth": "4",
\ "AllowShortIfStatementsOnASingleLine": "false",
\ "AllowShortFunctionsOnASingleLine": "false",
\ "ColumnLimit": "0",
\ "ConstructorInitializerAllOnOneLineOrOnePerLine": "false",
\ "ConstructorInitializerIndentWidth": "0",
\ "AccessModifierOffset": "-4",
\ "BreakBeforeBraces": "Linux",
\ "BreakConstructorInitializers": "BeforeComma",
\ "AllowShortCaseLabelsOnASingleLine": "true",
\ "IndentCaseLabels": "true",
\ "DerivePointerAlignment": "false",
\ "PointerAlignment": "Left"}
" use this to close multiple buffers with fzf
function! s:list_buffers()
redir => list
silent ls
redir END
return split(list, "\n")
endfunction
function! s:delete_buffers(lines)
execute 'bwipeout' join(map(a:lines, {_, line -> split(line)[0]}))
endfunction
command! BD call fzf#run(fzf#wrap({
\ 'source': s:list_buffers(),
\ 'sink*': { lines -> s:delete_buffers(lines) },
\ 'options': '--multi --reverse --bind ctrl-a:select-all+accept'
\ }))
" setlocal spell
set spelllang=en_us
" fix latest error directly
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
" Do not lint or fix python files.
" let g:ale_pattern_options_enabled = 1
" let g:ale_pattern_options = {
" \ '*.py': {'ale_linters': [], 'ale_fixers': []},
" \}
" " Only run linters named in ale_linters settings.
" let g:ale_linters_explicit = 1
" let g:ale_fixers = {'cpp': ['clangtidy']}
" let g:ale_linters = {'cpp': ['clangd']}
" let g:ale_sign_error = '●'
" let g:ale_sign_warning = '.'
" let g:ale_lint_on_enter = 0
" let g:ale_lint_on_save = 1
" let g:ale_set_loclist = 0
" let g:ale_set_quickfix = 0
" let g:ale_open_list = 1
" let g:ale_keep_list_window_open = 0
" let g:ale_set_highlights = 1
" let g:ale_set_signs = 1
" let g:ale_echo_cursor = 1
" let g:ale_virtualtext_cursor = 0
" let g:ale_cursor_detail = 0
" let g:ale_set_balloons = 0
" :nnoremap <C-]> :ALEGoToDefinition<CR>
" :nnoremap <Leader>w :ALEFindReference -quickfix <bar> :copen<CR>
" " Set this in your vimrc file to disabling highlighting
" highlight ALEWarning ctermbg=lightyellow
" highlight ALEError ctermbg=lightred
highlight clear SignColumn
" highlight! link SignColumn LineNr
let g:gitgutter_set_sign_backgrounds = 1
" make sure we can use aliases in command mode
let $BASH_ENV = "~/.bash_aliases"
"Goyo settings
let g:goyo_width = 81
let g:goyo_height = 999
let g:goyo_margin_top = 0
let g:goyo_margin_bottom = 0
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
set textwidth=80
set wrap
Limelight
" ...
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
set showmode
set showcmd
set scrolloff=3
set textwidth=0
set nowrap
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
command! -range=% Openinbrowser <line1>,<line2> TOhtml | :AsyncRun open %
:command Q q
" This prompt instructs model to be consise in order to be used inline in editor
let s:initial_complete_prompt =<< trim END
>>> system
You are a general assistant.
Answer shortly, consisely and only what you are asked.
Do not provide any explanantion or comments if not requested.
If you answer in a code, do not wrap it in markdown code block.
END
" :AI
" - prompt: optional prepended prompt
" - engine: chat | complete - see how to configure complete engine in the section below
" - options: openai config (see https://platform.openai.com/docs/api-reference/completions)
" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
" - options.request_timeout: request timeout in seconds
" - options.enable_auth: enable authorization using openai key
" - options.token_file_path: override global token configuration
" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
" - ui.paste_mode: use paste mode (see more info in the Notes below)
let g:vim_ai_complete = {
\ "prompt": "",
\ "engine": "chat",
\ "options": {
\ "model": "cognitivecomputations/dolphin3.0-r1-mistral-24b:free",
\ "endpoint_url": "https://openrouter.ai/api/v1/chat/completions",
\ "max_tokens": 0,
\ "max_completion_tokens": 0,
\ "temperature": 0.1,
\ "request_timeout": 20,
\ "stream": 1,
\ "enable_auth": 1,
\ "token_file_path": "~/.config/openrouter.token",
\ "selection_boundary": "#####",
\ "initial_prompt": s:initial_complete_prompt,
\ },
\ "ui": {
\ "paste_mode": 1,
\ },
\}
" :AIEdit
" - prompt: optional prepended prompt
" - engine: chat | complete - see how to configure complete engine in the section below
" - options: openai config (see https://platform.openai.com/docs/api-reference/completions)
" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
" - options.request_timeout: request timeout in seconds
" - options.enable_auth: enable authorization using openai key
" - options.token_file_path: override global token configuration
" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
" - ui.paste_mode: use paste mode (see more info in the Notes below)
let g:vim_ai_edit = {
\ "prompt": "",
\ "engine": "chat",
\ "options": {
\ "model": "cognitivecomputations/dolphin3.0-r1-mistral-24b:free",
\ "endpoint_url": "https://openrouter.ai/api/v1/chat/completions",
\ "max_tokens": 0,
\ "max_completion_tokens": 0,
\ "temperature": 0.1,
\ "request_timeout": 20,
\ "stream": 1,
\ "enable_auth": 1,
\ "token_file_path": "~/.config/openrouter.token",
\ "selection_boundary": "#####",
\ "initial_prompt": s:initial_complete_prompt,
\ },
\ "ui": {
\ "paste_mode": 1,
\ },
\}
" This prompt instructs model to work with syntax highlighting
let s:initial_chat_prompt =<< trim END
>>> system
You are a general assistant.
If you attach a code block add syntax type after ``` to enable syntax highlighting.
END
" :AIChat
" - prompt: optional prepended prompt
" - options: openai config (see https://platform.openai.com/docs/api-reference/chat)
" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
" - options.request_timeout: request timeout in seconds
" - options.enable_auth: enable authorization using openai key
" - options.token_file_path: override global token configuration
" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
" - ui.open_chat_command: preset (preset_below, preset_tab, preset_right) or a custom command
" - ui.populate_options: put [chat-options] to the chat header
" - ui.scratch_buffer_keep_open: re-use scratch buffer within the vim session
" - ui.force_new_chat: force new chat window (used in chat opening roles e.g. `/tab`)
" - ui.paste_mode: use paste mode (see more info in the Notes below)
let g:vim_ai_chat = {
\ "prompt": "",
\ "options": {
\ "model": "cognitivecomputations/dolphin3.0-r1-mistral-24b:free",
\ "endpoint_url": "https://openrouter.ai/api/v1/chat/completions",
\ "max_tokens": 0,
\ "max_completion_tokens": 0,
\ "temperature": 1,
\ "request_timeout": 20,
\ "stream": 1,
\ "enable_auth": 1,
\ "token_file_path": "~/.config/openrouter.token",
\ "selection_boundary": "",
\ "initial_prompt": s:initial_chat_prompt,
\ },
\ "ui": {
\ "open_chat_command": "preset_below",
\ "scratch_buffer_keep_open": 0,
\ "populate_options": 0,
\ "code_syntax_enabled": 1,
\ "force_new_chat": 0,
\ "paste_mode": 1,
\ },
\}