-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
1141 lines (1095 loc) · 36.3 KB
/
init.lua
File metadata and controls
1141 lines (1095 loc) · 36.3 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
vim.wo.number = true
vim.cmd("set fileformat=unix")
vim.o.clipboard = "unnamedplus"
-- Change leader to a comma
vim.g.mapleader = "\\"
vim.api.nvim_set_keymap('i', 'jj', '<Esc>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'Q', ':!!sh<CR>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-y>', ':let @+ = expand("%:p")<CR>')
vim.keymap.set('n', "<left>", "gT")
vim.keymap.set('n', "<right>", "gt")
vim.keymap.set('n', "<C-c>", ":q<CR>")
vim.keymap.set('n', "<leader>re", ":tabnew ~/.config/nvim/init.lua<CR>")
vim.keymap.set('n', "<leader>rr", ":source $MYVIMRC<CR>")
vim.keymap.set('n', "<C-s>", ':w<CR>')
vim.keymap.set('i', "<C-s>", '<Esc>:w<CR>a')
vim.o.shada = "!,'2000000,<10000,s1000000,h"
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local toggle_key = "<C-,>"
plugins = {
{
'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
},
'neovim/nvim-lspconfig',
"mason-org/mason-lspconfig.nvim",
"mason-org/mason.nvim",
{ "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } },
"mfussenegger/nvim-dap",
"leoluz/nvim-dap-go",
"jay-babu/mason-nvim-dap.nvim",
"elentok/format-on-save.nvim",
{
"nvim-neotest/neotest",
dependencies = {
"nvim-neotest/neotest-jest",
"marilari88/neotest-vitest",
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter"
},
keys = {
{
"<leader>tl",
function()
require("neotest").run.run_last()
end,
desc = "Run Last Test",
},
{
"<leader>tL",
function()
require("neotest").run.run_last({ strategy = "dap" })
end,
desc = "Debug Last Test",
},
{
"<leader>tw",
"<cmd>lua require('neotest').run.run({ jestCommand = 'jest --watch ' })<cr>",
desc = "Run Watch",
},
{
"<leader>tr",
function()
require("neotest").run.run()
end,
desc = "Run Test under cursor",
},
{
"<leader>tR",
function()
require("neotest").run.run({ strategy = "dap" })
end,
desc = "Debug Test under cursor",
},
},
},
"klen/nvim-test",
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' }
},
"ruifm/gitlinker.nvim",
{
"roobert/action-hints.nvim",
config = function()
require("lualine").setup({
sections = {
lualine_x = { require("action-hints").statusline },
},
})
end,
},
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
},
{
"OXY2DEV/markview.nvim",
lazy = false, -- load immediately (for markdown editing)
ft = { "markdown" }, -- optional: load only for markdown
opts = {
-- put any plugin-specific configuration here
},
dependencies = {
-- markview.nvim depends on nui.nvim
"MunifTanjim/nui.nvim",
},
},
{
"HakonHarnes/img-clip.nvim",
config = function()
require('img-clip').setup {
-- Options for saving/embedding images
save_method = 'base64', -- or 'file' for saving as a file
-- Optional: configure image processing
process_cmd = 'convert - -resize 50% png:-', -- Example: resize image to 50%
-- Optional: configure directory for saved files (if save_method is 'file')
dir_path = function()
return vim.fn.expand("%:t:r") .. '_images'
end,
}
end,
event = "VeryLazy",
opts = {
-- add options here
-- or leave it empty to use the default settings
},
keys = {
-- suggested keymap
{ "<leader>p", "<cmd>PasteImage<cr>", desc = "Paste image from system clipboard" },
},
},
{
"amitds1997/remote-nvim.nvim",
version = "*", -- Pin to GitHub releases
dependencies = {
"nvim-lua/plenary.nvim", -- For standard functions
"MunifTanjim/nui.nvim", -- To build the plugin UI
"nvim-telescope/telescope.nvim", -- For picking b/w different remote methods
},
config = true,
},
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "jsonc", "markdown", "lua",
"vim", "vimdoc", "query", "go", "typescript", "javascript", "html"
},
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
refactor = {
smart_rename = {
enable = true,
-- Assign keymaps to false to disable them, e.g. `smart_rename = false`.
keymaps = {
smart_rename = "grr",
},
},
highlight_definitions = {
enable = true,
-- Set to false if you have an `updatetime` of ~100.
clear_on_cursor_move = true,
},
highlight_current_scope = { enable = false },
},
textobjects = {
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",
}
},
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["an"] = "@function.name", -- custom name object
["ac"] = "@class.outer",
["ag"] = "@call.outer",
["ig"] = "@call.inner",
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["ii"] = "@conditional.inner",
["ai"] = "@conditional.outer",
["as"] = "@struct_field.outer",
["is"] = "@struct_field.inner",
-- 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 = "@scope", query_group = "locals", desc = "Select language scope" },
},
-- You can choose the select mode (default is charwise 'v')
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * method: eg 'v' or 'o'
-- and should return the mode ('v', 'V', or '<c-v>') or a table
-- mapping query_strings to modes.
selection_modes = {
['@parameter.outer'] = 'v', -- charwise
['@function.outer'] = 'V', -- linewise
['@class.outer'] = '<c-v>', -- blockwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding or succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * selection_mode: eg 'v'
-- and should return true or false
include_surrounding_whitespace = false,
},
},
})
end
},
'nvim-treesitter/nvim-treesitter-refactor',
'nvim-treesitter/nvim-treesitter-textobjects',
'nvim-treesitter/nvim-treesitter-context',
{ "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} },
'github/copilot.vim',
--'hrsh7th/cmp-nvim-lsp',
"ellisonleao/gruvbox.nvim",
"prichrd/refgo.nvim",
{ 'glacambre/firenvim', build = ":call firenvim#install(0)" },
"christoomey/vim-tmux-navigator",
"f-person/auto-dark-mode.nvim",
"nanotee/zoxide.vim",
'vladdoster/remember.nvim',
'lewis6991/gitsigns.nvim',
{
"ray-x/go.nvim",
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
config = function()
require("go").setup({
dap_debug = true, -- enable DAP integration
})
end,
},
"nvim-tree/nvim-web-devicons",
"sindrets/diffview.nvim",
"gpanders/editorconfig.nvim",
"rbgrouleff/bclose.vim",
{
"cseickel/diagnostic-window.nvim",
dependencies = { "MunifTanjim/nui.nvim" }
},
{
"mikavilpas/yazi.nvim",
version = "*",
},
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
},
{
'johnseth97/gh-dash.nvim',
lazy = true,
keys = {
{
'<leader>cc',
function() require('gh_dash').toggle() end,
desc = 'Toggle gh-dash popup',
},
},
opts = {
keymaps = {}, -- disable internal mapping
border = 'rounded', -- or 'double'
width = 0.8,
height = 0.8,
autoinstall = true,
},
},
{
"ldelossa/gh.nvim",
dependencies = {
{
"ldelossa/litee.nvim",
config = function()
require("litee.lib").setup()
end,
},
},
config = function()
require("litee.gh").setup()
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"muniftanjim/nui.nvim",
-- {"3rd/image.nvim", opts = {}}, -- optional image support in preview window: see `# preview mode` for more information
},
lazy = false, -- neo-tree will lazily load itself
---@module "neo-tree"
---@type neotree.config?
opts = {
-- fill any relevant options here
},
},
{
"oskarrrrrrr/symbols.nvim",
config = function()
local r = require("symbols.recipes")
require("symbols").setup(r.DefaultFilters, r.AsciiSymbols, {
-- custom settings here
-- e.g. hide_cursor = false
})
vim.keymap.set("n", ",s", "<cmd> Symbols<CR>")
vim.keymap.set("n", ",S", "<cmd> SymbolsClose<CR>")
end
},
"andymass/vim-matchup",
{ 'akinsho/git-conflict.nvim', version = "*", config = true },
"nat-418/boole.nvim",
{
"johmsalas/text-case.nvim",
dependencies = { "nvim-telescope/telescope.nvim" },
config = function()
require("textcase").setup({})
require("telescope").load_extension("textcase")
end,
keys = {
"ga", -- Default invocation prefix
{ "<C-x><C-c>", "<cmd>TextCaseOpenTelescope<CR>", mode = { "n", "x" }, desc = "Telescope" },
"ga", -- Default invocation prefix
{ "ga.", "<cmd>TextCaseOpenTelescope<CR>", mode = { "n", "x" }, desc = "Telescope" },
},
cmd = {
-- NOTE: The Subs command name can be customized via the option "substitude_command_name"
"Subs",
"TextCaseOpenTelescope",
"TextCaseOpenTelescopeQuickChange",
"TextCaseOpenTelescopeLSPChange",
"TextCaseStartReplacingCommand",
},
-- If you want to use the interactive feature of the `Subs` command right away, text-case.nvim
-- has to be loaded on startup. Otherwise, the interactive feature of the `Subs` will only be
-- available after the first executing of it or after a keymap of text-case.nvim has been used.
lazy = false,
},
"LunarVim/bigfile.nvim",
{
"coder/claudecode.nvim",
dependencies = { "folke/snacks.nvim" },
keys = {
{ toggle_key, "<cmd>ClaudeCodeFocus<cr>", desc = "Claude Code", mode = { "n", "x" } },
},
opts = {
terminal = {
---@module "snacks"
---@type snacks.win.Config|{}
snacks_win_opts = {
position = "float",
width = 0.9,
height = 0.9,
keys = {
claude_hide = {
toggle_key,
function(self)
self:hide()
end,
mode = "t",
desc = "Hide",
},
},
},
},
},
},
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "main",
dependencies = {
{ "github/copilot.vim" }, -- or github/copilot.vim
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
},
build = "make tiktoken", -- Only on MacOS or Linux
opts = {
-- See Configuration section for rest
},
-- See Commands section for default commands if you want to lazy load on them
},
"junegunn/fzf.vim",
{
'nvim-telescope/telescope.nvim',
tag = '0.1.8',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-live-grep-args.nvim',
version = "^1.0.0",
},
"princejoogie/dir-telescope.nvim",
},
config = function()
local telescope = require("telescope")
-- first setup telescope
telescope.setup({
pickers = {
find_files = {
previewer = false,
},
oldfiles = {
previewer = false,
},
git_status = {
previewer = false,
},
buffers = {
previewer = false,
mappings = {
i = {
["<c-d>"] = "delete_buffer",
},
n = {
["dd"] = "delete_buffer",
},
},
},
},
})
-- then load the extension
telescope.load_extension("live_grep_args")
telescope.load_extension("dir")
end
},
{
'LukasPietzschmann/telescope-tabs',
config = function()
require('telescope').load_extension 'telescope-tabs'
require('telescope-tabs').setup {
-- Your custom config :^)
}
end,
dependencies = { 'nvim-telescope/telescope.nvim' },
},
{
'chomosuke/term-edit.nvim',
lazy = false,
version = '1.*',
},
{
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
win_options = {
signcolumn = "yes:2",
},
},
-- Optional dependencies
dependencies = { { "echasnovski/mini.icons", opts = {} } },
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
},
{
"refractalize/oil-git-status.nvim",
dependencies = {
"stevearc/oil.nvim",
},
config = true,
},
"ldelossa/gh.nvim",
dependencies = {
{
"ldelossa/litee.nvim",
config = function()
require("litee.lib").setup()
end,
},
},
config = function()
require("litee.gh").setup()
end,
'jeffkreeftmeijer/neovim-sensible',
{
"kiyoon/jupynium.nvim",
build = "pip3 install --user .",
-- build = "conda run --no-capture-output -n jupynium pip install .",
-- enabled = vim.fn.isdirectory(vim.fn.expand "~/miniconda3/envs/jupynium"),
},
"rcarriga/nvim-notify", -- optional
"stevearc/dressing.nvim" -- optional, UI for :JupyniumKernelSelect
}
require("lazy").setup(plugins, {})
require("gitlinker").setup()
require('boole').setup({
mappings = {
increment = '<C-a>',
decrement = '<C-x>'
},
-- User defined loops
additions = {
{ 'Foo', 'Bar' },
{ 'tic', 'tac', 'toe' }
},
allow_caps_additions = {
{ 'enable', 'disable' }
-- enable → disable
-- Enable → Disable
-- ENABLE → DISABLE
}
})
local wk = require("which-key")
wk.add {
{ '<leader>g', group = 'Git' },
{ '<leader>gh', group = 'Github' },
{ '<leader>ghc', group = 'Commits' },
{ '<leader>ghcc', '<cmd>GHCloseCommit<cr>', desc = 'Close' },
{ '<leader>ghce', '<cmd>GHExpandCommit<cr>', desc = 'Expand' },
{ '<leader>ghco', '<cmd>GHOpenToCommit<cr>', desc = 'Open To' },
{ '<leader>ghcp', '<cmd>GHPopOutCommit<cr>', desc = 'Pop Out' },
{ '<leader>ghcz', '<cmd>GHCollapseCommit<cr>', desc = 'Collapse' },
{ '<leader>ghi', group = 'Issues' },
{ '<leader>ghip', '<cmd>GHPreviewIssue<cr>', desc = 'Preview' },
{ '<leader>ghl', group = 'Litee' },
{ '<leader>ghlt', '<cmd>LTPanel<cr>', desc = 'Toggle Panel' },
{ '<leader>ghp', group = 'Pull Request' },
{ '<leader>ghpc', '<cmd>GHClosePR<cr>', desc = 'Close' },
{ '<leader>ghpd', '<cmd>GHPRDetails<cr>', desc = 'Details' },
{ '<leader>ghpe', '<cmd>GHExpandPR<cr>', desc = 'Expand' },
{ '<leader>ghpo', '<cmd>GHOpenPR<cr>', desc = 'Open' },
{ '<leader>ghpp', '<cmd>GHPopOutPR<cr>', desc = 'PopOut' },
{ '<leader>ghpr', '<cmd>GHRefreshPR<cr>', desc = 'Refresh' },
{ '<leader>ghpt', '<cmd>GHOpenToPR<cr>', desc = 'Open To' },
{ '<leader>ghpz', '<cmd>GHCollapsePR<cr>', desc = 'Collapse' },
{ '<leader>ghr', group = 'Review' },
{ '<leader>ghrb', '<cmd>GHStartReview<cr>', desc = 'Begin' },
{ '<leader>ghrc', '<cmd>GHCloseReview<cr>', desc = 'Close' },
{ '<leader>ghrd', '<cmd>GHDeleteReview<cr>', desc = 'Delete' },
{ '<leader>ghre', '<cmd>GHExpandReview<cr>', desc = 'Expand' },
{ '<leader>ghrs', '<cmd>GHSubmitReview<cr>', desc = 'Submit' },
{ '<leader>ghrz', '<cmd>GHCollapseReview<cr>', desc = 'Collapse' },
{ '<leader>ght', group = 'Threads' },
{ '<leader>ghtc', '<cmd>GHCreateThread<cr>', desc = 'Create' },
{ '<leader>ghtn', '<cmd>GHNextThread<cr>', desc = 'Next' },
{ '<leader>ghtt', '<cmd>GHToggleThread<cr>', desc = 'Toggle' },
}
require("mason").setup()
require("mason-lspconfig").setup(
{ ensure_installed = { "ts_ls" } }
)
local lspconfig = require('lspconfig')
local function disable_for_big_or_generated(bufnr)
local name = vim.api.nvim_buf_get_name(bufnr)
if name:match("/generated/") or name:match("/node_modules/")
or name:match("%.pb%.go$") or name:match("%.pb%.proto$") then
return true
end
return false
end
require('lspconfig').ts_ls.setup({
on_attach = function(client, bufnr)
-- Additional on_attach settings can go here
end,
-- Extra env for tsserver logs + memory
cmd_env = {
-- tsserver logging (created by typescript-language-server)
TSS_LOG = "-logToFile true -file /tmp/tsserver.log -level verbose",
NODE_OPTIONS = "--max-old-space-size=32000",
},
init_options = {
maxTsServerMemory = 32384,
}
})
lspconfig.gopls.setup({
on_attach = function(client, bufnr)
if disable_for_big_or_generated(bufnr) then
vim.lsp.buf_detach_client(bufnr, client.id)
return
end
end,
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_dir = lspconfig.util.root_pattern("go.work", "go.mod", ".git"),
cmd_env = {
-- Soft cap for Go runtime memory used by gopls:
-- accepts plain bytes or units like KiB, MiB, GiB
GOMEMLIMIT = "50GiB",
},
settings = {
gopls = {
analyses = {
unusedparams = true,
shadow = true,
},
buildFlags = { "-tags=ignore_generated" },
staticcheck = true,
},
},
})
require("mason-nvim-dap").setup()
require("oil").setup({
win_options = {
signcolumn = "yes:2",
},
})
vim.keymap.set('n', '<leader>y', ':Yazi<CR>')
vim.keymap.set('n', '<leader>d', ':DiagWindowShow<CR>')
ssh_con = os.getenv("SSH_CONNECTION")
if not ssh_con or string.len(ssh_con) == 0 then
require("auto-dark-mode").setup()
end
require('nvim-test').setup()
require 'term-edit'.setup {
prompt_end = '➜ '
}
require("ibl").setup()
require("CopilotChat").setup {
debug = true, -- Enable debugging
-- See Configuration section for rest
model = 'gpt-4o',
}
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
vim.cmd([[colorscheme gruvbox]])
-- todo move mappings into a separate file
vim.keymap.set('n', '<leader>rr', ':source $MYVIMRC<CR>')
vim.keymap.set('n', '<leader>re', ':tabnew ~/.config/nvim/init.lua<CR>')
-- git setup {{{
require('gitsigns').setup {
signs = {
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signs_staged = {
add = { text = '┃' },
change = { text = '┃' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
on_attach = function(bufnr)
local gitsigns = require('gitsigns')
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', 'gn', function()
if vim.wo.diff then
vim.cmd.normal({ ']c', bang = true })
else
gitsigns.nav_hunk('next')
end
end)
map('n', 'gp', function()
if vim.wo.diff then
vim.cmd.normal({ '[c', bang = true })
else
gitsigns.nav_hunk('prev')
end
end)
-- Actions
map('n', 'gs', gitsigns.stage_hunk)
map('n', 'gu', gitsigns.reset_hunk)
map('v', '<leader>hs', function()
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end)
map('v', 'gu', function()
gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end)
map('n', 'gS', gitsigns.stage_buffer)
map('n', 'gSR', gitsigns.reset_buffer)
map('n', '<leader>hp', gitsigns.preview_hunk)
map('n', '<leader>hi', gitsigns.preview_hunk_inline)
map('n', '<leader>gbs', function()
gitsigns.blame_line({ full = true })
end)
map('n', '<leader>hd', gitsigns.diffthis)
map('n', '<leader>hD', function()
gitsigns.diffthis('~')
end)
map('n', '<leader>hQ', function() gitsigns.setqflist('all') end)
map('n', '<leader>hq', gitsigns.setqflist)
-- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame)
map('n', '<leader>td', gitsigns.toggle_deleted)
map('n', '<leader>tw', gitsigns.toggle_word_diff)
-- Text object
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk)
end
}
--- }}}
--- telescope setup {{{
local telescope = require("telescope")
local lga_actions = require("telescope-live-grep-args.actions")
local builtin = require('telescope.builtin')
local actions = require("telescope.actions")
require("telescope").setup {
defaults = {
mappings = {
i = {
["<C-u>"] = false
},
},
},
extensions = {
live_grep_args = {
auto_quoting = true, -- enable/disable auto-quoting
-- define mappings, e.g.
mappings = { -- extend mappings
i = {
["<C-k>"] = lga_actions.quote_prompt(),
["<C-i>"] = lga_actions.quote_prompt({ postfix = " --iglob " }),
-- freeze the current list and start a fuzzy search in the frozen list
["<C-space>"] = actions.to_fuzzy_refine,
},
},
-- ... also accepts theme settings, for example:
-- theme = "dropdown", -- use dropdown theme
-- theme = { }, -- use own theme spec
-- layout_config = { mirror=true }, -- mirror preview pane
}
}
}
telescope.load_extension("live_grep_args")
-- }}}
-- todo get this to work
require("neotest").setup({
adapters = {
require("neotest-jest")({
-- jestCommand = require('neotest-jest.jest-util').getJestCommand(vim.fn.expand '%:p:h'),
jestCommand = "npx jest --verbose",
jestConfigFile = function(file)
if string.find(file, "/packages/") then
return string.match(file, "(.-/[^/]+/)src") .. "jest.config.ts"
end
return vim.fn.getcwd() .. "/jest.config.ts"
end,
})
}
})
vim.keymap.set('n', '<leader>ff', builtin.find_files)
vim.keymap.set('n', '<leader>fb', builtin.buffers)
vim.keymap.set('n', '<leader>fw', function()
builtin.git_status({
timeout = 10000,
enable_preview = true,
})
end, { desc = "change files" })
vim.keymap.set('n', '<leader>fo', builtin.oldfiles)
vim.keymap.set('n', '<C-e>', ':e!<CR>')
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set("n", "<leader>fa", ":lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>")
vim.keymap.set('n', '<leader>fr', function()
builtin.live_grep({
grep_open_files = true,
prompt_title = 'Live Grep in Open Buffers',
})
end, { desc = '[S]earch with [G]rep (open buffers only)' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>hc', builtin.command_history, {})
vim.keymap.set("n", "<leader>fd", "<cmd>Telescope dir find_files<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>lt", "<cmd>Telescope telescope-tabs list_tabs<CR>", { noremap = true, silent = true })
vim.keymap.set('n', '<leader>glc', function()
require('telescope.builtin').find_files({
find_command = { 'git', 'diff', '--name-only', 'HEAD^', 'HEAD' },
})
end, { desc = 'File changed in last commit' })
vim.keymap.set('n', '<leader>gbl', function()
require('telescope.builtin').git_branches({
show_remote_tracking = true,
})
end, { desc = 'Checkout [G]it [B]ranch' })
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', "<leader>e", vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev)
vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next)
vim.keymap.set('n', "<leader>q", vim.diagnostic.setloclist)
-- copilot
vim.keymap.set('i', '<C-Space>', '<Plug>(copilot-accept-word)')
--todo remap this to prevent conflict with tmux mapping
--the remote vim tmux mappings don't work any way so might as well get some
--use out of C-l (todo find something better)
-- vim.keymap.set('i', '<C-l>', '<Plug>(copilot-accept-line)')
--'go.nvim setup'
-- require('go').setup()
--below is broken rn
--require("go.format").goimports() -- goimports + gofmt
---- Run gofmt + goimports on save
--local format_sync_grp = vim.api.nvim_create_augroup("goimports", {})
--vim.api.nvim_create_autocmd("BufWritePre", {
-- pattern = "*.go",
-- callback = function()
-- require('go.format').goimports()
-- end,
-- group = format_sync_grp,
--})
-- 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', 'gy', '<cmd>Telescope lsp_type_definitions<CR>', 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', 'K', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<leader>gt", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>", {})
vim.keymap.set('n', "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', "<leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', "<C-x>f", ':GoTestFunc<CR>', opts)
vim.keymap.set('n', '<leader>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
require('remember')
local formatters = require("format-on-save.formatters")
require('format-on-save').setup({
experiments = {
partial_update = 'diff', -- or 'line-by-line'
},
formatter_by_ft = {
css = formatters.lsp,
html = formatters.lsp,
java = formatters.lsp,
javascript = formatters.lsp,
json = formatters.shell({ cmd = { "jq" } }),
lua = formatters.lsp,
markdown = formatters.prettierd,
openscad = formatters.lsp,
python = formatters.black,
rust = formatters.lsp,