-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
1463 lines (1217 loc) · 43.8 KB
/
init.vim
File metadata and controls
1463 lines (1217 loc) · 43.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
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
" _ _ _
" | | | | | | ( )
" __| | _____ _| |_| |__ _ ____ ___ _ __ ___ _ __ ___
" / _ |/ _ \ \ / / __| |_ \ | _ \ \ / / | _ _ \| __/ __|
" | (_| | __/\ V /| |_| | | | | | | \ V /| | | | | | | | | (__
" \____|\___| \_/ \__|_| |_| |_| |_|\_/ |_|_| |_| |_|_| \___|
"
" Author: Trevor Hartman
" Source: https://github.com/devth/dotfiles
" A part of the pristine dotfile zen garden of @devth
" Plugins {{{
lua <<EOF
vim.g.sexp_enable_insert_mappings = 0
vim.g.sexp_mappings = {}
vim.g.sexp_filetypes = ''
EOF
lua require("config.lazy")
" }}}
" Lua config {{{
lua require("config.theme")
" }}}
" Vim system settings {{{
if !empty(glob("~/.vimrc_private"))
source ~/.vimrc_private
endif
" set foldmethod=marker
set nowrap
set linebreak " for when we do need wrapping
set ttyfast
" don't need this anymore and noice doesn't like it.
" set lazyredraw
set nocompatible
" min number of lines above below cursor
set scrolloff=3
syntax on
filetype plugin indent on
set shell=/opt/homebrew/bin/fish
" set shellcmdflag=-l
set history=1000
set undolevels=1000
set nocursorline nocursorcolumn " vim is slow with these on :/
set termguicolors
imap jj <Esc>
" don't auto resize window on splitting
" set noequalalways
" store tab titles and other stuff in sessions
set sessionoptions+=globals,tabpages
" Splits
set splitbelow splitright
" Persistent undo
let undodir = expand('~/.undo-vim')
if !isdirectory(undodir)
call mkdir(undodir)
endif
set undodir=~/.undo-vim
set undofile
set wildmenu
set wildmode=list:longest
set visualbell
set shortmess=I " hide the startup message
set shortmess+=F " don't show file info when editing
set ic " case insensitive search
set gdefault
set incsearch
set wrapscan " side effect: jumps to result as you type
set hlsearch
set showmatch
set hidden " allow unsaved buffers to exist in the bg
set noautochdir
set norelativenumber
set nonumber
set nobackup
set noswapfile
" Whitespace
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
set backspace=start,indent
set textwidth=80
set linebreak
set wrapmargin=1
" prevent double spaces when joining with C-j
set nojoinspaces
set spelllang=en_us
" whitespace characters
set list listchars=tab:»·,trail:·,nbsp:·
" Show glyphs from vim-devicons
set encoding=utf8
" Configure python
let g:python2_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
" Format options {{{
" Allow wrapping lines at textwidth automatically
set fo+=t
set fo-=l
" Set correct filetypes
autocmd BufNewFile,BufRead Jenkinsfile set syntax=groovy
" pythong's a weirdo: don't wrap
autocmd FileType python set textwidth=0
autocmd FileType python set formatoptions-=t
" }}}
" }}}
" lua vim settings {{{
lua <<EOF
vim.diagnostic.config({
underline = true,
update_in_insert = true,
-- disable virtual_lines since they cause too much layout shift
virtual_lines = false,
virtual_text = {
spacing = 2,
source = "if_many",
prefix = "●",
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
-- prefix = "icons",
},
float = {
border = "rounded",
source = "always",
focusable = false,
style = "minimal",
header = "",
prefix = "",
},
severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "", -- nf-fa-times_circle
[vim.diagnostic.severity.WARN] = "", -- nf-fa-exclamation_triangle
[vim.diagnostic.severity.HINT] = "", -- nf-fa-lightbulb_o
[vim.diagnostic.severity.INFO] = "", -- nf-fa-info_circle
},
},
})
-- Faster CursorHold trigger (default is 4000)
vim.o.updatetime = 300
-- Show full diagnostic info when hovering
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
vim.diagnostic.open_float(nil, { focus = false })
end,
})
EOF
" }}}
" nvim lua default package lookup {{{
lua <<EOF
package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.config/nvim/lua/?.lua"
EOF
" }}}
" Images 3rd/image.nvim {{{
" lua <<EOF
" package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua"
" package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua"
" require("image").setup({})
" EOF
" }}}
" Vim system mappings {{{
" Silent write file
nnoremap <leader>w :silent write<cr>
" Split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Center screen on line
nmap <space> zz
" Navigate wrapped files
nmap j gj
nmap k gk
" Edit / reload .vimrc
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
vmap <leader>sv y:@"<CR>
" Edit .zshrc
nnoremap <leader>ez <C-w><C-v><C-l>:e ~/.zshrc<cr>
" Always open help in vert split
" Disable this because vim-iced uses the help for doc strings
" autocmd FileType help wincmd L
" Clear searches
nnoremap <leader><space> :nohlsearch<cr>
" Tab between braces
nnoremap <tab> %
vnoremap <tab> %
" Show next matched string at eh center of screen
nnoremap n nzz
nnoremap N Nzz
" Yank current file path
nnoremap <leader>cp :let @" = expand("%")<cr>
" Substitute word under cursor
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
" Remove trailing whitespace
nnoremap <leader>aw :%s/\s\+$//<cr>:let @/=''<cr>``
" Remove last character in line
function! RmLastChar()
:s/.$/
endfunction
nnoremap <leader>ax :call RmLastChar()<cr>
vnoremap <leader>ax :call RmLastChar()<cr>
" Toggle Goyo
nnoremap <leader>go :Goyo<cr>
" Tab navigation replacement for tmux
" nnoremap <C-space>l :tabp<cr>
" nnoremap <C-space>c :tabnew<cr>
" nnoremap <C-space>0 1gt
" nnoremap <C-space>1 2gt
" nnoremap <C-space>2 3gt
" nnoremap <C-space>3 4gt
" nnoremap <C-space>4 5gt
" nnoremap <C-space>4 5gt
" nnoremap <C-space>5 6gt
" }}}
" Vim system autocmds {{{
" watch for dir changed
" autocmd DirChanged * echomsg string(v:event)
" turn on spelling for certain files
" autocmd BufRead,BufNewFile *.md setlocal spell complete+=kspell
autocmd BufRead,BufNewFile *.md set cursorline cursorcolumn
autocmd FileType gitcommit setlocal spell complete+=kspell
\ cursorline cursorcolumn
" S-K to pull up dictionary on markdown
autocmd FileType markdown setlocal keywordprg=sdcv
" yaml
autocmd BufRead,BufNewFile *.yaml set cursorline cursorcolumn
" FileType for EJS
autocmd BufNewFile,BufRead *.ejs set ft=json
" FileType for eslint
autocmd BufNewFile,BufRead .eslintrc set ft=json
" }}}
" Vim terminal {{{
highlight TermCursor ctermfg=red guifg=red
lua vim.keymap.set("t", "<C-[>", [[<C-\><C-n>]], { noremap = true, silent = true })
" }}}
" Fold settings {{{
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let clean_line = substitute(line, "{", "", "g")
let clean_line = substitute(clean_line, "\"", "", "g")
let fillcharcount = windowwidth - len(clean_line) - len(foldedlinecount) - len('lines')
return clean_line . '↯' . repeat(" ",fillcharcount) . foldedlinecount . ' lines '
endfunction " }}}
set foldtext=MyFoldText()
set foldlevel=3
" Use marker foldmethod for specific file types
autocmd FileType yaml,vim,zsh,sh,make setlocal foldmethod=marker foldlevel=0
nnoremap z<space> za " easier toggling
" Don't open folds for me when searching
" (might want to be able to toggle this)
set fdo-=search
" }}}
" yaml treesitter {{{
lua << EOF
-- config here if you need it
require'treesitter-context'.setup{
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
}
EOF
" }}}
" Lualine {{{
lua << EOF
-- define function and formatting of the information
local function parrot_status()
local status_info = require("parrot.config").get_status_info()
local status = ""
if status_info.is_chat then
status = status_info.prov.chat.name
else
status = status_info.prov.command.name
end
return string.format("%s(%s)", status, status_info.model)
end
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
-- angles (default)
-- component_separators = { left = '', right = ''},
-- section_separators = { left = '', right = ''},
-- bubbles
-- section_separators = { left = '', right = '' },
-- component_separators = { left = '', right = '' },
-- slants
component_separators = '',
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {'filename'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'mode', 'nvim_treesitter#statusline(90)'},
lualine_x = {'searchcount', 'fileformat', 'filesize', 'filetype'},
lualine_y = { parrot_status, 'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = { parrot_status },
lualine_z = {}
},
tabline = {},
extensions = {'quickfix', 'nvim-tree', 'trouble', 'fzf', 'lazy'}
}
EOF
" }}}
" Aesthetics {{{
" https://github.com/norcalli/nvim-colorizer.lua
lua require'colorizer'.setup()
let g:neosolarized_vertSplitBgTrans = 1
" This must be defined before activating colorscheme
" augroup my_neomake_signs
" au!
" autocmd ColorScheme *
" \ hi NeomakeErrorSign ctermfg=red ctermbg=black |
" \ hi NeomakeWarningSign ctermfg=yellow
" augroup END
" fun! CustomizeDarkColors()
" " " Remove background on vertical splits
" " " Hide the ~ characters at end of files
" " " Customize Folds
" " if &background == 'dark'
" " hi VertSplit ctermbg=0 ctermfg=0 guibg=#FAF2DC
" " hi NonText cterm=NONE gui=NONE guibg=NONE guifg=#FAF2DC ctermbg=0 ctermfg=0
" " hi ColorColumn ctermbg=black
" " hi Folded cterm=bold ctermfg=cyan ctermbg=black
" " hi FoldColumn cterm=reverse
" " hi fmrkr ctermbg=black ctermfg=black
" " else
" " hi NonText ctermbg=7 ctermfg=7
" " hi ColorColumn ctermbg=7
" " hi VertSplit ctermbg=7 ctermfg=7
" " hi fmrkr ctermbg=7 ctermfg=7
" " endif
" endfun
" augroup vimrc
" autocmd!
" autocmd ColorScheme * call CustomizeDarkColors()
" augroup END
" Create syntax fmrkr for folds
autocmd BufRead,BufNewFile * syn match fmrkr '"*{{{\|"*}}}' |
\ syn cluster vimCommentGroup contains=fmrkr
" colorscheme solarized
colorscheme solarized
" set termguicolors " https://github.com/overcache/NeoSolarized
set colorcolumn=80
" default background color - can be toggled
set bg=dark
" Quickly switch between light and dark
nnoremap <leader>bgl :set bg=light<cr>
nnoremap <leader>bgd :set bg=dark<cr>
" controls vertical split pipe, end of buffer
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
" Goyo {{{
let g:goyo_height = "100%"
let g:goyo_width = 94
function! s:goyo_enter()
silent !tmux set status off
" silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
" set scrolloff=999
endfunction
function! s:goyo_leave()
silent !tmux set status on
" silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
" set scrolloff=5
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" }}}
" }}}
" Replace / substitute {{{
" s for substitute
nmap s <plug>(SubversiveSubstitute)
nmap ss <plug>(SubversiveSubstituteLine)
nmap S <plug>(SubversiveSubstituteToEndOfLine)
" https://github.com/svermeulen/vim-subversive
xmap s <plug>(SubversiveSubstitute)
xmap p <plug>(SubversiveSubstitute)
xmap P <plug>(SubversiveSubstitute)
" }}}
"
" TreeSitter {{{
lua <<EOF
-- local ft_to_parser = require("nvim-treesitter.parsers").filetype_to_parsername
-- ft_to_parser.mdx = "markdown"
-- vim.treesitter.language.register('mdx', 'markdown', 'markdown')
vim.filetype.add({
extension = {
gotmpl = 'gotmpl',
},
pattern = {
[".*/templates/.*%.tpl"] = "helm",
[".*/templates/.*%.ya?ml"] = "helm",
["helmfile.*%.ya?ml"] = "helm",
},
})
require'nvim-treesitter.configs'.setup {
ensure_installed = {
'css', 'graphql', 'html', 'javascript', 'lua', 'nix', 'python', 'svelte',
'tsx', 'twig', 'typescript', 'vim', 'vimdoc', 'markdown', 'markdown_inline',
'clojure', 'regex', 'bash',
'git_config', 'gitcommit', 'git_rebase', 'gitignore', 'gitattributes'
},
highlight = {
enable = true
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn", -- set to `false` to disable one of the mappings
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
indent = {
enable = true
},
-- see all config options at
-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects?tab=readme-ov-file#text-objects-select
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
},
lsp_interop = {
enable = true,
border = 'none',
floating_preview_opts = {},
peek_definition_code = {
["<leader>df"] = "@function.outer",
["<leader>dF"] = "@class.outer",
},
},
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- nvim_buf_set_keymap) which plugins like which-key display
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
-- You can also use captures from other query groups like `locals.scm`
["as"] = { query = "@local.scope", query_group = "locals", desc = "Select language scope" },
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = "@function.outer",
["]]"] = { query = "@class.outer", desc = "Next class start" },
--
-- You can use regex matching (i.e. lua pattern) and/or pass a list in a "query" key to group multiple queries.
["]o"] = "@loop.*",
-- ["]o"] = { query = { "@loop.inner", "@loop.outer" } }
--
-- You can pass a query group to use query from `queries/<lang>/<query_group>.scm file in your runtime path.
-- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm.
["]s"] = { query = "@local.scope", query_group = "locals", desc = "Next scope" },
["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" },
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
-- Below will go to either the start or the end, whichever is closer.
-- Use if you want more granular movements
-- Make it even more gradual by adding multiple queries and regex.
-- goto_next = {
-- ["]d"] = "@conditional.outer",
-- },
-- goto_previous = {
-- ["[d"] = "@conditional.outer",
-- }
},
},
}
-- https://github.com/windwp/nvim-ts-autotag?tab=readme-ov-file#setup
require('nvim-ts-autotag').setup({
opts = {
-- Defaults
enable_close = true, -- Auto close tags
enable_rename = true, -- Auto rename pairs of tags
enable_close_on_slash = false -- Auto close on trailing </
},
-- Also override individual filetype configs, these take priority.
-- Empty by default, useful if one of the "opts" global settings
-- doesn't work well in a specific filetype
per_filetype = {
["html"] = {
enable_close = false
}
}
})
-- vim.treesitter.language.register('mdx', 'markdown')
EOF
set foldmethod=expr
set foldexpr = "v:lua.vim.lsp.foldexpr()"
" set foldexpr=nvim_treesitter#foldexpr()
set nofoldenable
set foldlevel=20
" }}}
" DAP {{{
lua << EOF
-- https://github.com/David-Kunz/vim/blob/master/init.lua
local function map(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then options = vim.tbl_extend('force', options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- dap node
local dap = require('dap')
dap.adapters.node2 = {
type = 'executable',
command = 'node',
args = {os.getenv('HOME') .. '/oss/vscode-node-debug2/out/src/nodeDebug.js'},
}
dap.configurations.javascript = {
{
name = 'Launch',
type = 'node2',
request = 'launch',
program = '${file}',
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = 'inspector',
console = 'integratedTerminal',
},
{
-- For this to work you need to make sure the node process is started with the `--inspect` flag.
name = 'Attach to process',
type = 'node2',
request = 'attach',
processId = require'dap.utils'.pick_process,
},
}
dap.defaults.fallback.terminal_win_cmd = '80vsplit new'
vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapBreakpointRejected', {text='🟦', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''})
-- _G.shutDownDapSession = function()
-- local dap = require'dap'
-- dap.terminate()
-- dap.disconnect( { terminateDebuggee = true })
-- dap.close()
-- end
map('n', '<leader>dh', ':lua require"dap".toggle_breakpoint()<CR>')
map('n', '<leader>dH', ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
map('n', '<leader>k', ':lua require"dap".step_out()<CR>')
map('n', "<leader>l", ':lua require"dap".step_into()<CR>')
map('n', '<leader>j', ':lua require"dap".step_over()<CR>')
map('n', '<leader>h', ':lua require"dap".continue()<CR>')
map('n', '<leader>dn', ':lua require"dap".run_to_cursor()<CR>')
map('n', '<leader>dk', ':lua require"dap".up()<CR>zz')
map('n', '<leader>dj', ':lua require"dap".down()<CR>zz')
-- map('n', '<leader>dc', ':lua require"dap".terminate()<CR>')
map('n', '<leader>dr', ':lua require"dap".repl.toggle({}, "vsplit")<CR><C-w>l')
map('n', '<leader>dR', ':lua require"dap".clear_breakpoints()<CR>')
map('n', '<leader>de', ':lua require"dap".set_exception_breakpoints({"all"})<CR>')
map('n', '<leader>da', ':lua require"debugHelper".attach()<CR>')
map('n', '<leader>dA', ':lua require"debugHelper".attachToRemote()<CR>')
map('n', '<leader>di', ':lua require"dap.ui.widgets".hover()<CR>')
map('n', '<leader>d?', ':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)<CR>')
-- nvim-telescope/telescope-dap.nvim
require('telescope').load_extension('dap')
map('n', '<leader>ds', ':Telescope dap frames<CR>')
map('n', '<leader>dc', ':Telescope dap commands<CR>')
map('n', '<leader>dv', ':Telescope dap variables<CR>')
map('n', '<leader>db', ':Telescope dap list_breakpoints<CR>')
-- nvim-telescope/telescope-file-browser.nvim
-- require('telescope').load_extension('file_browser')
-- theHamsta/nvim-dap-virtual-text and mfussenegger/nvim-dap
require('nvim-dap-virtual-text').setup()
-- g.dap_virtual_text = true
-- https://github.com/nvim-telescope/telescope-fzf-native.nvim
require('telescope').load_extension('fzf')
-- https://github.com/nvim-telescope/telescope-media-files.nvim
require('telescope').load_extension('media_files')
-- https://github.com/aaronhallaert/advanced-git-search.nvim#%EF%B8%8F-installation
require("telescope").load_extension("advanced_git_search")
-- pass args to grep https://github.com/nvim-telescope/telescope-live-grep-args.nvim
require("telescope").load_extension("live_grep_args")
-- telescope for code actions
require("telescope").load_extension("ui-select")
-- David-Kunz/jester
-- map('n', '<leader>tt', ':lua require"jester".run({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- map('n', '<leader>t_', ':lua require"jester".run_last({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- map('n', '<leader>tf', ':lua require"jester".run_file({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- -- map('n', '<leader>dd', ':lua require"jester".debug({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- map('n', '<leader>d_', ':lua require"jester".debug_last({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- -- map('n', '<leader>df', ':lua require"jester".debug_file({ path_to_jest = "/opt/homebrew/bin/jest" })<cr>')
-- map('n', '<leader>dq', ':lua require"jester".terminate()<cr>')
EOF
" }}}
" LSP {{{
lua << EOF
local lspconfig = require("lspconfig")
local buf_map = function(bufnr, mode, lhs, rhs, opts)
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts or {
silent = true,
})
end
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- disabled - too slow
-- lspconfig.yamlls.setup {}
-- this replaces lspconfig ts_ls
require("typescript-tools").setup {
settings = {
expose_as_code_action = "all",
jsx_close_tag = {
enable = true,
filetypes = { "javascriptreact", "typescriptreact" },
},
tsserver_file_preferences = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
}
-- python lsp
-- require'lspconfig'.jedi_language_server.setup{}
-- require'lspconfig'.pyright.setup{}
-- require'lspconfig'.ruff.setup{}
-- require'lspconfig'.biome.setup{}
-- require'lspconfig'.sorbet.setup{}
-- require("lspconfig").ruby_lsp.setup{}
vim.lsp.enable('pyright')
vim.lsp.enable('ruff')
vim.lsp.enable('biome')
-- vim.lsp.enable('sorbet')
-- vim.lsp.enable('ruby_lsp')
local on_attach = function(client, bufnr)
-- disabled Wed Sep 17 17:19:33 MDT 2025
-- if you don't miss anything just delete this
-- vim.cmd("command! LspDef lua vim.lsp.buf.definition()")
-- vim.cmd("command! LspFormatting lua vim.lsp.buf.format { timeout_ms = 5000 }")
-- vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()")
-- vim.cmd("command! LspHover lua vim.lsp.buf.hover()")
-- -- vim.cmd("command! LspRename lua vim.lsp.buf.rename()")
-- vim.cmd("command! LspRefs lua vim.lsp.buf.references()")
-- vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()")
-- vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()")
-- vim.cmd("command! LspDiagLine lua vim.diagnostic.open_float()")
-- vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()")
-- -- TODO remove all these and use lsp-wide mappings
-- buf_map(bufnr, "n", "gd", ":LspDef<CR>")
-- -- buf_map(bufnr, "n", "gr", ":LspRename<CR>")
-- buf_map(bufnr, "n", "gl", ":LspRefs<CR>")
-- buf_map(bufnr, "n", "gy", ":LspTypeDef<CR>")
-- -- buf_map(bufnr, "n", "K", ":LspHover<CR>")
-- -- use [d ]d instead
-- -- buf_map(bufnr, "n", "[a", ":LspDiagPrev<CR>")
-- -- buf_map(bufnr, "n", "]a", ":LspDiagNext<CR>")
-- -- buf_map(bufnr, "n", "ga", ":LspCodeAction<CR>")
-- -- buf_map(bufnr, "n", "<Leader>fo", ":LspFormatting<CR>")
-- buf_map(bufnr, "n", "<Leader>a", ":LspDiagLine<CR>")
-- buf_map(bufnr, "i", "<C-x><C-x>", "<cmd> LspSignatureHelp<CR>")
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
-- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead
-- this can be super slow - consider formatting manually instead
-- vim.lsp.buf.formatting_sync()
-- save current view (cursor, scroll, etc.)
local view = vim.fn.winsaveview()
-- join undo block (no new undo step)
pcall(vim.cmd, "silent! undojoin")
-- run formatting
vim.lsp.buf.format({
bufnr = bufnr,
async = false,
timeout_ms = 1000,
})
-- restore view
vim.fn.winrestview(view)
end,
})
end
end
-- replaced null_ls with none-ls following biome's instructions
local null_ls = require("null-ls")
-- use biome (via lsp) instead!
null_ls.setup({
sources = {
-- temp disable these while trying biome:
-- require("none-ls.diagnostics.eslint"),
-- require("none-ls.diagnostics.eslint"),
-- require("none-ls.code_actions.eslint"),
-- use prettier instead of lsp formatting
-- null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.biome,
-- this isn't a valid diagnostic:
-- null_ls.builtins.diagnostics.biome.with({
-- command = "biome", -- Verify this matches your global install
-- args = { "check", "--formatter-enabled=false", "$FILENAME" },
-- }),
null_ls.builtins.formatting.terragrunt_fmt,
-- stylua formatting for Lua
null_ls.builtins.formatting.stylua,
-- ruby (make sure to use the built in bundled gems)
-- this times out. it probably doesn't work with rvm.
-- null_ls.builtins.formatting.rubocop.with({
-- command = "bundle",
-- args = { "exec", "rubocop", "-a", "--stdin", "$FILENAME" },
-- timeout = 9000,
-- }),
-- null_ls.builtins.diagnostics.rubocop
},
on_attach = on_attach,
}
)
-- sort imports automatically
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- pattern = { "*.js", "*.ts", "*.jsx", "*.tsx" },
-- callback = function()
-- vim.lsp.buf.execute_command({
-- command = "biome/organizeImports",
-- arguments = { vim.api.nvim_buf_get_name(0) },
-- })
-- end,
-- })
EOF
" au BufEnter * typescript require'completion'.on_attach()
" }}}
" Completion {{{
" Use <Tab> and <S-Tab> to navigate through popup menu
" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" " Set completeopt to have a better completion experience
" set completeopt=menuone,noinsert,noselect
" " Avoid showing message extra message when using completion
" set shortmess+=c
set completeopt=menu,menuone,noselect
lua <<EOF
-- Setup 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(),
-- Accept currently selected item. Set `select` to `false` to only
-- confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp', priority = 1000 },
{ name = "codeium", priority = 900 },
-- https://www.reddit.com/r/neovim/comments/so4g5e/comment/hw7i5n0/
{ name = "nvim_lsp_signature_help" },
{ name = 'calc' },
{ name = "parrot_completion" },
{ name = "parrot" },
{
name = 'buffer',
option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end
}
},
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (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' }
})
})
EOF