-
Notifications
You must be signed in to change notification settings - Fork 44
/
init.lua
1097 lines (1017 loc) · 38.3 KB
/
init.lua
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
-- vim.cmd("set shell=/bin/zsh")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none", "--single-branch",
"https://github.com/folke/lazy.nvim.git", lazypath
})
end
vim.opt.runtimepath:prepend(lazypath)
local cmd = vim.cmd
local g = vim.g
local opt = vim.opt
g.mapleader = " "
require('lazy').setup({
-- {
-- 'folke/tokyonight.nvim',
-- priority = 1000,
-- config = function()
-- require('tokyonight').setup({
-- styles = {functions = 'bold', keywords = 'italic'}
-- })
-- -- vim.cmd.colorscheme("tokyonight")
-- -- vim.cmd.colorscheme("tokyonight-day")
-- end
-- },
'mhartington/formatter.nvim', -- use 'neovim/nvim-lspconfig',
{'nvim-treesitter/nvim-treesitter', build = ':TSUpdate'},
'nvim-telescope/telescope.nvim',
-- {
-- "nvim-telescope/telescope-frecency.nvim",
-- config = function()
-- require("telescope").load_extension "frecency"
-- end,
-- dependencies = {"kkharji/sqlite.lua"}
-- },
'nvim-lua/plenary.nvim',
'github/copilot.vim',
'nvim-lua/popup.nvim',
'sindrets/diffview.nvim',
{
'echasnovski/mini.icons',
version = false,
config = function() require('mini.icons').setup() end
},
-- { 'echasnovski/mini.diff' },
'lewis6991/gitsigns.nvim',
'nvim-telescope/telescope-dap.nvim',
-- 'theHamsta/nvim-dap-virtual-text',
-- 'ryanoasis/vim-devicons',
'David-Kunz/jester',
{
'David-Kunz/gen.nvim',
dev = true,
opts = {
model = 'llama3:instruct',
display_mode = "split"
-- model = 'wizardlm2',
-- model = 'dolphin-mixtral:8x7b-v2.5-q3_K_S',
-- model = 'openhermes2.5-mistral',
-- show_model = true,
-- show_prompt = true,
-- start_up = function() print('start up') end,
-- display_mode = 'vsplit',
-- debug = 'true'
}
},
-- {'David-Kunz/markid', dev = true},
-- 'David-Kunz/spotlight',
-- {'nvim-tree/nvim-tree.lua', dependencies = {'nvim-tree/nvim-web-devicons'}},
-- {'echasnovski/mini.base16', version = '*'}
'David-Kunz/treesitter-unit', -- use 'David-Kunz/ts-quickfix',
-- 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/nvim-cmp',
-- 'David-Kunz/cmp-npm', 'marko-cerovac/material.nvim',
'mfussenegger/nvim-dap', -- 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip',
'voldikss/vim-floaterm',
{'rcarriga/nvim-dap-ui', dependencies = {"nvim-neotest/nvim-nio"}},
-- use 'ldelossa/litee.nvim',
-- use 'ldelossa/gh.nvim',
'nvim-telescope/telescope-ui-select.nvim', -- 'nvim-treesitter/playground',
-- 'norcalli/nvim-colorizer.lua',
'mxsdev/nvim-dap-vscode-js',
"microsoft/vscode-js-debug",
'Marskey/telescope-sg',
-- lazy = true,
build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && rm -rf out && mv dist out",
{
"microsoft/vscode-node-debug2",
-- lazy = true,
build = "npm install && NODE_OPTIONS=--no-experimental-fetch npm run build"
}, -- use {
-- 'ggandor/leap.nvim',
-- config = function() require('leap').add_default_mappings() end
-- }
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
-- { 'echasnovski/mini-git' },
{
'echasnovski/mini.completion',
version = false,
config = function() require('mini.completion').setup() end
},
-- {
-- 'echasnovski/mini.comment',
-- version = false,
-- config = function() require('mini.comment').setup() end
-- },
{
'echasnovski/mini.files',
version = false,
config = function()
require('mini.files').setup({mappings = {go_in_plus = 'l'}})
end
}
-- {
-- 'echasnovski/mini.base16',
-- version = false,
-- config = function()
-- require('mini.base16').setup({
-- palette = {
-- base00 = "#181818",
-- base01 = "#282828",
-- base02 = "#383838",
-- base03 = "#585858",
-- base04 = "#b8b8b8",
-- base05 = "#d8d8d8",
-- base06 = "#e8e8e8",
-- base07 = "#f8f8f8",
-- base08 = "#ab4642",
-- base09 = "#dc9656",
-- base0A = "#f7ca88",
-- base0B = "#a1b56c",
-- base0C = "#86c1b9",
-- base0D = "#7cafc2",
-- base0E = "#ba8baf",
-- base0F = "#a16946"
-- }
-- })
-- end
-- }
-- {
-- 'Exafunction/codeium.vim',
-- }
}, {dev = {path = "/Users/d065023/projects/nvim"}})
-- vim.g.codeium_enabled = false
-- vim.g.codeium_disable_bindings = true
-- vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true })
-- vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true })
-- vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true })
-- vim.keymap.set('i', '<c-cr>', function() return vim.fn['codeium#Accept']() end, { expr = true })
-- require('packer').startup(function(use)end)
-- use 'wbthomason/packer.nvim'
-- use 'tpope/vim-commentary'
-- use 'mhartington/formatter.nvim'
-- -- use 'neovim/nvim-lspconfig'
-- use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
-- use 'nvim-telescope/telescope.nvim'
-- use 'nvim-lua/plenary.nvim'
-- use 'nvim-lua/popup.nvim'
-- use 'lewis6991/gitsigns.nvim'
-- use 'nvim-telescope/telescope-dap.nvim'
-- use 'theHamsta/nvim-dap-virtual-text'
-- use 'ryanoasis/vim-devicons'
-- use 'David-Kunz/jester'
-- use 'David-Kunz/markid'
-- use 'David-Kunz/spotlight'
-- use {'nvim-tree/nvim-tree.lua', requires = {'nvim-tree/nvim-web-devicons'}}
-- use 'David-Kunz/treesitter-unit'
-- -- use 'David-Kunz/ts-quickfix'
-- use 'hrsh7th/cmp-nvim-lsp'
-- use 'hrsh7th/cmp-buffer'
-- use 'hrsh7th/nvim-cmp'
-- use 'David-Kunz/cmp-npm'
-- use 'marko-cerovac/material.nvim'
-- use 'mfussenegger/nvim-dap'
-- use 'L3MON4D3/LuaSnip'
-- use 'saadparwaiz1/cmp_luasnip'
-- use 'voldikss/vim-floaterm'
-- use 'rcarriga/nvim-dap-ui'
-- -- use 'ldelossa/litee.nvim'
-- -- use 'ldelossa/gh.nvim'
-- use 'nvim-telescope/telescope-ui-select.nvim'
-- use 'folke/tokyonight.nvim'
-- use 'nvim-treesitter/playground'
-- use 'norcalli/nvim-colorizer.lua'
-- use 'mxsdev/nvim-dap-vscode-js'
-- use {
-- "microsoft/vscode-js-debug",
-- opt = true,
-- run = "npm install --legacy-peer-deps && npm run compile"
-- }
-- use {
-- "microsoft/vscode-node-debug2",
-- opt = true,
-- run = "npm install && NODE_OPTIONS=--no-experimental-fetch npm run build"
-- }
-- -- use {
-- -- 'ggandor/leap.nvim',
-- -- config = function() require('leap').add_default_mappings() end
-- -- }
-- use {
-- "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim",
-- "neovim/nvim-lspconfig"
-- }
-- end)
-- default options
opt.completeopt = {'menu', 'menuone', 'noselect'}
opt.laststatus = 3
opt.mouse = 'a'
opt.splitright = true
opt.splitbelow = true
opt.expandtab = true
opt.tabstop = 2
opt.shiftwidth = 2
opt.number = true
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
-- opt.so = 10
-- opt.relativenumber = true
vim.cmd('set nonumber')
vim.cmd('set norelativenumber')
-- set diffopt+=vertical " starts diff mode in vertical split
opt.cmdheight = 1
opt.ls = 0
-- set shortmess+=c " don't need to press enter so often
opt.signcolumn = 'yes'
opt.updatetime = 520
opt.undofile = true
cmd('filetype plugin on')
opt.backup = false
g.netrw_banner = false
g.netrw_liststyle = 3
g.markdown_fenced_languages = {'javascript', 'js=javascript', 'json=javascript'}
-- opt.path:append({ "**" })
vim.cmd([[set path=$PWD/**]])
vim.keymap.set('n', '<leader>v', ':e $MYVIMRC<CR>')
vim.opt.statusline = "%F Line:%l"
-- require('mini.diff').setup()
-- require('mini.git').setup()
vim.keymap.set('n', '<leader>hd',
function() require('mini.diff').toggle_overlay() end)
-- lewis6991/gitsigns.nvim
function diffThisBranch()
local branch = vim.fn.input("Branch: ", "")
require"gitsigns".diffthis(branch)
end
require('gitsigns').setup({
current_line_blame = true,
on_attach = function(bufnr)
-- Navigation
-- vim.keymap.set('n', ']c', "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", {expr=true})
-- vim.keymap.set('n', '[c', "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", {expr=true})
vim.keymap.set('n', ']c', ':Gitsigns next_hunk<CR>')
vim.keymap.set('n', '[c', ':Gitsigns prev_hunk<CR>')
-- Actions
vim.keymap.set('n', '<leader>hs', ':Gitsigns stage_hunk<CR>')
vim.keymap.set('v', '<leader>hs', ':Gitsigns stage_hunk<CR>')
vim.keymap.set('n', '<leader>hr', ':Gitsigns reset_hunk<CR>')
vim.keymap.set('v', '<leader>hr', ':Gitsigns reset_hunk<CR>')
vim.keymap.set('n', '<leader>hS', '<cmd>Gitsigns stage_buffer<CR>')
vim.keymap.set('n', '<leader>hu', '<cmd>Gitsigns undo_stage_hunk<CR>')
vim.keymap.set('n', '<leader>hR', '<cmd>Gitsigns reset_buffer<CR>')
vim.keymap.set('n', '<leader>hp', '<cmd>Gitsigns preview_hunk<CR>')
vim.keymap.set('n', '<leader>hb', function()
require"gitsigns".blame_line {full = true}
end)
vim.keymap.set('n', '<leader>tb',
'<cmd>Gitsigns toggle_current_line_blame<CR>')
vim.keymap.set('n', '<leader>hd', '<cmd>Gitsigns diffthis<CR>')
vim.keymap.set('n', '<leader>hD',
function() require"gitsigns".diffthis("~") end)
vim.keymap.set('n', '<leader>hm',
function() require"gitsigns".diffthis("main") end)
vim.keymap.set('n', '<leader>hM', diffThisBranch)
vim.keymap.set('n', '<leader>td', '<cmd>Gitsigns toggle_deleted<CR>')
-- Text object
vim.keymap.set('o', 'ih', ':<C-U>Gitsigns select_hunk<CR>')
vim.keymap.set('x', 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
})
-- sbdchd/neoformat
vim.keymap.set('n', '<leader>F', ':Format<CR>')
require('formatter').setup({
logging = false,
filetype = {
javascript = {
-- prettierd
function()
return {
exe = "prettierd",
args = {vim.api.nvim_buf_get_name(0)},
stdin = true
}
end
},
typescript = {
-- prettierd
function()
return {
exe = "prettierd",
args = {vim.api.nvim_buf_get_name(0)},
stdin = true
}
end
},
json = {
-- prettierd
function()
return {
exe = "prettierd",
args = {vim.api.nvim_buf_get_name(0)},
stdin = true
}
end
},
rust = {function() return {exe = "rustfmt", stdin = true} end},
lua = {function() return {exe = "lua-format", stdin = true} end},
sql = {
-- prettierd
function()
return {
exe = "sql-formatter",
args = {vim.api.nvim_buf_get_name(0)},
stdin = true
}
end
}
}
})
local telescope_actions = require("telescope.actions.set")
local fixfolds = {
hidden = true,
attach_mappings = function(_)
telescope_actions.select:enhance({
post = function() vim.cmd(":normal! zx") end
})
return true
end
}
local actions = require("telescope.actions")
require('telescope').setup {
pickers = {
buffers = fixfolds,
find_files = fixfolds,
git_files = fixfolds,
grep_string = fixfolds,
live_grep = fixfolds,
oldfiles = fixfolds
},
extensions = {
ast_grep = {
command = {"sg", "--json=stream"}, -- must have --json=stream
grep_open_files = false, -- search in opened files
lang = nil -- string value, specify language for ast-grep `nil` for default
}
}
}
-- nvim-telescope/telescope.nvim
_G.telescope_find_files_in_path = function(path)
local _path = path or vim.fn.input("Dir: ", "", "dir")
require("telescope.builtin").find_files({search_dirs = {_path}})
end
_G.telescope_live_grep_in_path = function(path)
local _path = path or vim.fn.input("Dir: ", "", "dir")
require("telescope.builtin").live_grep({search_dirs = {_path}})
end
_G.telescope_files_or_git_files = function()
local utils = require('telescope.utils')
local builtin = require('telescope.builtin')
local _, ret, _ = utils.get_os_command_output({
'git', 'rev-parse', '--is-inside-work-tree'
})
if ret == 0 then
builtin.git_files()
else
builtin.find_files()
end
end
vim.keymap.set('n', '<leader>fD', function() telescope_live_grep_in_path() end)
-- vim.keymap.set('n', '<leader><space>',
-- function() telescope_files_or_git_files() end)
vim.keymap.set('n', '<leader>fd', function() telescope_find_files_in_path() end)
vim.keymap.set('n', '<leader>ft',
function() telescope_find_files_in_path("./tests") end)
vim.keymap.set('n', '<leader>fc', function()
telescope_find_files_in_path("./node_modules/@sap/cds")
end)
vim.keymap.set('n', '<leader>fC', function()
telescope_live_grep_in_path("./node_modules/@sap/cds")
end)
vim.keymap.set('n', '<leader>ft', ':Telescope ast_grep<CR>')
vim.keymap.set('n', '<leader>fT',
function() telescope_live_grep_in_path("./tests") end)
vim.keymap.set('n', '<leader>ff', ':Telescope live_grep<CR>')
-- vim.keymap.set('n', '<leader>fo', ':Telescope file_browser<CR>')
vim.keymap.set('n', '<leader>fn', ':Telescope find_files<CR>')
vim.keymap.set('n', '<leader>fr', ':Telescope resume<CR>')
vim.keymap.set('n', '<leader>fG', ':Telescope git_branches<CR>')
vim.keymap.set('n', '<leader>fg', ':Telescope git_status<CR>')
vim.keymap.set('n', '<c-\\>', ':Telescope buffers<CR>')
vim.keymap.set('n', '<leader>fs', ':Telescope lsp_document_symbols<CR>')
vim.keymap
.set('n', '<leader>fw', ':Telescope lsp_dynamic_workspace_symbols<CR>')
vim.keymap.set('n', '<leader>FF', ':Telescope grep_string<CR>')
vim.keymap.set('n', '<leader><space>',
function() telescope_files_or_git_files() end)
-- vim.keymap.set('n', '<leader><space>', ':Telescope frecency workspace=CWD<CR>')
vim.keymap.set('n', '<leader>fy', ':let @"=expand("%")<CR>')
-- David-Kunz/cmp-npm
-- require('cmp-npm').setup({only_latest_version = true})
vim.keymap.set('n', 'gd', function() vim.lsp.buf.definition() end)
vim.keymap.set('n', 'gi', function() vim.lsp.buf.implementation() end)
vim.keymap.set('n', 'gD', function() vim.lsp.buf.implementation() end)
vim.keymap.set('n', '<c-k>', function() vim.lsp.buf.signature_help() end)
vim.keymap.set('n', 'gr', function() vim.lsp.buf.references() end)
vim.keymap.set('n', 'gR', function() vim.lsp.buf.rename() end)
vim.keymap.set('n', 'ga', function() vim.lsp.buf.code_action() end)
vim.keymap.set('n', 'ge', function() vim.diagnostic.goto_next() end)
vim.keymap.set('n', 'gE', function() vim.diagnostic.goto_prev() end)
vim.keymap.set('n', 'gA', ':Telescope lsp_range_code_actions<CR>')
-- -- CDS
-- cmd([[
-- augroup MyCDSCode
-- autocmd!
-- autocmd BufReadPre,FileReadPre *.cds set ft=cds
-- augroup END
-- ]])
--
-- DISABLE FOR NOW
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'
if not configs.sapcds_lsp then
configs.sapcds_lsp = {
default_config = {
cmd = {
vim.fn.expand(
"/Users/d065023/apps/cds-lsp/node_modules/.bin/cds-lsp"),
'--stdio'
},
filetypes = {'cds'},
root_dir = lspconfig.util.root_pattern('.git', 'package.json'),
settings = {}
}
}
end
if lspconfig.sapcds_lsp.setup then
lspconfig.sapcds_lsp.setup {
-- capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
}
end
vim.keymap.set('n', '<leader><esc><esc>', ':tabclose<CR>')
-- vim.g.material_style = "darker"
-- vim.cmd 'colorscheme material'
vim.opt.fillchars = {
horiz = '█',
horizup = '█',
horizdown = '█',
vert = '█',
vertleft = '█',
vertright = '█',
verthoriz = '█'
}
vim.g.floaterm_width = 0.95
vim.g.floaterm_height = 0.95
vim.keymap.set('n', '<leader>g', ':FloatermNew lazygit<CR>')
-- cmd('set foldmethod=indent')
-- cmd('set foldmethod=expr')
-- cmd('set foldexpr=nvim_treesitter#foldexpr()')
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.keymap.set('n', '<leader>n', ':tabe ~/tmp/notes.md<CR>')
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.cds = {
install_info = {
-- local path or git repo
-- url = "~/apps/tree-sitter-cds",
url = "/Users/d065023/apps/tree-sitter-cds",
files = {"src/parser.c", "src/scanner.c"}
},
filetype = "cds",
-- additional filetypes that use this parser
used_by = {"cdl", "hdbcds"}
}
-- require('markid')
require'nvim-treesitter.configs'.setup {
highlight = {enable = true},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<CR>',
node_incremental = '<CR>',
node_decremental = '<S-CR>'
}
}
-- markid = {enable = true}
}
-- mxsdev/nvim-dap-vscode-js
require('dap-vscode-js').setup({
debugger_path = os.getenv('HOME') ..
'/.local/share/nvim/lazy/vscode-js-debug',
adapters = {
'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal',
'pwa-extensionHost'
}
})
-- require("dap-vscode-js").setup({
-- adapters = {
-- 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal',
-- 'pwa-extensionHost'
-- }
-- })
-- mfussenegger/nvim-dap
local dap = require('dap')
dap.adapters.node2 = {
type = 'executable',
command = 'node',
args = {
os.getenv('HOME') ..
'/.local/share/nvim/lazy/vscode-node-debug2/out/src/nodeDebug.js'
}
}
-- require('dap').set_log_level('INFO')
dap.defaults.fallback.terminal_win_cmd = '20split 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 = ''})
vim.keymap.set('n', '<leader>dh',
function() require"dap".toggle_breakpoint() end)
vim.keymap.set('n', '<leader>dH',
":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
vim.keymap.set({'n', 't'}, '<A-k>', function() require"dap".step_out() end)
vim.keymap.set({'n', 't'}, "<A-l>", function() require"dap".step_into() end)
vim.keymap.set({'n', 't'}, '<A-j>', function() require"dap".step_over() end)
vim.keymap.set({'n', 't'}, '<A-h>', function() require"dap".continue() end)
vim.keymap.set('n', '<leader>dn', function() require"dap".run_to_cursor() end)
vim.keymap.set('n', '<leader>dc', function() require"dap".terminate() end)
vim.keymap.set('n', '<leader>dR',
function() require"dap".clear_breakpoints() end)
vim.keymap.set('n', '<leader>de',
function() require"dap".set_exception_breakpoints({"all"}) end)
vim.keymap.set('n', '<leader>da', function() require"debugHelper".attach() end)
vim.keymap.set('n', '<leader>dA',
function() require"debugHelper".attachToRemote() end)
vim.keymap
.set('n', '<leader>di', function() require"dap.ui.widgets".hover() end)
vim.keymap.set('n', '<leader>d?', function()
local widgets = require "dap.ui.widgets";
widgets.centered_float(widgets.scopes)
end)
vim.keymap.set('n', '<leader>dk', ':lua require"dap".up()<CR>zz')
vim.keymap.set('n', '<leader>dj', ':lua require"dap".down()<CR>zz')
vim.keymap.set('n', '<leader>dr',
':lua require"dap".repl.toggle({}, "vsplit")<CR><C-w>l')
vim.keymap.set('n', '<leader>du', ':lua require"dapui".toggle()<CR>')
-- nvim-telescope/telescope-dap.nvim
require('telescope').load_extension('dap')
vim.keymap.set('n', '<leader>ds', ':Telescope dap frames<CR>')
-- vim.keymap.set('n', '<leader>dc', ':Telescope dap commands<CR>')
vim.keymap.set('n', '<leader>db', ':Telescope dap list_breakpoints<CR>')
-- require('nvim-dap-virtual-text').setup()
-- David-Kunz/jester
require'jester'.setup({
path_to_jest = "/opt/homebrew/bin/jest",
dap = {type = 'pwa-node'}
})
-- require'jester'.setup({ dap = { type = 'pwa-node'}})
-- require'jester'.setup({ path_to_jest = "/opt/homebrew/bin/jest", dap = { type = 'pwa-node' } })
vim.keymap.set('n', '<leader>tt', function() require"jester".run() end)
vim.keymap.set('n', '<leader>t_', function() require"jester".run_last() end)
vim.keymap.set('n', '<leader>tf', function() require"jester".run_file() end)
vim.keymap.set('n', '<leader>d_', function() require"jester".debug_last() end)
vim.keymap.set('n', '<leader>df', function() require"jester".debug_file() end)
vim.keymap.set('n', '<leader>dq', function() require"jester".terminate() end)
vim.keymap.set('n', '<leader>dd', function() require"jester".debug() end)
-- lua language server
-- local system_name
-- if vim.fn.has("mac") == 1 then
-- system_name = "macOS"
-- elseif vim.fn.has("unix") == 1 then
-- system_name = "Linux"
-- elseif vim.fn.has('win32') == 1 then
-- system_name = "Windows"
-- else
-- print("Unsupported system for sumneko")
-- end
-- -- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use
-- local sumneko_root_path = os.getenv('HOME') ..'/apps/lua-language-server'
-- local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server"
-- local runtime_path = vim.split(package.path, ';')
-- table.insert(runtime_path, "lua/?.lua")
-- table.insert(runtime_path, "lua/?/init.lua")
-- require'lspconfig'.sumneko_lua.setup {
-- capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
-- cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
-- settings = {
-- Lua = {
-- runtime = {
-- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
-- version = 'LuaJIT',
-- -- Setup your lua path
-- path = runtime_path,
-- },
-- diagnostics = {
-- -- Get the language server to recognize the `vim` global
-- globals = {'vim'},
-- },
-- workspace = {
-- -- Make the server aware of Neovim runtime files
-- library = vim.api.nvim_get_runtime_file("", true),
-- },
-- -- Do not send telemetry data containing a randomized but unique identifier
-- telemetry = {
-- enable = false,
-- },
-- },
-- },
-- }
-- vim.keymap.set('n', '[b', ':bnext<CR>')
-- vim.keymap.set('n', ']b', ':bprev<CR>')
-- David-Kunz/treesitter-unit
vim.keymap.set('x', 'u', ':<c-u>lua require"treesitter-unit".select()<CR>')
vim.keymap.set('o', 'u', ':<c-u>lua require"treesitter-unit".select()<CR>')
vim.keymap.set('x', 'u', ':<c-u>lua require"treesitter-unit".select(true)<CR>')
vim.keymap.set('o', 'u', ':<c-u>lua require"treesitter-unit".select(true)<CR>')
-- require"treesitter-unit".enable_highlighting()
-- local tunit = require'treesitter-unit'
-- vim.keymap.set('x', 'iu', function() require'treesitter-unit'.select() end)
-- vim.keymap.set('x', 'au', function() require'treesitter-unit'.select(true) end)
-- vim.keymap.set('o', 'iu', function() require'treesitter-unit'.select() end)
-- vim.keymap.set('o', 'au', function() require'treesitter-unit'.select(true) end)
-- custom folder icon
-- require'nvim-web-devicons'.setup({
-- override = {
-- lir_folder_icon = {
-- icon = "",
-- color = "#7ebae4",
-- name = "LirFolderNode"
-- }
-- }
-- })
-- use visual mode
-- function _G.LirSettings()
-- vim.api.nvim_buf_set_keymap(0, 'x', 'J',
-- ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
-- {noremap = true, silent = true})
--
-- -- echo cwd
-- vim.api.nvim_echo({{vim.fn.expand('%:p'), 'Normal'}}, false, {})
-- end
-- vim.cmd [[augroup lir-settings]]
-- vim.cmd [[ autocmd!]]
-- vim.cmd [[ autocmd Filetype lir :lua LirSettings()]]
-- vim.cmd [[augroup END]]
-- global mark I for last edit
-- vim.cmd [[autocmd InsertLeave * execute 'normal! mI']]
-- highlight on yank
vim.cmd(
[[au TextYankPost * lua vim.highlight.on_yank {higroup="IncSearch", timeout=150, on_visual=true}]])
-- kyazdani42/nvim-tree.lua
-- require('nvim-tree').setup({
-- hijack_cursor = true,
-- update_focused_file = {enable = true},
-- filters = {dotfiles = true},
-- view = {width = 50}
-- })
-- vim.keymap.set('n', '\\', ':NvimTreeToggle<CR>', {silent = true})
vim.keymap.set('n', '\\',
':lua if not MiniFiles.close() then MiniFiles.open(vim.api.nvim_buf_get_name(0)) end<CR>',
{silent = true})
vim.keymap.set('n', 'gq', ':bd!<CR>')
vim.keymap.set('n', '<leader>w', ':w<CR>')
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>')
vim.cmd('iabbrev :tup: 👍')
vim.cmd('iabbrev :tdo: 👎')
vim.cmd('iabbrev :smi: 😊')
vim.cmd('iabbrev :sad: 😔')
vim.cmd('iabbrev darkred #8b0000')
vim.cmd('iabbrev darkgreen #006400')
_G.term_buf_of_tab = _G.term_buf_of_tab or {}
_G.term_buf_max_nmb = _G.term_buf_max_nmb or 0
local function spawn_terminal()
local cur_tab = vim.api.nvim_get_current_tabpage()
vim.cmd('vs | terminal')
local cur_buf = vim.api.nvim_get_current_buf()
_G.term_buf_max_nmb = _G.term_buf_max_nmb + 1
vim.api.nvim_buf_set_name(cur_buf, "Terminal " .. _G.term_buf_max_nmb)
table.insert(_G.term_buf_of_tab, cur_tab, cur_buf)
vim.cmd(':startinsert')
end
function Toggle_terminal()
local cur_tab = vim.api.nvim_get_current_tabpage()
local term_buf = term_buf_of_tab[cur_tab]
if term_buf ~= nil then
local cur_buf = vim.api.nvim_get_current_buf()
if cur_buf == term_buf then
vim.cmd('q')
else
local win_list = vim.api.nvim_tabpage_list_wins(cur_tab)
for _, win in ipairs(win_list) do
local win_buf = vim.api.nvim_win_get_buf(win)
if win_buf == term_buf then
vim.api.nvim_set_current_win(win)
vim.cmd(':startinsert')
return
end
end
vim.cmd('vert sb' .. term_buf)
vim.cmd(':startinsert')
end
else
spawn_terminal()
vim.cmd(':startinsert')
end
end
vim.keymap.set('n', '<c-y>', Toggle_terminal)
vim.keymap.set('i', '<c-y>', '<ESC>:lua Toggle_terminal()<CR>')
vim.keymap.set('t', '<c-y>', '<c-\\><c-n>:lua Toggle_terminal()<CR>')
cmd([[
if has('nvim')
au! TermOpen * tnoremap <buffer> <Esc> <c-\><c-n>
endif]])
Send_line_to_terminal = function()
local curr_line = vim.api.nvim_get_current_line()
local cur_tab = vim.api.nvim_get_current_tabpage()
local term_buf = term_buf_of_tab[cur_tab]
if term_buf == nil then
spawn_terminal()
term_buf = term_buf_of_tab[cur_tab]
end
for _, chan in pairs(vim.api.nvim_list_chans()) do
if chan.buffer == term_buf then chan_id = chan.id end
end
vim.api.nvim_chan_send(chan_id, curr_line .. '\n')
end
vim.keymap.set('n', '<leader>x', ':lua Send_line_to_terminal()<CR>')
require"nvim-treesitter.configs".setup {playground = {enable = true}}
vim.keymap.set('n', '<c-o>', '<c-o>zz')
vim.keymap.set('n', '<c-i>', '<c-i>zz')
-- 'L3MON4D3/LuaSnip'
-- local has_words_before = function()
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
-- return col ~= 0 and
-- vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col,
-- col)
-- :match("%s") == nil
-- end
--
-- local ls = require("luasnip")
-- ls.add_snippets("cds", {
-- ls.snippet("field", ls.text_node("YY1_CrByIncidentMgmt_SDH")),
-- ls.snippet("topic", ls.text_node(
-- "sap/cap/incidents/ce/sap/s4/beh/salesorder/v1/SalesOrder/Changed/v1"))
-- })
-- ls.add_snippets("json", {
-- ls.snippet("path", ls.text_node('/sap/opu/odata/sap/API_SALES_ORDER_SRV'))
-- })
-- ls.add_snippets("javascript", {
-- ls.snippet("block", ls.text_node("DeliveryBlockReason")),
-- ls.snippet("payload", ls.text_node({
-- " {", " SalesOrderType: 'OR',", " SalesOrganization: '1710',",
-- " DistributionChannel: '10',", " OrganizationDivision: '00',",
-- " SoldToParty: '17100002',",
-- " PurchaseOrderByCustomer: 'Incident: ' + title,",
-- " YY1_CrByIncidentMgmt_SDH: true,", " to_Item: orders.map(o => ({",
-- " Material: o.product,", " RequestedQuantity: o.quantity,",
-- " RequestedQuantityUnit: o.unitOfMeasure", " }))", " }"
-- }))
-- })
-- local cmp = require("cmp")
-- cmp.setup({
-- snippet = {expand = function(args) ls.lsp_expand(args.body) end},
-- mapping = {
-- ['<C-Space>'] = cmp.mapping.complete(),
-- ['<CR>'] = cmp.mapping.confirm({select = false}),
-- ['<C-d>'] = cmp.mapping.scroll_docs(-4),
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-n>'] = cmp.mapping.select_next_item({
-- behavior = cmp.SelectBehavior.Insert
-- }),
-- ['<C-p>'] = cmp.mapping.select_prev_item({
-- behavior = cmp.SelectBehavior.Insert
-- }),
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if ls.expand_or_jumpable() then
-- ls.expand_or_jump()
-- else
-- fallback()
-- end
-- end, {"i", "s"}),
-- ["<S-Tab>"] = cmp.mapping(function(fallback)
-- if ls.jumpable(-1) then
-- ls.jump(-1)
-- else
-- fallback()
-- end
-- end, {"i", "s"})
-- },
-- sources = {
-- {name = 'npm'}, {name = 'luasnip'}, {name = 'nvim_lsp'},
-- {name = 'buffer', keyword_length = 5}
-- }
-- -- formatting = {
-- -- format = lspkind.cmp_format({with_text = false, maxwidth = 50})
-- -- }
-- })
-- local t = function(str)
-- return vim.api.nvim_replace_termcodes(str, true, true, true)
-- end
--
-- _G.expand = function()
-- -- print("hurray!!")
-- if ls.expand_or_jumpable() then return t("<Plug>luasnip-expand-or-jump") end
-- return ''
-- end
--
-- _G.expand_back = function()
-- -- print("hurray!!")
-- if ls.jumpable(-1) then return t("<Plug>luasnip-jump-prev") end
-- return ''
-- end
--
-- vim.api.nvim_set_keymap('i', '<c-j>', 'v:lua.expand()', {expr = true})
-- vim.api.nvim_set_keymap('i', '<c-k>', 'v:lua.expand_back()', {expr = true})
-- vim.api.nvim_set_keymap('s', '<c-j>', 'v:lua.expand()', {expr = true})
-- vim.api.nvim_set_keymap('s', '<c-k>', 'v:lua.expand_back()', {expr = true})
--
-- vim.keymap.set('n', '<leader>ls',
-- '<cmd>source ~/.config/nvim/after/plugin/luasnip.lua<CR>')
--
_G.test_dap = function()
local dap = require 'dap'
-- dap.terminate(nil, nil, function()
-- vim.wait(2000, function()
-- local session = dap.session()
-- return session and session.initialized
-- end)
-- dap.run({
-- console = "integratedTerminal",
-- cwd = "/Users/d065023/tmp/node-test",
-- disableOptimisticBPs = true,
-- port = 9229,
-- protocol = "inspector",
-- request = "launch",
-- runtimeArgs = { "--inspect-brk", "plain.js" },
-- type = "pwa-node"
-- })
-- end)
dap.run({
type = 'pwa-node',
request = 'launch',
cwd = '/Users/d065023/tmp/node-test',
rootPath = '/Users/d065023/tmp/node-test',
runtimeArgs = {
'--inspect-brk', './node_modules/.bin/jest', '--no-coverage', '-t',
'^foo$', '--', 'sample.test.js'
},
args = {'--no-cache'},
console = 'integratedTerminal'
})
end
-- ldelossa/gh.nvim
-- require('litee.lib').setup()
-- require('litee.gh').setup({
-- prefer_https_remote = true
-- })
-- nvim-telescope/telescope-ui-select.nvim
require("telescope").load_extension("ui-select")
-- require("github-theme").setup({
-- theme_style = "dark",
-- })
vim.keymap.set('i', '<c-o>', '<esc><s-o>')
vim.keymap.set('n', '<leader>p', ':Lazy<CR>')
-- vim.api.nvim_create_autocmd('BufHidden', {
-- pattern = '[dap-terminal]*',
-- callback = function(arg)
-- vim.schedule(function() vim.api.nvim_buf_delete(arg.buf, { force = true }) end)
-- end
-- })
vim.keymap.set('n', '<leader>?',
'orequire("/usr/local/lib/node_modules/derive-type/")(...arguments)<esc>')
local dap = require("dap")
local dapui = require("dapui")
dapui.setup()
vim.keymap.set('n', '<leader>do', function() require("dapui").open() end)
vim.keymap.set('n', '<leader>dC', function() require("dapui").close() end)
-- dap.listeners.after.event_initialized["dapui_config"] = function()
-- dapui.open()
-- end
dap.listeners.before.event_terminated["dapui_config"] =
function() dapui.close() end
dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end
require('mason').setup()
require("mason-lspconfig").setup()
require("mason-lspconfig").setup_handlers {
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {}
end,
["lua_ls"] = function()
require("lspconfig").lua_ls.setup({
settings = {Lua = {diagnostics = {globals = {'vim'}}}}
})
end,
["tsserver"] = function()
require("lspconfig").tsserver.setup({
settings = {
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true
}
},
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,