-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.vim
1987 lines (1692 loc) · 64.4 KB
/
init.vim
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
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
set t_Co=256
set nocompatible
" {{{ ---- Bootstrap ----
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
" let s:py2 = expand("$HOME/tools/bin/python2")
" if executable(s:py2)
" let g:autopep8_cmd = expand("$HOME/tools/bin/autopep8")
" let g:python_host_prog = s:py2
" " bin/pip install pynvim
" else
" " echom "tools3/bin/python not installed"
" " let s:py3 = expand("$HOME/tools3/bin/python")
" " if executable(s:py3)
" " let g:autopep8_cmd = expand("$HOME/tools3/bin/autopep8")
" " let g:python3_host_prog = s:py3
" " endif
" endif
function! Identify()
let l:h = hostname()
if match(l:h, 'Lenovo') > -1
return 'laptop'
else
return 'desktop'
endif
endfunction
let g:my_machine = Identify()
let $DISPLAY=':0'
" }}}
" {{{ ---- Load plugins ----
filetype plugin on
filetype plugin indent on
" To reload plugins, after changing here:
" :so %
" :PlugInstall
" To uninstall a plugin:
" remove from below
" call:
" :PlugClean!
" NOTE: Make sure you use single quotes when defining Plug
call plug#begin('~/.vim/nvim-plugged')
" Distraction-free editing; Turn on with :Goyo 80. Turn off with :Goyo!
" Plug 'junegunn/goyo.vim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
endif
endfunction
" The inimitable NerdTree. Locate files in explorer pane with <leader>f
Plug 'preservim/nerdtree'
Plug 'flwyd/nerdtree-harvest'
" Plug 'Xuyuanp/nerdtree-git-plugin'
" Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': ':UpdateRemotePlugins'}
" Plug 'el-iot/buffer-tree-explorer.vim'
" Toggle comments with tcc
Plug 'tomtom/tcomment_vim'
" The :EasyAlign command
Plug 'junegunn/vim-easy-align'
" BufferBye, gives :Bdelete command to delete buffers. Mapped to Q
Plug 'moll/vim-bbye'
" See https://jakobgm.com/posts/vim/git-integration/
" Show git status stull in guter column (next to numbers)
Plug 'airblade/vim-gitgutter'
" Show indent guides
Plug 'Yggdroot/indentLine'
let g:indentLine_fileTypeExclude = ['json', 'markdown', 'rst']
let g:indentLine_setConceal = 0
" Plug 'vimwiki/vimwiki', {'branch': 'dev'}
Plug 'samoshkin/vim-mergetool'
" Modify * to also work with visual selections.
Plug 'nelstrom/vim-visual-star-search'
" Handle multi-file find and replace.
Plug 'mhinz/vim-grepper'
" Lightline colors in status bar
Plug 'itchyny/lightline.vim'
Plug 'mgee/lightline-bufferline' " , {'branch': 'add-ordinal-buffer-numbering'}
" ========== Language Support =========
" ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim
" and Vim 8 while you edit your text files.
Plug 'tiberiuichim/ale', {'branch': 'fix-pnpm'}
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
" Plug 'jose-elias-alvarez/null-ls.nvim'
" Plug 'MunifTanjim/eslint.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'gsuuon/llm.nvim'
" Plug 'huggingface/llm.nvim'
Plug 'heavenshell/vim-jsdoc'
" Plug 'pangloss/vim-javascript'
" Plug 'yuezk/vim-js'
" Plug 'maxmellon/vim-jsx-pretty'
" let g:polyglot_disabled = ['jsx']
Plug 'HerringtonDarkholme/yats.vim'
" Python 'tags' in a tagbar
" Plug 'majutsushi/tagbar'
" Plug 'liuchengxu/vista.vim' " tagbar replacement that uses LSP
Plug 'chrisbra/vim-xml-runtime' " official XML ft plugin
"
" Preview css colors
Plug 'ap/vim-css-color'
" .pug files support
Plug 'digitaltoad/vim-pug'
" Better increment (ctrl+a/ctrl+x) behavior
Plug 'qwertologe/nextval.vim'
" Best color theme evah
Plug 'AlessandroYorba/Alduin'
" Plug 'scheakur/vim-scheakur'
" Git integration, do :Gdiff, :Gblame, :Gremove and more
Plug 'tpope/vim-fugitive'
" Snippets and autocomplete
Plug 'L3MON4D3/LuaSnip', {'tag': 'v2.*', 'do': 'make install_jsregexp'}
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
call plug#end()
" }}}
" ---- Personal preferences ---- {{{
"
" Some of this stuff is lifted from sensible.vim
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
" fix spurious q characters in konsole
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=0
set guicursor=
" syntax sync minlines=20000 " fixes syntax not updating on large files
" set autoindent
" set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
syntax enable
set backspace=indent,eol,start
set backup " backups
set backupskip=/tmp/*,/private/tmp/*
set complete-=i
set completeopt+=preview
set cursorline
set conceallevel=0 " if set higher hides quotes in json files
set display+=lastline
set fillchars=vert:│,fold:━ " this changes characters used for splits and horizontal folding
set foldcolumn=1 " increase size of fold column
set foldlevelstart=0 " most folds opened by default
set foldopen=hor,insert,jump,mark,percent,quickfix,search,tag,undo
set foldenable
set foldmethod=marker " fold based on markers level
" set foldmethod=syntax
set foldlevelstart=1
set formatoptions=tcqrn1 " set autoformat options (think gq). See http://vimdoc.sourceforge.net/htmldoc/change.html#fo-table
set history=1000
set hlsearch " highlight search matches
set laststatus=2
set lazyredraw
set list " show whitespace characters, useful
set listchars=tab:▸\ ,trail:•,extends:>,precedes:<,nbsp:+,eol:¬
set mouse=
set noincsearch " jumps to first match as you type
set noshowmode " already provided by lightline
set nosmartcase
set nosmartindent
set nosmarttab
set nospell
set nowrap " don't wrap, it's annoying
set nrformats-=octal
set number
" set nuw=6 " increase size of gutter column
set nuw=5 " increase size of gutter column
set ruler
set scrolloff=3 " how many lines to bottom cause scrolling
set showcmd
set showmatch
set showtabline=2 " always show the tabline
set sidescrolloff=5
set splitbelow " preferences for where the split happens
set splitright
set termguicolors
set textwidth=79
set ttimeout
set timeoutlen=800
set ttimeoutlen=10
set undofile
set undolevels=200 " undo settings
set novisualbell " annoying screen flash in VIM
set wildmenu
set writebackup
set ff=unix
set expandtab
set tabstop=2 " not liking big tabs
set shiftwidth=2
" set foldenable " this makes the folds closed when file is opened
" set ignorecase " when searching, ignore case if all letters lowercase
" set smartcase " override ignorecase if term has caps
" 'inccommand' shows results while typing a |:substitute| command
if exists('&inccommand')
set inccommand=split " can also do nosplit for inline preview
endif
" clipboard configuration
set clipboard= " unnamedplus "EasyClip + Vim + system clipboard
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
catch
endtry
" }}}
" Autofocus active file when changing buffers
" See https://superuser.com/questions/195022/vim-how-to-synchronize-nerdtree-with-current-opened-tab-file-path
" autocmd BufEnter * if &modifiable | NERDTreeFind | wincmd p | endif
" ---- Custom functions ---- {{{
" strips trailing whitespace at the end of files. this
" is called on buffer write in the autogroup above.
function! <SID>StripTrailingWhitespaces()
" save last search & cursor position
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd filetype nerdtree highlight ' . a:extension . ' guifg=' . a:guifg
exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
" bash execute contents of current buffer and filter it to a new window
command! FW call FilterToNewWindow()
function! FilterToNewWindow()
let TempFile = tempname()
let SaveModified = &modified
exe 'w ' . TempFile
exe '!chmod +x ' . TempFile
let &modified = SaveModified
exe ':e ' . TempFile
exe '%! ' . @%
exe 'w!'
endfunction
" }}}
" ---- Plugin configurations --- {{{
" buftabline configuration
let g:buftabline_numbers = 2 " show buffer position next to each buffer label
" use \1 to go to tab 1
let g:indentLine_char = '│'
let g:indentLine_color_gui = '#111111'
" jump to the other tag with \z
" nnoremap <leader>z :MtaJumpToOtherTag<cr>
" asynchronous lint engine (ale) settings
let g:ale_set_balloons = 0
let g:ale_cursor_detail = 0
let g:ale_virtualtext_cursor = 1
let g:ale_virtualtext_prefix = " ➜ "
let g:ale_python_flake8_executable = expand("$HOME/miniconda3/bin/flake8")
" let g:ale_python_autopep8_executable = expand("$HOME/tools3/bin/autopep8")
" let g:ale_python_black_executable = expand("$HOME/tools3/bin/black")
" let g:ale_python_isort_executable = expand("$HOME/tools3/bin/isort")
" let g:ale_python_pyls_executable = expand("$HOME/tools/bin/pyls")
" let g:ale_javascript_eslint_options = "--no-color"
let g:ale_javascript_eslint_executable = "eslint"
let g:ale_typescript_eslint_executable = "eslint"
" expand("NODE_PATH=project/node_modules project/node_modules/.bin/eslint")
" Given a buffer, return an appropriate working directory for ESLint.
function! g:AleGetCwd(buffer) abort
" ESLint 6 loads plugins/configs/parsers from the project root
" By default, the project root is simply the CWD of the running process.
" https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md
" https://github.com/dense-analysis/ale/issues/2787
"
" If eslint is installed in a directory which contains the buffer, assume
" it is the ESLint project root. Otherwise, use nearest node_modules.
" Note: If node_modules not present yet, can't load local deps anyway.
let l:executables = [
\ '.yarn/sdks/eslint/bin/eslint.js',
\ 'node_modules/.bin/eslint_d',
\ 'node_modules/eslint/bin/eslint.js',
\ 'node_modules/.bin/eslint',
\]
let l:executable = ale#path#FindNearestExecutable(a:buffer, l:executables)
if stridx(l:executable, '.pnpm/') > -1
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
let l:modules_root = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
echom l:modules_root
return l:modules_root
elseif !empty(l:executable)
let l:modules_index = strridx(l:executable, 'node_modules')
let l:modules_root = l:modules_index > -1 ? l:executable[0:l:modules_index - 2] : ''
let l:sdks_index = stridx(l:executable, ale#path#Simplify('.yarn/sdks'))
let l:sdks_root = l:sdks_index > -1 ? l:executable[0:l:sdks_index - 2] : ''
else
let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules')
let l:modules_root = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : ''
let l:sdks_dir = ale#path#FindNearestDirectory(a:buffer, ale#path#Simplify('.yarn/sdks'))
let l:sdks_root = !empty(l:sdks_dir) ? fnamemodify(l:sdks_dir, ':h:h:h') : ''
endif
return strlen(l:modules_root) > strlen(l:sdks_root) ? l:modules_root : l:sdks_root
endfunction
" call ale#linter#Define('typescript', {
" \ 'name': 'eslinttibi',
" \ 'executable': function('ale#handlers#eslint#GetExecutable'),
" \ 'cwd': function('g:AleGetCwd'),
" \ 'command': function('ale#handlers#eslint#GetCommand'),
" \ 'callback': 'ale#handlers#eslint#HandleJSON',
" \})
" \
"'command':
"
" call ale#linter#Define('javascript', {
" \ 'name': 'eslint',
" \ 'output_stream': 'both',
" \ 'executable': function('ale#handlers#eslint#GetExecutable'),
" \ 'command': function('ale#handlers#eslint#GetCommand'),
" \ 'callback': 'ale#handlers#eslint#HandleJSON',
" \})
" \ 'add_blank_lines_for_python_control_statements',
" let g:ale_fixers = {
" \ 'python': [
" \ 'remove_trailing_lines',
" \ 'autopep8',
" \ 'isort',
" \ ],
" \ 'javascript': ['eslint'],
" \ 'css': ['stylelint'],
" \ 'less': ['prettier'],
" \ 'json': ['prettier']
" \}
"
" Available Linters: ['bandit', 'flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'vulture']
" Enabled Linters: ['flake8', 'mypy', 'pylint']
" Suggested Fixers:
" 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements.
" 'autopep8' - Fix PEP8 issues with autopep8.
" 'black' - Fix PEP8 issues with black.
" 'isort' - Sort Python imports with isort.
" 'remove_trailing_lines' - Remove all blank lines at the end of a file.
" 'reorder-python-imports' - Sort Python imports with reorder-python-imports.
" 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
" 'yapf' - Fix Python files with yapf.
" \ 'black',
let g:ale_fixers = {
\ 'python': [
\ 'isort',
\ 'autopep8',
\ 'trim_whitespace',
\ 'remove_trailing_lines',
\ ],
\ 'javascript': ['eslint'],
\ 'typescriptreact': ['eslint'],
\ 'typescript': ['eslint'],
\ 'css': ['prettier', 'stylelint'],
\ 'less': ['prettier', 'stylelint'],
\ 'json': ['prettier']
\}
let g:ale_linters = {
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\ 'typescript': ['eslint'],
\ 'xml': ['xmllint'],
\ 'css': ['stylelint'],
\ 'less': ['stylelint']
\ }
" 'flake8'
" let g:ale_linters_explicit = 1
" let g:ale_fix_on_save = 1
"
" let g:ale_javascript_prettier_options = '--single-quote --trailing-comma all'
" let g:ale_stylelint_options = '--fix'
" let g:ale_linters.python = ['pyls'] " use vim-lsp for python integration
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_column_always = 0
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
let g:ale_sign_error = "X"
let g:ale_sign_warning = "‼"
"
let g:NERDTreeShowHidden=1
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ "Unknown" : "?"
\ }
let NERDTreeIgnore = ['\.pyc$', '\.pyo$', '\.egg-info$', '\~$', '\.git$', '\.eggs', '__pycache__', '\.\~']
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" npm i -g pyright
" npm install -g typescript typescript-language-server
" Lua configuration. I don't do, yet, init.lua
lua << EOF
require("mason").setup()
require("mason-lspconfig").setup()
local llm = require "llm"
local llamacpp = require "llm.providers.llamacpp"
local codellama = require "llm.providers.llamacpp"
local extract = require "llm.prompts.extract"
local starters = require "llm.prompts.starters"
-- See https://github.com/JoseConseco/nvim_config/blob/master/lua/nv_llm-nvim/init.lua
local defaultOptions = {
server_start = {
command = '/mnt/docker/work/sd/llama.cpp/server',
args = {
'-m', '/mnt/docker/work/sd/text-generation-webui/models/openassistant-llama2-13b-orca-8k-3319.Q4_K_M.gguf',
'-c', 4096,
'-ngl', 22
}
}
}
require('llm').setup({
hl_group = "Substitute",
-- prompts = util.module.autoload "prompt_library",
default_prompt = llamacpp.default_prompt,
join_undo = true,
prompts = {
-- ask = starters.ask,
llamacpp = starters.llamacpp,
codellama = starters.codellama,
modify = {
provider = llamacpp,
params = { temperature = 0.4, },
options = {
temperature = 0.5, -- Adjust the randomness of the generated text (default: 0.8).
repeat_penalty = 1.0, -- Control the repetition of token sequences in the generated text (default: 1.1)
seed = -1, -- Set the random number generator (RNG) seed (default: -1, -1 = random seed)
},
mode = llm.mode.INSERT_OR_REPLACE,
-- mode = llm.mode.BUFFER,
builder = function(input)
return function(build)
vim.ui.input(
{ prompt = 'Action to perform on code: ' },
function(user_input)
if user_input == nil then return end
local final_prompt = ''
if #user_input > 0 then
final_prompt =
[===[ <s>[INST]<<SYS>>\nHelp USER by updating his code wrapped inside [CODE] tag.\nUSER:]===] .. user_input .. "\n[CODE]\n" .. input .. "\n[/CODE]\n [/INST]"
else
return
end
print(final_prompt)
build({
prompt = final_prompt
})
end)
end
end,
transform = extract.markdown_code,
},
-- ask = {
-- provider = llamacpp,
-- params = { temperature = 0.7, },
-- mode = llm.mode.INSERT,
-- -- options = defaultOptions,
-- builder = function(input)
--
-- return function(build)
-- vim.ui.input(
-- { prompt = 'Instruction: ' },
-- function(user_input)
-- if user_input == nil then return end
--
-- local final_prompt = ''
-- if #user_input > 0 then
--
-- -- [===[<s>[INST]<<SYS>>\nWrite code to solve the following coding problem. Please wrap your code answer using ```. Output only the code.\n<</SYS>>.]==]
--
-- final_prompt =
-- " <s>[INST]<<SYS>>Write code to solve the following coding problem that obeys the constraints and passes the example test cases. Please wrap your code answer using ```.<<SYS>>"
-- .. user_input .. "\n[/INST]\n"
--
-- else
-- return
-- end
--
-- build({
-- prompt = final_prompt
-- })
-- end)
-- end
-- end,
-- transform = extract.markdown_code,
-- },
-- commit = {
-- provider = codellama,
-- mode = llm.mode.INSERT,
-- builder = function()
-- local git_diff = vim.fn.system {'git', 'diff', '--staged'}
--
-- if not git_diff:match('^diff') then
-- vim.notify(vim.fn.system('git status'), vim.log.levels.ERROR)
-- return
-- end
--
-- return {
-- messages = {
-- {
-- role = 'user',
-- content = 'Write a terse commit message according to the Conventional Commits specification. Try to stay below 80 characters total. Staged git diff: ```\n' .. git_diff .. '\n```'
-- }
-- }
-- }
-- end,
-- },
-- ['llama'] = {
-- provider = codellama,
-- -- options = defaultOptions,
-- builder = function(input, context)
-- return {
-- prompt = llamacpp.llama_2_user_prompt({
-- user = context.args or '',
-- message = input
-- })
-- }
-- end
-- }
}
})
-- local null_ls = require("null-ls")
-- local eslint = require("eslint")
--
-- null_ls.setup()
--
-- eslint.setup({
-- bin = 'eslint', -- or `eslint_d`
-- code_actions = {
-- enable = true,
-- apply_on_save = {
-- enable = true,
-- types = { "directive", "problem", "suggestion", "layout" },
-- },
-- disable_rule_comment = {
-- enable = true,
-- location = "separate_line", -- or `same_line`
-- },
-- },
-- diagnostics = {
-- enable = true,
-- report_unused_disable_directives = false,
-- run_on = "type", -- or `save`
-- },
-- })
-- Set up nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lua" },
{ name = "path" },
-- { name = 'vsnip' }, -- For vsnip users.
{ name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- require('lspconfig')['tsserver'].setup {
-- capabilities = capabilities
-- }
-- require('lspconfig')[pyright].setup {
-- capabilities = capabilities
-- }
local lspconfig = require('lspconfig')
lspconfig.pyright.setup {}
lspconfig.tsserver.setup {
capabilities = capabilities
}
lspconfig.rust_analyzer.setup {
-- Server-specific settings. See `:help lspconfig-setup`
settings = {
['rust-analyzer'] = {},
},
}
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
EOF
" Ensure you have installed some decent font to show these pretty symbols, then
" you can enable icon for the kind.
" let g:vista_icon_indent = ["╰▸ ", "├▸ "]
" let g:vista#renderer#enable_icon = 1
" " TODO: need to fix the default icon
" let g:vista#renderer#icons = {
" \ "default": "\uf794",
" \ "function": "\uf794",
" \ "variable": "\uf71b",
" \ }
" }}}
" ---- File type based settings ---- {{{
"
"
au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
":%!~/tools3/bin/zpretty -z
augroup configgroup
autocmd!
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" autocmd BufEnter * :syntax sync fromstart
autocmd BufNewFile,BufRead *.pt setlocal filetype=xml
autocmd BufNewFile,BufRead *.zpt setlocal filetype=xml
autocmd BufNewFile,BufRead *.zcml setlocal filetype=xml
autocmd BufNewFile,BufRead *.overrides setlocal filetype=less
autocmd BufNewFile,BufRead *.variables setlocal filetype=less
" autocmd BufWritePre *.{pt,zpt} :call ZPT_format()
" autocmd BufWritePre *.zcml :call ZCML_format()
autocmd BufNewFile,BufRead *.overrides setlocal filetype=less
autocmd BufNewFile,BufRead *.jsx setlocal filetype=javascript
autocmd BufNewFile,BufRead *.js setlocal filetype=javascript
autocmd BufNewFile,BufRead *.vue setlocal filetype=html
autocmd BufNewFile,BufRead *.tag setlocal filetype=html
autocmd BufNewFile,BufRead *.json setlocal conceallevel=0
autocmd BufNewFile,BufRead *.jsonc setlocal conceallevel=0
autocmd Filetype json setlocal conceallevel=0
autocmd Filetype jsonc setlocal conceallevel=0
autocmd Filetype html setlocal ts=2 sw=2 sts=2 expandtab
autocmd Filetype pug setlocal ts=4 sw=4 sts=4 expandtab
autocmd Filetype javascript setlocal ts=2 sw=2 sts=2 expandtab
autocmd Filetype css setlocal ts=2 sw=2 sts=2 expandtab
autocmd Filetype xquery setlocal ts=4 sw=4 sts=4 expandtab
" autocmd Filetype vue setlocal ts=2 sw=2 sts=2 expandtab
" autocmd Filetype riot setlocal ts=2 sw=2 sts=0 expandtab
autocmd FileType python setlocal commentstring=#\ %s
autocmd Filetype python setlocal tabstop=4 shiftwidth=4 expandtab colorcolumn=89
autocmd FileType python highlight Excess ctermbg=DarkGrey guibg=Black
autocmd FileType python match Excess /\%120v.*/
autocmd FileType python setlocal nowrap
autocmd FileType python setlocal textwidth=89
autocmd FileType python setlocal foldlevel=99
autocmd FileType markdown setlocal conceallevel=0
" autocmd Filetype python nnoremap <buffer> <silent> <C-K> :LspPreviousError<CR>
" autocmd Filetype python nnoremap <buffer> <silent> <C-J> :LspNextError<CR>
" autocmd VimEnter *.py nested TagbarOpen
autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
autocmd FileType rst setlocal wrap
autocmd FileType rst setlocal textwidth=79
autocmd Filetype rst setlocal ts=4 sw=4 sts=4 expandtab
augroup END
augroup alestatusupdate
autocmd!
autocmd BufEnter,BufRead * call ale#Queue(0)
autocmd User ALELint call lightline#update()
augroup END
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
:call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
:call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
:call NERDTreeHighlightFile('vim', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
:call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
:call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
:call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
:call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
:call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
" }}}
" ---- Lightline configuration ---- {{{
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ ['darkestgreen', 'brightgreen', 'bold'], ['white', 'gray4'] ]
let s:p.normal.right = [ ['gray5', 'gray10'], ['gray9', 'gray4'], ['gray8', 'gray2'] ]
let s:p.inactive.right = [ ['gray1', 'gray5'], ['gray4', 'gray1'], ['gray4', 'gray0'] ]
let s:p.inactive.left = s:p.inactive.right[1:]
let s:p.insert.left = [ ['darkestcyan', 'white', 'bold'], ['white', 'darkblue'] ]
let s:p.insert.right = [ [ 'darkestcyan', 'mediumcyan' ], [ 'mediumcyan', 'darkblue' ], [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.left = [ ['white', 'brightred', 'bold'], ['white', 'gray4'] ]
let s:p.visual.left = [ ['darkred', 'brightorange', 'bold'], ['white', 'gray4'] ]
let s:p.normal.middle = [ [ 'gray7', 'gray2' ] ]
let s:p.insert.middle = [ [ 'mediumcyan', 'darkestblue' ] ]
let s:p.replace.middle = s:p.normal.middle
let s:p.replace.right = s:p.normal.right
let s:p.tabline.left = [ [ 'gray9', 'gray4' ] ]
let s:p.tabline.tabsel = [ [ 'gray9', 'gray1' ] ]
" let s:p.tabline.middle = [ [ 'gray2', '#0b2828' ] ]
" let s:p.tabline.middle = [ [ 'gray2', 'gray8' ] ]
let s:p.tabline.middle = [ [ 'gray2', '#221616' ] ]
let s:p.tabline.right = [ [ 'gray9', 'gray3' ] ]
let s:p.normal.error = [ [ 'gray9', 'brightestred' ] ]
let s:p.normal.warning = [ [ 'gray1', 'yellow' ] ]
let g:lightline#colorscheme#farlight#palette = lightline#colorscheme#fill(s:p)
let g:lightline#bufferline#show_number = 1
let g:lightline#bufferline#shorten_path = 1
let g:lightline#bufferline#unnamed = '[...]'
let g:lightline#bufferline#show_number = 2
let g:lightline#bufferline#filename_modifier = ':t' " only show filename. See :help filename-modifiers for more options
" components are name:function to call
" use the active: left/right lists to control what shows where
let g:lightline = {
\ 'colorscheme': 'farlight',
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' },
\ 'tabline': {'left': [['buffers']], 'right': [['close']]},
\ 'active': {
\ 'left': [[ 'mode', 'paste', 'alestatus'], ['fugitive', 'filename']],
\ 'right': [['percent'], ['lineinfo'], ['bufsettings'], ['method']]
\ },
\ 'component_function': {
\ 'modified': 'LightLineModified',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'filetype': 'LightLineFiletype',
\ 'fileformat': 'LightLineFileformat',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'bufsettings': 'LightLineBufSettings',
\ 'cocstatus': 'coc#status',
\ 'method': 'NearestMethodOrFunction',
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers',
\ 'alestatus': 'g:LinterStatus'
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"":""}',
\ },
\ 'component_type': {
\ 'buffers': 'tabsel' ,
\ 'alestatus': 'error'
\ }
\ }
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '']
function! g:LightLineAleStatus()