-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.lua
More file actions
2326 lines (2231 loc) · 74.2 KB
/
init.lua
File metadata and controls
2326 lines (2231 loc) · 74.2 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
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",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- ============================================================================
-- COLORSCHEMES
-- ============================================================================
"sainnhe/sonokai",
"sainnhe/everforest",
-- ============================================================================
-- TREESITTER & SYNTAX
-- ============================================================================
{
"nvim-treesitter/nvim-treesitter",
branch = "master",
lazy = false,
build = ":TSUpdate",
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
-- shows wrapping function signature if it is outside of the view
"nvim-treesitter/nvim-treesitter-context",
},
config = function()
require("nvim-treesitter.configs").setup({
modules = {}, -- Add modules if needed
sync_install = false, -- Install parsers asynchronously (recommended)
ensure_installed = { "lua", "typescript", "python", "json", "markdown" }, -- Add your desired languages
ignore_install = {}, -- Parsers to ignore
auto_install = true, -- Automatically install missing parsers
highlight = {
enable = true, -- false will disable the whole extension
-- disable = { "elixir" }, -- list of language that will be disabled
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
-- additional_vim_regex_highlighting = false,
},
textobjects = {
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",
["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" },
-- selects the return statement without the return keyword
["ir"] = { query = "@return.inner", desc = "Select inner part of a return statement" },
["ar"] = { query = "@return.outer", desc = "Select outer part of a return statement" },
},
-- 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,
},
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" },
-- uses shift down arrow to go to next statement (more granular than function)
-- ["J"] = "@statement.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
-- ["[["] = "@class.outer",
-- ["K"] = "@statement.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",
},
},
},
textsubjects = {
enable = true,
keymaps = {
[">"] = "textsubjects-smart",
["+"] = "textsubjects-container-outer",
},
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = "o",
toggle_hl_groups = "i",
toggle_injected_languages = "t",
toggle_anonymous_nodes = "a",
toggle_language_display = "I",
focus_language = "f",
unfocus_language = "F",
update = "R",
goto_node = "<cr>",
show_help = "?",
},
},
})
end,
},
{
"nvim-treesitter/playground",
lazy = true,
cmd = {
"TSPlaygroundToggle",
},
},
"HiPhish/rainbow-delimiters.nvim",
-- ============================================================================
-- LSP & LANGUAGE SERVERS
-- ============================================================================
{
"mason-org/mason.nvim",
opts = {},
},
{
"mason-org/mason-lspconfig.nvim",
opts = {},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",
},
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
"ts_ls",
-- "vue_ls",
-- "vtsls",
"tailwindcss",
"lua_ls",
"ruff",
"pyright",
},
automatic_enable = true,
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
vim.lsp.config("pyright", {
settings = {
pyright = {
disableOrganizeImports = true,
},
python = {
analysis = {
ignore = { "*" },
},
},
},
})
vim.lsp.config("ruff", {
init_options = {
settings = {
lint = {
enable = true,
},
},
},
})
vim.lsp.enable("pyright")
vim.lsp.enable("ruff")
vim.lsp.enable("eslint")
vim.keymap.set("n", "<space>1", "<cmd>LspEslintFixAll<cr>", {
noremap = true,
silent = true,
desc = "ESLint: Fix all auto-fixable issues",
})
end,
},
{
"jay-babu/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"mason-org/mason.nvim",
"nvimtools/none-ls.nvim",
},
config = function()
-- Primary Source of Truth is null-ls's setup
require("mason-null-ls").setup({
-- handlers = {},
automatic_installation = true,
})
end,
},
{
"nvimdev/lspsaga.nvim",
config = function()
require("lspsaga").setup({
lightbulb = {
enable = false,
},
symbol_in_winbar = {
enable = false,
},
})
vim.keymap.set({ "n", "v" }, "<space>l", "<cmd>Lspsaga code_action<CR>")
vim.keymap.set("n", "<space>u", "<cmd>Lspsaga outgoing_calls<CR>")
vim.keymap.set("n", "<space>U", "<cmd>Lspsaga incoming_calls<CR>")
end,
dependencies = {
"nvim-treesitter/nvim-treesitter", -- optional
"nvim-tree/nvim-web-devicons", -- optional
},
},
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{
"j-hui/fidget.nvim",
opts = {
-- options
},
},
-- ============================================================================
-- COMPLETION
-- ============================================================================
{
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = {
"rafamadriz/friendly-snippets",
{
"mikavilpas/blink-ripgrep.nvim",
version = "*", -- use the latest stable version
},
-- this adds blink suggestion items that are same as copilot, search below 'copilot'
-- { "fang2hou/blink-copilot" },
},
-- use a release tag to download pre-built binaries
version = "1.*",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
preset = "default",
["<C-k>"] = false, -- or {}
},
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- (Default) Only show the documentation popup when manually triggered
completion = { documentation = { auto_show = true } },
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = {
"lsp",
-- needs fang2hou/blink-copilot
-- "copilot", -- for now using grayed out suggestions by copilot.lua
"path",
"snippets",
"buffer",
"lazydev",
"ripgrep", -- 👈🏻 add "ripgrep" here
},
providers = {
-- 👇🏻👇🏻 add the ripgrep provider config below
ripgrep = {
module = "blink-ripgrep",
name = "Ripgrep",
score_offset = -50,
-- see the full configuration below for all available options
---@module "blink-ripgrep"
---@type blink-ripgrep.Options
opts = {
min_length = 4, -- only trigger after 4+ chars typed
},
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 90,
},
},
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" },
signature = { enabled = true },
},
opts_extend = { "sources.default" },
},
-- ============================================================================
-- FORMATTING & LINTING
-- ============================================================================
{
"stevearc/conform.nvim",
opts = {
formatters = {
oxfmt = {
command = "oxfmt",
args = { "$FILENAME" },
stdin = false,
-- When stdin=false, use this template to generate the temporary file that gets formatted
tmpfile_format = ".conform.$RANDOM.$FILENAME",
},
},
formatters_by_ft = {
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "ruff_format" },
-- You can customize some of the format options for the filetype (:help conform.format)
rust = { "rustfmt", lsp_format = "fallback" },
markdown = { "prettierd", "prettier", stop_after_first = true },
-- Conform will run the first available formatter
javascript = {
"oxfmt",
"prettierd",
"prettier",
stop_after_first = true,
},
typescript = {
"oxfmt",
"prettierd",
"prettier",
stop_after_first = true,
},
javascriptreact = {
"oxfmt",
"prettierd",
"prettier",
stop_after_first = true,
},
typescriptreact = {
"oxfmt",
"prettierd",
"prettier",
stop_after_first = true,
},
css = { "prettierd", "prettier", stop_after_first = true },
},
format_after_save = function(bufnr)
local name = vim.api.nvim_buf_get_name(bufnr)
-- If a large file, don't format on save
local max_filesize = 512 * 1024 -- 512 KB
local ok, stats = pcall(vim.loop.fs_stat, name)
if ok and stats and stats.size > max_filesize then
return
end
return { lsp_fallback = false }
end,
},
init = function()
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
require("conform").format({ async = true, lsp_format = "fallback", range = range })
end, { range = true })
-- maps it to <space>f
vim.keymap.set("n", "<space>f", ":Format<CR>", { noremap = true, silent = true, desc = "Format buffer" })
vim.keymap.set("v", "<space>f", ":Format<CR>", { noremap = true, silent = true, desc = "Format selection" })
-- set up formatexpr for gq formatting
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
},
{
"nvimtools/none-ls.nvim",
dependencies = {
"nvimtools/none-ls-extras.nvim",
},
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- formatting is handled by conform.nvim, so we don't need these
-- null_ls.builtins.formatting.stylua,
-- null_ls.builtins.formatting.prettierd,
-- COMMENTED OUT: These code actions cause 3-4s delay in lspsaga
-- Refactoring actions - uncomment if you find you need them
-- null_ls.builtins.code_actions.refactoring,
-- ESLint code actions - now handled by native eslint LSP (fast!)
-- Use <space>1 for ESLint auto-fix instead
-- require("none-ls.code_actions.eslint"),
-- KEEP: ESLint formatting (this is fast and works on save)
-- require("none-ls.formatting.eslint"),
-- null_ls.builtins.completion.spell,
-- require("none-ls.diagnostics.eslint"),
-- require("none-ls.diagnostics.eslint"),
-- require("none-ls.code_actions.eslint"),
-- require("none-ls.formatting.eslint"),
},
})
end,
},
"editorconfig/editorconfig-vim",
-- ============================================================================
-- DIAGNOSTICS & ERRORS
-- ============================================================================
{
"folke/trouble.nvim",
lazy = false,
opts = {
modes = {
diagnostics = {
-- auto_open = true,
-- auto_close = true,
warn_no_results = false,
},
},
}, -- for default options, refer to the configuration section for custom setup.
cmd = "Trouble",
config = function(_, opts)
require("trouble").setup(opts)
local trouble = require("trouble")
local function update_trouble_for_cur_buf_errors()
-- Don't trigger in insert or replace modes
local mode = vim.fn.mode()
if mode:match("^[iIrR]") then
return
end
-- Don't trigger if we're in a Trouble window
local current_buf = vim.api.nvim_get_current_buf()
local buf_filetype = vim.bo[current_buf].filetype
if buf_filetype == "trouble" then
return
end
local bufnr = 0 -- current buffer
local diagnostics = vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.ERROR })
if #diagnostics > 0 then
trouble.open({
mode = "diagnostics",
focus = false,
filter = {
buf = bufnr,
severity = vim.diagnostic.severity.ERROR,
},
})
else
trouble.close("diagnostics")
end
end
local group = vim.api.nvim_create_augroup("TroubleAutoUpdate", { clear = true })
vim.api.nvim_create_autocmd({ "DiagnosticChanged", "WinEnter", "InsertLeave", "BufEnter" }, {
group = group,
callback = function()
vim.schedule(update_trouble_for_cur_buf_errors)
end,
})
-- Cleanup autocmds on exit
vim.api.nvim_create_autocmd("VimLeavePre", {
group = group,
callback = function()
vim.api.nvim_del_augroup_by_id(group)
end,
})
-- Initial check
vim.schedule(update_trouble_for_cur_buf_errors)
end,
keys = {
{
"<F6>",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "All Diagnostics (Trouble)",
},
{
"<leader><F6>",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<space>O",
"<cmd>Trouble symbols toggle focus=true win.position=bottom auto_close=true<cr>",
desc = "Symbols (Trouble)",
},
-- {
-- "<leader>cl",
-- "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
-- desc = "LSP Definitions / references / ... (Trouble)",
-- },
-- {
-- "<leader>xL",
-- "<cmd>Trouble loclist toggle<cr>",
-- desc = "Location List (Trouble)",
-- },
-- {
-- "<leader>xQ",
-- "<cmd>Trouble qflist toggle<cr>",
-- desc = "Quickfix List (Trouble)",
-- },
},
},
{
"rachartier/tiny-inline-diagnostic.nvim",
event = "VeryLazy",
priority = 1000,
config = function()
require("tiny-inline-diagnostic").setup({})
vim.diagnostic.config({ virtual_text = false }) -- Disable default virtual text
end,
},
-- ============================================================================
-- CODE NAVIGATION
-- ============================================================================
{
dir = "~/repos/sibling-jump", -- Use local development version
opts = {
next_key = "<C-j>",
prev_key = "<C-k>",
center_on_jump = true,
filetypes = { "typescript", "javascript", "typescriptreact", "javascriptreact", "lua", "python" },
block_loop_key = "Z", -- Cycle through block boundaries (if/else, functions, objects, arrays)
block_loop_key_visual = "z", -- Visual mode keybinding for block-loop
block_loop_center_on_jump = false, -- Don't center screen for block-loop (only for sibling-jump)
},
},
{
"aaronik/treewalker.nvim",
opts = {
scope_confined = true,
},
keys = {
-- movement
{ "<C-S-k>", "<cmd>Treewalker Up<cr>", mode = { "n", "v" }, silent = true },
{ "<C-S-j>", "<cmd>Treewalker Down<cr>", mode = { "n", "v" }, silent = true },
{ "<C-h>", "<cmd>Treewalker Left<cr>", mode = { "n", "v" }, silent = true },
{ "<C-l>", "<cmd>Treewalker Right<cr>", mode = { "n", "v" }, silent = true },
},
},
{
"rmagatti/goto-preview",
opts = {
width = 100,
height = 40,
references = {
width = 250,
},
},
keys = {
{ "gpp", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>", desc = "Preview definition" },
{
"gpt",
"<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>",
desc = "Preview type definition",
},
{ "gpi", "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>", desc = "Preview implementation" },
{ "gp", "<cmd>lua require('goto-preview').close_all_win()<CR>", desc = "Close all preview windows" },
{ "gpr", "<cmd>lua require('goto-preview').goto_preview_references()<CR>", desc = "Preview references" },
{ "gpd", "<cmd>lua require('goto-preview').goto_preview_declaration()<CR>", desc = "Preview declaration" },
},
},
{
"subev/refjump.nvim",
-- branch = "all-feat",
branch = "main",
event = "LspAttach", -- Uncomment to lazy load
opts = {
keymaps = {
enable = true,
next = "J", -- Keymap to jump to next LSP reference
prev = "K", -- Keymap to jump to previous LSP reference
},
highlights = {
enable = true, -- Highlight the LSP references on jump
auto_clear = true, -- Automatically clear highlights when cursor moves
clear_on_escape = true, -- Listen for escape/ctrl-c to clear highlights (non-intrusive)
},
counter = {
enable = true, -- Enable virtual text counter at end of line
},
loop = false, -- Don't loop back to first/last reference when reaching the end
},
},
{
"dnlhc/glance.nvim",
opts = {
hooks = {
before_open = function(results, open, jump)
local uri = vim.uri_from_bufnr(0)
if #results == 1 then
local target_uri = results[1].uri or results[1].targetUri
if target_uri == uri then
jump(results[1])
else
open(results)
end
else
open(results)
end
end,
},
detached = function(winid)
return vim.api.nvim_win_get_width(winid) < 150
end,
},
keys = {
{ ",d", "<cmd>Glance definitions<cr>", desc = "Glance definitions" },
{ "gti", "<cmd>Glance implementations<cr>", desc = "Glance implementations" },
{ "gr", "<cmd>Glance references<cr>", desc = "Glance references" },
{ "gT", "<cmd>Glance type_definitions<cr>", desc = "Glance type_definitions" },
{ "<space><backspace>", "<cmd>Glance references<cr>", desc = "Glance references" },
},
},
{
"subev/vim-illuminate",
branch = "feat/cursor-highlight-groups",
lazy = false,
config = function()
require("illuminate").configure({})
end,
},
-- ============================================================================
-- AI & COPILOT
-- ============================================================================
{
"copilotlsp-nvim/copilot-lsp",
enabled = true,
opts = {},
init = function()
-- vim.g.copilot_nes_debounce = 300
-- this thing works but it relies on mason's copilot-lsp installation which conflicts with copilot.lua
-- vim.lsp.enable("copilot_ls")
-- vim.keymap.set("n", "7", function()
-- local bufnr = vim.api.nvim_get_current_buf()
-- local state = vim.b[bufnr].nes_state
-- if state then
-- -- Try to jump to the start of the suggestion edit.
-- -- If already at the start, then apply the pending suggestion and jump to the end of the edit.
-- local _ = require("copilot-lsp.nes").walk_cursor_start_edit()
-- or (
-- require("copilot-lsp.nes").apply_pending_nes()
-- and require("copilot-lsp.nes").walk_cursor_end_edit()
-- )
-- return nil
-- else
-- -- Resolving the terminal's inability to distinguish between `TAB` and `<C-i>` in normal mode
-- return "7"
-- end
-- end, { desc = "Accept Copilot NES suggestion", expr = true })
end,
},
{
"zbirenbaum/copilot.lua",
event = { "BufReadPost", "BufNewFile" },
opts = {
panel = {
enabled = false,
auto_refresh = true,
},
suggestion = {
enabled = true,
auto_trigger = true,
keymap = {
accept = "<c-cr>",
next = "<c-j>",
prev = "<c-k>",
accept_line = "<c-l>",
},
},
-- can' seem to make this work neither with copilot.lua nor copilot-lsp
nes = {
enabled = false, -- requires copilot-lsp as a dependency
auto_trigger = true,
keymap = {
accept_and_goto = "<c-i>",
accept = false,
dismiss = false,
},
},
},
},
{
"folke/sidekick.nvim",
lazy = false,
opts = {
nes = { enabled = false },
cli = {
layout = "right",
win = {
split = {
width = 0.5,
},
},
mux = {
backend = "zellij",
enabled = true,
},
},
},
keys = {
{
"1",
function()
-- if there is a next edit, jump to it, otherwise apply it if any
if not require("sidekick").nes_jump_or_apply() then
return "1" -- fallback to normal
end
end,
expr = true,
desc = "Goto/Apply Next Edit Suggestion",
},
{
"<c-.>",
function()
require("sidekick.cli").toggle()
end,
desc = "Sidekick Toggle",
mode = { "n", "t", "i", "x" },
},
{
"<leader>aa",
function()
require("sidekick.cli").send({ msg = "{this}" })
end,
mode = { "x", "n" },
desc = "Send This (at cursor)",
},
{
"<leader>as",
function()
require("sidekick.cli").select()
end,
-- Or to select only installed tools:
-- require("sidekick.cli").select({ filter = { installed = true } })
desc = "Select CLI",
},
{
"<leader>ad",
function()
require("sidekick.cli").close()
end,
desc = "Detach a CLI Session",
},
{
"<leader>af",
function()
require("sidekick.cli").send({ msg = "{file}" })
end,
desc = "Send File",
},
{
"<leader>av",
function()
require("sidekick.cli").send({ msg = "{selection}" })
end,
mode = { "x" },
desc = "Send Visual Selection",
},
{
"<leader>ap",
function()
require("sidekick.cli").prompt()
end,
mode = { "n", "x" },
desc = "Sidekick Select Prompt",
},
},
},
{
"olimorris/codecompanion.nvim",
opts = {
strategies = {
chat = {
adapter = "anthropic",
keymaps = {
send = {
modes = { n = "2" },
opts = {},
},
-- Add further custom keymaps here
},
},
inline = {
adapter = "anthropic",
},
},
adapters = {
http = {
anthropic = function()
return require("codecompanion.adapters").extend("anthropic", {
schema = {
model = {
default = "claude-sonnet-4-5",
},
},
})
end,
},
},
},
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
lazy = false,
init = function()
-- Expand 'cc' into 'CodeCompanion' in the command line
vim.cmd([[cab cc CodeCompanion]])
end,
keys = {
{
"<leader>cc",
":CodeCompanion #{buffer} ",
desc = "Prepare `Code Companion` with current buffer and visual selection",
mode = { "n", "v" },
},
{
"<leader>ca",
"<cmd>CodeCompanionActions<cr>",
desc = "Toggle Code Companion Actions",
mode = { "n", "v" },
},
{
"<leader>cv",
"<cmd>CodeCompanionChat Add<cr>",
desc = "Add visual selection to Code Companion Chat",
mode = "v",
},
{
"<leader>co",
"<cmd>CodeCompanionChat<cr>",
desc = "Open Code Companion Chat",
mode = "n",
},
{
"<leader>ce",
":CodeCompanionChat /explain #{buffer} ",
desc = "Explain current visual selection with Code Companion",
mode = { "n", "v" },
},
{
"<leader>ct",
":CodeCompanion #{buffer} /tests ",
desc = "Add tests for visual selection",
mode = { "n", "v" },
},
},
},
-- ============================================================================
-- GIT INTEGRATION
-- ============================================================================
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"sindrets/diffview.nvim", -- optional - Diff integration
-- Only one of these is needed.
"nvim-telescope/telescope.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
"nvim-mini/mini.pick", -- optional
"folke/snacks.nvim", -- optional
},
opts = {},
keys = {
{ "<leader>g", "<cmd>Neogit<cr>", desc = "Open Neogit" },
},
},
{
"lewis6991/gitsigns.nvim",
opts = {
current_line_blame = true,
on_attach = function(bufnr)
local gs = package.loaded.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", "]c", function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map("n", "[c", function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
-- Actions
map("n", "<space>x", gs.reset_hunk)
map("n", "<space>h", gs.preview_hunk)