-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugins.lua
1368 lines (1271 loc) · 34.3 KB
/
plugins.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([[packadd packer.nvim]])
vim.cmd([[
augroup RecompilePlugins
autocmd! BufWritePost plugins.lua let g:plugins_recompile=1 | source <afile> | PackerCompile
augroup END
]])
local function setup_packer(packer_bootstrap)
require("packer").startup(function(use)
use("wbthomason/packer.nvim")
use("tpope/vim-sensible")
use("tpope/vim-repeat")
use("wellle/targets.vim")
use({
"tpope/vim-unimpaired",
setup = function()
vim.g.nremap = {
-- Disable encoding and decoding maps
["[u"] = "",
["]u"] = "",
["[y"] = "",
["]y"] = "",
["[x"] = "",
["]x"] = "",
["[C"] = "",
["]C"] = "",
}
vim.g.xremap = vim.g.nremap
end,
})
use({
"echasnovski/mini.nvim",
config = function()
require("mini.trailspace").setup({
only_in_normal_buffers = true,
})
end,
})
use({ "tweekmonster/startuptime.vim", cmd = "StartupTime" })
use({ "lewis6991/impatient.nvim" })
use({
"ojroques/nvim-osc52",
config = function()
vim.api.nvim_create_autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("OSCYank", {}),
desc = 'Use OSC52 to copy text from the "+ buffer from Neovim inside SSH',
callback = function()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end,
})
end,
cond = function()
local ssh_connection = vim.env.SSH_CONNECTION
return ssh_connection ~= nil and ssh_connection ~= ""
end,
})
use({
"bkad/camelcasemotion",
config = function()
vim.g.camelcasemotion_key = "<Leader>"
end,
})
use({
"kyazdani42/nvim-web-devicons",
config = function()
require("nvim-web-devicons").setup({
default = true,
})
end,
})
use({
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
setup = function()
vim.g.neo_tree_remove_legacy_commands = 1
end,
config = function()
require("which-key").register({
["-"] = {
function()
local directory = vim.fn.expand("%:p:h")
require("neo-tree.command").execute({
action = "show",
source = "filesystem",
reveal = true,
-- NOTE: prevent annoying "File not in cwd" prompts.
-- Always use file's parent directory as neo-tree's cwd
reveal_force_cwd = true,
dir = directory,
position = "current",
})
end,
"Open parent directory in neo-tree",
},
["<leader>-"] = {
":Neotree reveal dir=. position=current<CR>",
"Open cwd in neo-tree",
},
})
local events = require("neo-tree.events")
---@class FileMovedArgs
---@field source string
---@field destination string
---@param args FileMovedArgs
local function on_file_remove(args)
local ts_clients = vim.lsp.get_active_clients({ name = "tsserver" })
for _, ts_client in ipairs(ts_clients) do
ts_client.request("workspace/executeCommand", {
command = "_typescript.applyRenameFile",
arguments = {
{
sourceUri = vim.uri_from_fname(args.source),
targetUri = vim.uri_from_fname(args.destination),
},
},
})
end
end
require("neo-tree").setup({
use_popups_for_input = false,
window = {
position = "current",
mappings = {
o = "open",
a = {
"add",
config = {
show_path = "absolute",
},
},
m = {
"move",
config = {
show_path = "absolute",
},
},
},
},
filesystem = {
bind_to_cwd = false,
window = {
mappings = {
["-"] = "navigate_up",
},
},
hijack_netrw_behavior = "open_current",
},
nesting_rules = {
ts = { "test.ts" },
},
event_handlers = {
{
event = events.NEO_TREE_BUFFER_ENTER,
handler = function()
vim.wo.number = true
vim.wo.relativenumber = true
end,
},
{
event = events.FILE_MOVED,
handler = on_file_remove,
},
{
event = events.FILE_RENAMED,
handler = on_file_remove,
},
},
})
end,
})
use({
"miversen33/netman.nvim",
config = function()
require("netman")
end,
})
use({
"junegunn/vim-easy-align",
config = function()
-- NOTE: for some reason, which-key.nvim could not register this binding
vim.cmd([[
xmap ga <Plug>(EasyAlign)
]])
end,
})
use({
"nvim-lualine/lualine.nvim",
requires = { "kyazdani42/nvim-web-devicons", opt = true },
config = function()
---Use global status line instead of per-window status lines
local global_status = false
local dap_extension = {
sections = {
lualine_a = { "mode", "filename" },
},
inactive_sections = {
lualine_a = { "filename" },
},
filetypes = {
"dapui_scopes",
"dapui_watches",
"dapui_stacks",
"dapui_breakpoints",
"dap-repl",
},
}
--- Source: https://github.com/nvim-lualine/lualine.nvim/wiki/Component-snippets#truncating-components-in-smaller-window
--- @param trunc_width number trunctates component when screen width is less than trunc_width
--- @param trunc_len number truncates component to trunc_len number of chars
--- @param hide_width? number hides component when window width is smaller then hide_width
--- @param no_ellipsis? boolean whether to disable adding '...' at end after truncation
--- return function that can format the component accordingly
local function trunc(trunc_width, trunc_len, hide_width, no_ellipsis)
return function(str)
local win_width = global_status and vim.go.columns or vim.fn.winwidth(0)
if hide_width and win_width < hide_width then
return ""
elseif trunc_width and trunc_len and win_width < trunc_width and #str > trunc_len then
return str:sub(1, trunc_len) .. (no_ellipsis and "" or "...")
end
return str
end
end
require("lualine").setup({
options = {
theme = "gruvbox-material",
globalstatus = global_status,
},
sections = {
lualine_a = { "mode" },
lualine_b = { { "branch", fmt = trunc(150, 20, 120) } },
lualine_c = {
{
"filename",
path = 1, -- NOTE: show relative file path
},
},
lualine_x = {
{
"diagnostics",
sources = { "nvim_diagnostic" },
},
{ "encoding", fmt = trunc(nil, nil, 150) },
{ "fileformat", fmt = trunc(nil, nil, 150) },
{ "filetype", fmt = trunc(150, 8) },
},
lualine_y = { { "progress", fmt = trunc(nil, nil, 120) } },
lualine_z = { "location" },
},
extensions = { "fugitive", "quickfix", dap_extension, "symbols-outline", "neo-tree" },
})
end,
})
use({
"alvarosevilla95/luatab.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("luatab").setup({})
end,
})
use("tpope/vim-fugitive")
use("tpope/vim-rhubarb")
use("shumphrey/fugitive-gitlab.vim")
use("junegunn/gv.vim")
use({
"akinsho/git-conflict.nvim",
-- NOTE: use stable releases.
-- This also fixes a bug which causes git-conflict.nvim only work when
-- neovim is opened in the root of the repository.
tag = "*",
config = function()
require("git-conflict").setup({
highlights = {
-- NOTE: the default `current` highlight color is too heavy
current = "DiffChange",
},
})
end,
-- NOTE: gruvbox-material resets highlights during its initialization.
-- git-conflict relies on its highlights to correctly highlight hunks
after = { "gruvbox-material" },
})
use({
"voldikss/vim-floaterm",
config = function()
require("which-key").register({
["<Leader>G"] = {
":FloatermNew --width=0.95 --height=0.95 lazygit<CR>",
"lazygit in floating terminal",
},
})
end,
})
use({
"windwp/nvim-autopairs",
config = function()
local autopairs = require("nvim-autopairs")
autopairs.setup({
disable_in_macro = true,
})
end,
})
use({
"ggandor/lightspeed.nvim",
config = function()
require("lightspeed").setup({})
end,
})
use({
"AckslD/nvim-trevJ.lua",
config = function()
local trevj = require("trevj")
trevj.setup()
require("which-key").register({
["<Leader>J"] = { trevj.format_at_cursor, "Unjoin lines" },
})
end,
})
use({
"mbbill/undotree",
config = function()
vim.o.undofile = true
require("which-key").register({ ["<Leader>u"] = { ":UndotreeToggle<CR>", "Toggle undo tree" } })
end,
})
use({
"folke/which-key.nvim",
config = function()
local ws = require("which-key")
ws.setup({
operators = {
["<Leader>y"] = "Yank to clipboard",
},
})
ws.register({
["<"] = { "<gv", "Deindent lines" },
[">"] = { ">gv", "Indent lines" },
["<Leader>y"] = "Yank to clipboard",
}, {
mode = "v",
})
ws.register({
["cn"] = { "*``cgn", "Search and replace" },
["cN"] = { "*``cgN", "Search and replace backwards" },
J = { "mzJ`z", "Join lines" },
["<Leader>y"] = "Yank to clipboard",
})
end,
})
use({
"folke/todo-comments.nvim",
config = function()
require("todo-comments").setup({
colors = {
info = { "VirtualTextInfo" },
default = { "Aqua" },
},
keywords = {
SAFETY = { color = "hint", icon = "" },
},
})
end,
})
use({
"numToStr/Comment.nvim",
config = function()
require("Comment").setup({
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
})
end,
requires = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
})
use({ "kevinhwang91/nvim-bqf", ft = "qf" })
use("tpope/vim-obsession")
use({
"sainnhe/gruvbox-material",
config = function()
vim.o.termguicolors = true
vim.o.cursorline = true
vim.g.gruvbox_material_better_performance = 1
vim.g.gruvbox_material_diagnostic_virtual_text = "colored"
vim.g.gruvbox_material_diagnostic_text_highlight = 1
vim.g.gruvbox_material_diagnostic_line_highlight = 1
vim.g.gruvbox_material_ui_contrast = "high"
vim.cmd("colorscheme gruvbox-material")
end,
})
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
require("indent_blankline").setup({
use_treesitter = true,
show_current_context = true,
show_current_context_start = true,
context_highlight_list = { "Blue" },
context_patterns = {
-- NOTE: indent-blankline's defaults
"class",
"^func",
"method",
"^if",
"while",
"for",
"with",
"try",
"except",
"arguments",
"argument_list",
"object",
"dictionary",
"element",
"table",
"tuple",
-- NOTE: better JavaScript/TypeScript support
"return_statement",
"statement_block",
},
bufname_exclude = { "" }, -- Disables the plugin in hover() popups and new files
char_highlight_list = { "VertSplit" },
-- NOTE: alternating indentation highlight
space_char_highlight_list = { "MsgSeparator", "Normal" },
})
end,
requires = "nvim-treesitter/nvim-treesitter",
})
use({
"lukas-reineke/headlines.nvim",
config = function()
require("headlines").setup({
markdown = {
fat_headlines = false,
},
})
end,
})
use({
"norcalli/nvim-colorizer.lua",
config = function()
require("colorizer").setup()
end,
})
use({
"lewis6991/gitsigns.nvim",
requires = {
"nvim-lua/plenary.nvim",
},
config = function()
local gitsigns = require("gitsigns")
gitsigns.setup({
on_attach = function(bufnr)
local which_key = require("which-key")
which_key.register({
["[c"] = {
"&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'",
"Move to previous hunk",
expr = true,
},
["]c"] = {
"&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'",
"Move to next hunk",
expr = true,
},
}, { buffer = bufnr })
local function get_selected_line_range(mode)
if mode ~= "v" then
return nil
end
-- NOTE: the '< and '> return the **last** visual selection
-- and have stale values.
-- I didn't find a way to reliably exit visual mode prior to reading
-- them. Thus, use this method below to get the current selection
-- and exit visual mode in a non-blocking way
-- NOTE: sometimes start_line_number > end_line_number
-- gitsigns seems to handle that
local start_line_number = vim.fn.line("v")
local end_line_number = vim.fn.getcurpos()[2]
-- NOTE: exit visual mode
vim.api.nvim_input("<esc>")
return { start_line_number, end_line_number }
end
local function register_stage_unstage_hunk(mode)
which_key.register({
name = "gitsigns",
s = {
function()
gitsigns.stage_hunk(get_selected_line_range(mode))
end,
"Stage hunk",
},
r = {
function()
gitsigns.reset_hunk(get_selected_line_range(mode))
end,
"Reset hunk",
},
}, {
mode = mode,
prefix = "<leader>h",
buffer = bufnr,
})
end
register_stage_unstage_hunk("n")
register_stage_unstage_hunk("v")
which_key.register({
name = "gitsigns",
t = {
name = "Toggle",
d = { gitsigns.toggle_deleted, "Toggle deleted lines" },
b = { gitsigns.toggle_current_line_blame, "Toggle current line blame" },
},
b = {
function()
gitsigns.blame_line({ full = true })
end,
"Blame current line",
},
R = { gitsigns.reset_buffer, "Reset changes in buffer" },
p = { gitsigns.preview_hunk, "Preview hunk" },
u = { gitsigns.undo_stage_hunk, "Unstage last hunk" },
}, {
prefix = "<leader>h",
buffer = bufnr,
})
end,
})
end,
})
use({
"gelguy/wilder.nvim",
config = function()
-- Use a vimscript file because of a bug with using line continuations
-- See https://github.com/gelguy/wilder.nvim/issues/53
-- TODO: use <sfile>
vim.cmd([[source $HOME/.config/nvim/wilder.vim]])
vim.cmd([[call wilder#main#start()]])
end,
run = ":UpdateRemotePlugins",
event = "CmdlineEnter",
})
-- Telescope
use({
"nvim-telescope/telescope.nvim",
requires = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-live-grep-args.nvim",
},
config = function()
local vimgrep_args_hidden_files = require("telescope.config").set_defaults().get("vimgrep_arguments")
table.insert(vimgrep_args_hidden_files, "--hidden")
require("which-key").register({
name = "Telescope",
f = { "<cmd>Telescope find_files hidden=true<CR>", "Files" },
g = {
function()
require("telescope").extensions.live_grep_args.live_grep_args({
vimgrep_arguments = vimgrep_args_hidden_files,
})
end,
"Grep with rg",
},
G = {
name = "Git",
s = { "<cmd>Telescope git_status<CR>", "Status" },
f = { "<cmd>Telescope git_files<CR>", "Files" },
b = { "<cmd>Telescope git_branches<CR>", "Branches" },
},
b = { "<cmd>Telescope buffers<CR>", "Buffers" },
h = { "<cmd>Telescope help_tags<CR>", "Help tags" },
t = { "<cmd>Telescope treesitter<CR>", "Treesitter" },
o = { "<cmd>Telescope oldfiles<CR>", "Old files" },
r = { "<cmd>Telescope lsp_references<CR>", "LSP references" },
s = { "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", "LSP workspace symbols" },
}, {
prefix = "<Leader>f",
})
require("telescope").setup({
defaults = {
-- NOTE: Lua regexps https://www.lua.org/manual/5.1/manual.html#5.4.1
file_ignore_patterns = { "%.git/", "%.yarn/", "%.next/" },
path_display = { ["truncate"] = 2 },
mappings = {
n = {
dd = require("telescope.actions").delete_buffer,
},
},
},
})
end,
})
-- LSP
use({
"neovim/nvim-lspconfig",
config = function()
vim.o.cmdheight = 2
vim.opt.shortmess:append("c")
require("mason").setup()
require("mason-lspconfig").setup()
require("lsp")
require("dim").setup({})
end,
requires = {
"jose-elias-alvarez/typescript.nvim",
"jose-elias-alvarez/null-ls.nvim",
"mfussenegger/nvim-jdtls",
"b0o/SchemaStore.nvim",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
"narutoxy/dim.lua",
},
})
use({
"simrat39/symbols-outline.nvim",
config = function()
require("which-key").register({ ["<Leader>so"] = { ":SymbolsOutline<CR>", "Symbols outline" } })
require("symbols-outline").setup({
show_numbers = true,
show_relative_numbers = true,
})
end,
})
use({
"hrsh7th/nvim-cmp",
config = function()
vim.opt.completeopt = { "menuone", "noselect" }
local function prepare_sources()
-- NOTE: order matters. The order will be maintained in completions popup
local sources = {
{ name = "nvim_lsp", label = "LSP" },
{ name = "crates", label = "crates.nvim" },
{ name = "npm" },
{ name = "luasnip" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "buffer", keyword_length = 4 },
{ name = "tmux", keyword_length = 4 },
{ name = "calc" },
{ name = "emoji" },
}
local source_labels = {}
for _, source in ipairs(sources) do
source_labels[source.name] = string.format("[%s]", source.label or source.name)
end
return sources, source_labels
end
local sources, source_labels = prepare_sources()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = sources,
formatting = {
format = require("lspkind").cmp_format({ mode = "symbol_text", menu = source_labels }),
},
})
end,
requires = {
"hrsh7th/cmp-buffer",
"Saecki/crates.nvim",
"hrsh7th/cmp-path",
"andersevenrud/cmp-tmux",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-nvim-lsp",
"rafamadriz/friendly-snippets",
"hrsh7th/cmp-emoji",
"onsails/lspkind-nvim",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
})
use({
"L3MON4D3/LuaSnip",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip").config.set_config({
update_events = "TextChanged,TextChangedI",
})
require("snippets").setup()
-- https://github.com/L3MON4D3/LuaSnip#keymaps
vim.cmd([[
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr>
snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr>
snoremap <silent> <S-Tab> <cmd>lua require('luasnip').jump(-1)<Cr>
imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
]])
end,
})
use({
"Saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
branch = "main",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("crates").setup()
end,
})
use({
"David-Kunz/cmp-npm",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("cmp-npm").setup({})
end,
})
use({
"folke/trouble.nvim",
config = function()
local ws = require("which-key")
ws.register({
name = "Trouble",
x = { "<cmd>TroubleToggle<CR>", "Toggle" },
w = { "<cmd>TroubleToggle workspace_diagnostics<CR>", "Workspace diagnostics" },
d = { "<cmd>TroubleToggle document_diagnostics<CR>", "Document diagnostics" },
q = { "<cmd>TroubleToggle quickfix<CR>", "Quickfix" },
}, {
prefix = "<Leader>t",
})
ws.register({
["gR"] = { "<cmd>TroubleToggle lsp_references<CR>", "Trouble LSP references" },
})
end,
})
use({
"ray-x/lsp_signature.nvim",
config = function()
require("lsp_signature").setup()
end,
})
use({
"onsails/lspkind-nvim",
config = function()
require("lspkind").init()
end,
})
use({
"kosayoda/nvim-lightbulb",
config = function()
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
desc = "Show lightbulb in the signcolumn whenever an LSP action is available",
group = vim.api.nvim_create_augroup("LspLightBulb", {}),
callback = require("nvim-lightbulb").update_lightbulb,
pattern = "*",
})
end,
})
use({
"weilbith/nvim-code-action-menu",
cmd = "CodeActionMenu",
})
use({
"ThePrimeagen/refactoring.nvim",
requires = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" },
{ "folke/which-key.nvim" },
},
config = function()
require("refactor").setup()
end,
})
-- Treesitter
use({
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
requires = {
"nvim-treesitter/playground",
"nvim-treesitter/nvim-treesitter-textobjects",
"romgrk/nvim-treesitter-context",
"RRethy/nvim-treesitter-textsubjects",
"p00f/nvim-ts-rainbow",
"windwp/nvim-ts-autotag",
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"bash",
"bibtex",
"c",
"comment",
"css",
"diff",
"dockerfile",
"git_rebase",
"gitattributes",
"gitignore",
"go",
"gomod",
"gowork",
"graphql",
"hcl",
"hjson",
"http",
"java",
"javascript",
"jsdoc",
"json",
"json5",
"jsonc",
"latex",
"lua",
"make",
"markdown",
"markdown_inline",
"nix",
"python",
"query",
"regex",
"rust",
"scss",
"svelte",
"toml",
"tsx",
"typescript",
"vim",
"vue",
"yaml",
},
highlight = {
enable = true,
},
autotag = {
enable = true,
},
context_commentstring = {
enable = true,
},
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
},
},
playground = {
enable = true,
},
query_linter = {
enable = true,
},
textobjects = {
swap = {
enable = true,
swap_next = {
["]a"] = { "@parameter.inner" },
},
swap_previous = {
["[a"] = { "@parameter.inner" },
},
},
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@call.outer",
["ic"] = "@call.inner",
},
},
},
rainbow = {
enable = true,
extended_mode = true,
},
})
end,
})
use({
"kevinhwang91/nvim-ufo",
requires = "kevinhwang91/promise-async",
config = function()
vim.o.foldlevel = 99
vim.o.foldenable = true
require("ufo").setup()
end,
})
use({
"ziontee113/syntax-tree-surfer",
config = function()
local surfer = require("syntax-tree-surfer")
local wk = require("which-key")
wk.register({
J = {
function()
surfer.surf("next", "visual")
end,
"Surf to next node",
},
K = {
function()
surfer.surf("prev", "visual")
end,
"Surf to previous node",
},
H = {
function()
surfer.surf("parent", "visual")
end,
"Surf to parent node",
},
L = {
function()
surfer.surf("child", "visual")
end,
"Surf to child node",
},
["<A-J>"] = {
function()
surfer.surf("next", "visual", true)
end,
"Replace with next node",
},
["<A-K>"] = {
function()
surfer.surf("prev", "visual", true)
end,
"Replace with previous node",
},
}, { mode = "x" })
wk.register({