forked from abzcoding/lvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuiltin.lua
More file actions
752 lines (722 loc) · 24.3 KB
/
builtin.lua
File metadata and controls
752 lines (722 loc) · 24.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
local M = {}
M.config = function()
local kind = require "user.lsp_kind"
-- Snippets
-- =========================================
require("luasnip/loaders/from_vscode").load { paths = { "~/.config/lvim/snippets" } }
-- Autopairs
-- =========================================
-- lvim.builtin.autopairs.on_config_done = function(autopairs)
-- local Rule = require "nvim-autopairs.rule"
-- autopairs.add_rule(Rule("$$", "$$", "tex"))
-- end
-- Command Palette
-- =========================================
lvim.builtin.cpmenu = M.cpmenu()
-- Bufferline
-- =========================================
local List = require "plenary.collections.py_list"
lvim.builtin.bufferline.options.diagnostics_indicator = function(_, _, diagnostics)
local result = {}
local symbols = { error = kind.icons.error, warning = kind.icons.warn, info = kind.icons.info }
for name, count in pairs(diagnostics) do
if symbols[name] and count > 0 then
table.insert(result, symbols[name] .. count)
end
end
result = table.concat(result, " ")
return #result > 0 and result or ""
end
lvim.builtin.bufferline.options.groups = {
options = {
toggle_hidden_on_enter = true,
},
items = {
{ name = "ungrouped" },
{
highlight = { guisp = "#51AFEF" },
name = "tests",
icon = kind.icons.test,
matcher = function(buf)
return buf.filename:match "_spec" or buf.filename:match "test"
end,
},
{
name = "view models",
highlight = { guisp = "#03589C" },
matcher = function(buf)
return buf.filename:match "view_model%.dart"
end,
},
{
name = "screens",
icon = kind.icons.screen,
matcher = function(buf)
return buf.path:match "screen"
end,
},
{
highlight = { guisp = "#C678DD" },
name = "docs",
matcher = function(buf)
local list = List { "md", "org", "norg", "wiki" }
return list:contains(vim.fn.fnamemodify(buf.path, ":e"))
end,
},
{
highlight = { guisp = "#F6A878" },
name = "config",
matcher = function(buf)
return buf.filename:match "go.mod"
or buf.filename:match "go.sum"
or buf.filename:match "Cargo.toml"
or buf.filename:match "manage.py"
or buf.filename:match "Makefile"
end,
},
},
}
lvim.builtin.bufferline.options.separator_style = os.getenv 'KITTY_WINDOW_ID' and 'slant' or 'thin'
-- CMP
-- =========================================
lvim.builtin.cmp.sources = {
{ name = "nvim_lsp" },
{ name = "cmp_tabnine", max_item_count = 3 },
{ name = "buffer", max_item_count = 5, keyword_length = 5 },
{ name = "path", max_item_count = 5 },
{ name = "luasnip", max_item_count = 3 },
{ name = "nvim_lua" },
{ name = "calc" },
{ name = "emoji" },
{ name = "treesitter" },
{ name = "crates" },
{ name = "orgmode" },
}
lvim.builtin.cmp.documentation.border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }
lvim.builtin.cmp.experimental = {
ghost_text = false,
native_menu = false,
custom_menu = true,
}
lvim.builtin.cmp.formatting.kind_icons = kind.cmp_kind
lvim.builtin.cmp.formatting.source_names = {
buffer = "(Buffer)",
nvim_lsp = "(LSP)",
luasnip = "(Snip)",
treesitter = "",
nvim_lua = "(NvLua)",
spell = "暈",
emoji = "",
path = "",
calc = "",
cmp_tabnine = "ﮧ",
["vim-dadbod-completion"] = "𝓐",
}
if lvim.builtin.sell_your_soul_to_devil then
lvim.keys.insert_mode["<c-h>"] = { [[copilot#Accept("\<CR>")]], { expr = true, script = true } }
local cmp = require "cmp"
lvim.builtin.cmp.mapping["<Tab>"] = cmp.mapping(M.tab, { "i", "c" })
lvim.builtin.cmp.mapping["<S-Tab>"] = cmp.mapping(M.shift_tab, { "i", "c" })
end
-- Comment
-- =========================================
-- integrate with nvim-ts-context-commentstring
lvim.builtin.comment.pre_hook = function(ctx)
if not vim.tbl_contains({ "typescript", "typescriptreact" }, vim.bo.ft) then
return
end
local comment_utils = require "Comment.utils"
local type = ctx.ctype == comment_utils.ctype.line and "__default" or "__multiline"
local location
if ctx.ctype == comment_utils.ctype.block then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
end
return require("ts_context_commentstring.internal").calculate_commentstring {
key = type,
location = location,
}
end
-- Dashboard
-- =========================================
lvim.builtin.alpha.mode = "custom"
local alpha_opts = require("user.dashboard").config()
lvim.builtin.alpha["custom"] = { config = alpha_opts }
-- LSP
-- =========================================
lvim.lsp.buffer_mappings.normal_mode["K"] = {
"<cmd>lua require('user.builtin').show_documentation()<CR>",
"Show Documentation",
}
lvim.lsp.float.border = {
{ "╔", "FloatBorder" },
{ "═", "FloatBorder" },
{ "╗", "FloatBorder" },
{ "║", "FloatBorder" },
{ "╝", "FloatBorder" },
{ "═", "FloatBorder" },
{ "╚", "FloatBorder" },
{ "║", "FloatBorder" },
}
lvim.lsp.diagnostics.float.border = {
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
{ " ", "FloatBorder" },
}
if os.getenv "KITTY_WINDOW_ID" then
lvim.lsp.float.border = {
{ "🭽", "FloatBorder" },
{ "▔", "FloatBorder" },
{ "🭾", "FloatBorder" },
{ "▕", "FloatBorder" },
{ "🭿", "FloatBorder" },
{ "▁", "FloatBorder" },
{ "🭼", "FloatBorder" },
{ "▏", "FloatBorder" },
}
lvim.lsp.diagnostics.float.border = lvim.lsp.float.border
end
lvim.lsp.diagnostics.float.focusable = false
lvim.lsp.float.focusable = true
lvim.lsp.diagnostics.signs.values = {
{ name = "DiagnosticSignError", text = kind.icons.error },
{ name = "DiagnosticSignWarn", text = kind.icons.warn },
{ name = "DiagnosticSignInfo", text = kind.icons.info },
{ name = "DiagnosticSignHint", text = kind.icons.hint },
}
lvim.lsp.diagnostics.float.source = "if_many"
lvim.lsp.diagnostics.float.format = function(d)
local t = vim.deepcopy(d)
local code = d.code or (d.user_data and d.user_data.lsp.code)
for _, table in pairs(M.codes) do
if vim.tbl_contains(table, code) then
return table.message
end
end
return t.message
end
-- Lualine
-- =========================================
lvim.builtin.lualine.active = true
lvim.builtin.lualine.sections.lualine_b = { "branch" }
-- NvimTree
-- =========================================
lvim.builtin.nvimtree.setup.diagnostics = {
enable = true,
icons = {
hint = kind.icons.hint,
info = kind.icons.info,
warning = kind.icons.warn,
error = kind.icons.error,
},
}
lvim.builtin.nvimtree.icons = kind.nvim_tree_icons
lvim.builtin.nvimtree.on_config_done = function(_)
lvim.builtin.which_key.mappings["e"] = { "<cmd>NvimTreeToggle<CR>", " Explorer" }
end
-- lvim.builtin.nvimtree.hide_dotfiles = 0
-- Project
-- =========================================
lvim.builtin.project.active = true
lvim.builtin.project.detection_methods = { "lsp", "pattern" }
-- Treesitter
-- =========================================
lvim.builtin.treesitter.context_commentstring.enable = true
lvim.builtin.treesitter.ensure_installed = "maintained"
lvim.builtin.treesitter.highlight.disable = { "org" }
lvim.builtin.treesitter.highlight.aditional_vim_regex_highlighting = { "org" }
lvim.builtin.treesitter.ignore_install = { "haskell", "norg" }
lvim.builtin.treesitter.incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-n>",
node_incremental = "<C-n>",
scope_incremental = "<C-s>",
node_decremental = "<C-r>",
},
}
lvim.builtin.treesitter.indent = { enable = true, disable = { "yaml", "python" } } -- treesitter is buggy :(
lvim.builtin.treesitter.matchup.enable = true
-- lvim.treesitter.textsubjects.enable = true
-- lvim.treesitter.playground.enable = true
lvim.builtin.treesitter.query_linter = {
enable = true,
use_virtual_text = true,
lint_events = { "BufWrite", "CursorHold" },
}
lvim.builtin.treesitter.textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
["al"] = "@loop.outer",
["il"] = "@loop.inner",
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["av"] = "@variable.outer",
["iv"] = "@variable.inner",
},
},
swap = {
enable = true,
swap_next = {
["<leader><M-a>"] = "@parameter.inner",
["<leader><M-f>"] = "@function.outer",
["<leader><M-e>"] = "@element",
},
swap_previous = {
["<leader><M-A>"] = "@parameter.inner",
["<leader><M-F>"] = "@function.outer",
["<leader><M-E>"] = "@element",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]p"] = "@parameter.inner",
["]f"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]F"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[p"] = "@parameter.inner",
["[f"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[F"] = "@function.outer",
["[]"] = "@class.outer",
},
},
}
-- Telescope
-- =========================================
-- lvim.builtin.telescope.defaults.path_display = { "smart", "absolute", "truncate" }
lvim.builtin.telescope.defaults.path_display = { shorten = 10 }
if lvim.builtin.fancy_telescope.active then
lvim.builtin.telescope.defaults.prompt_prefix = " "
lvim.builtin.telescope.defaults.borderchars = {
prompt = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
results = { "─", "▐", "─", "│", "╭", "▐", "▐", "╰" },
-- results = {' ', '▐', '▄', '▌', '▌', '▐', '▟', '▙' };
preview = { " ", "│", " ", "▌", "▌", "╮", "╯", "▌" },
}
lvim.builtin.telescope.defaults.selection_caret = " "
else
lvim.builtin.telescope.defaults.winblend = 15
end
lvim.builtin.telescope.defaults.cache_picker = { num_pickers = 3 }
lvim.builtin.telescope.defaults.layout_strategy = "horizontal"
lvim.builtin.telescope.defaults.file_ignore_patterns = {
"vendor/*",
"%.lock",
"__pycache__/*",
"%.sqlite3",
"%.ipynb",
"node_modules/*",
"%.jpg",
"%.jpeg",
"%.png",
"%.svg",
"%.otf",
"%.ttf",
".git/",
"%.webp",
".dart_tool/",
".github/",
".gradle/",
".idea/",
".settings/",
".vscode/",
"__pycache__/",
"build/",
"env/",
"gradle/",
"node_modules/",
"target/",
"%.pdb",
"%.dll",
"%.class",
"%.exe",
"%.cache",
"%.ico",
"%.pdf",
"%.dylib",
"%.jar",
"%.docx",
"%.met",
"smalljre_*/*",
".vale/",
"%.burp",
"%.mp4",
"%.mkv",
"%.rar",
"%.zip",
"%.7z",
"%.tar",
"%.bz2",
"%.epub",
"%.flac",
"%.tar.gz",
}
local user_telescope = require "user.telescope"
lvim.builtin.telescope.defaults.layout_config = user_telescope.layout_config()
local actions = require "telescope.actions"
lvim.builtin.telescope.defaults.mappings = {
i = {
["<c-c>"] = require("telescope.actions").close,
["<c-y>"] = require("telescope.actions").which_key,
["<tab>"] = actions.toggle_selection + actions.move_selection_next,
["<s-tab>"] = actions.toggle_selection + actions.move_selection_previous,
["<cr>"] = user_telescope.multi_selection_open,
["<c-v>"] = user_telescope.multi_selection_open_vsplit,
["<c-s>"] = user_telescope.multi_selection_open_split,
["<c-t>"] = user_telescope.multi_selection_open_tab,
["<c-j>"] = actions.move_selection_next,
["<c-k>"] = actions.move_selection_previous,
},
n = {
["<esc>"] = actions.close,
["<tab>"] = actions.toggle_selection + actions.move_selection_next,
["<s-tab>"] = actions.toggle_selection + actions.move_selection_previous,
["<cr>"] = user_telescope.multi_selection_open,
["<c-v>"] = user_telescope.multi_selection_open_vsplit,
["<c-s>"] = user_telescope.multi_selection_open_split,
["<c-t>"] = user_telescope.multi_selection_open_tab,
["<c-j>"] = actions.move_selection_next,
["<c-k>"] = actions.move_selection_previous,
["<c-n>"] = actions.cycle_history_next,
["<c-p>"] = actions.cycle_history_prev,
["<c-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
},
}
local telescope_actions = require "telescope.actions.set"
lvim.builtin.telescope.defaults.pickers.find_files = {
attach_mappings = function(_)
telescope_actions.select:enhance {
post = function()
vim.cmd ":normal! zx"
end,
}
return true
end,
find_command = { "fd", "--type=file", "--hidden", "--smart-case" },
}
lvim.builtin.telescope.on_config_done = function(telescope)
telescope.load_extension "file_create"
telescope.load_extension "command_palette"
if lvim.builtin.file_browser.active then
telescope.load_extension "file_browser"
end
end
-- Terminal
-- =========================================
lvim.builtin.terminal.active = true
lvim.builtin.terminal.open_mapping = [[<c-\>]]
-- WhichKey
-- =========================================
lvim.builtin.which_key.setup.window.winblend = 10
lvim.builtin.which_key.setup.window.border = "none"
lvim.builtin.which_key.setup.icons = {
breadcrumb = "/", -- symbol used in the command line area that shows your active key combo
separator = "·", -- symbol used between a key and it's label
group = "", -- symbol prepended to a group
}
lvim.builtin.which_key.setup.ignore_missing = true
lvim.builtin.which_key.on_config_done = function(wk)
local keys = {
["ga"] = { "<cmd>lua require('user.telescope').code_actions()<CR>", "Code Action" },
["gR"] = { "<cmd>Trouble lsp_references<CR>", "Goto References" },
["gI"] = { "<cmd>lua require('user.telescope').lsp_implementations()<CR>", "Goto Implementation" },
["gA"] = { "<cmd>lua vim.lsp.codelens.run()<CR>", "CodeLens Action" },
["gt"] = { "<cmd>lua vim.lsp.buf.type_definition()<CR>", "Goto Type Definition" },
}
wk.register(keys, { mode = "n" })
end
-- ETC
-- =========================================
local default_exe_handler = vim.lsp.handlers["workspace/executeCommand"]
vim.lsp.handlers["workspace/executeCommand"] = function(err, result, ctx, config)
-- supress NULL_LS error msg
if err and vim.startswith(err.message, "NULL_LS") then
return
end
return default_exe_handler(err, result, ctx, config)
end
-- if lvim.builtin.lastplace.active == false then
-- -- go to last loc when opening a buffer
-- vim.cmd [[
-- autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif
-- ]]
-- end
end
function M.rename(curr, win)
local name = vim.trim(vim.fn.getline ".")
vim.api.nvim_win_close(win, true)
if #name > 0 and name ~= curr then
local params = vim.lsp.util.make_position_params()
params.newName = name
vim.lsp.buf_request(0, "textDocument/rename", params)
end
end
function M.lsp_rename()
local name = vim.fn.expand "<cword>"
local ok, ts = pcall(require, "nvim-treesitter-playground.hl-info")
local tshl = ""
if ok and ts then
if #ts <= 0 then
return
end
tshl = ts.get_treesitter_hl()
local ind = tshl[#tshl]:match "^.*()%*%*.*%*%*"
tshl = tshl[#tshl]:sub(ind + 2, -3)
end
local win = require("plenary.popup").create(name, {
title = "New Name",
style = "minimal",
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
relative = "cursor",
borderhighlight = "FloatBorder",
titlehighlight = "Title",
highlight = tshl,
focusable = true,
width = 25,
height = 1,
line = "cursor+2",
col = "cursor-1",
})
-- Move cursor to the end of the prefix
vim.cmd "stopinsert"
vim.cmd "startinsert!"
vim.cmd [[lua require('cmp').setup.buffer { enabled = false }]]
local opts = { noremap = false, silent = true }
vim.api.nvim_buf_set_keymap(0, "i", "<Esc>", "<cmd>stopinsert | q!<CR>", opts)
vim.api.nvim_buf_set_keymap(0, "n", "<Esc>", "<cmd>stopinsert | q!<CR>", opts)
vim.api.nvim_buf_set_keymap(
0,
"i",
"<CR>",
"<cmd>stopinsert | lua require('user.builtin').rename(" .. name .. "," .. win .. ")<CR>",
opts
)
vim.api.nvim_buf_set_keymap(
0,
"n",
"<CR>",
"<cmd>stopinsert | lua require('user.builtin').rename(" .. name .. "," .. win .. ")<CR>",
opts
)
end
function M.tab(fallback)
local methods = require("lvim.core.cmp").methods
local cmp = require "cmp"
local luasnip = require "luasnip"
local copilot_keys = vim.fn["copilot#Accept"]()
if cmp.visible() then
cmp.select_next_item()
elseif vim.api.nvim_get_mode().mode == "c" then
fallback()
elseif copilot_keys ~= "" then -- prioritise copilot over snippets
-- Copilot keys do not need to be wrapped in termcodes
vim.api.nvim_feedkeys(copilot_keys, "i", true)
elseif luasnip.expandable() then
luasnip.expand()
elseif methods.jumpable() then
luasnip.jump(1)
elseif methods.check_backspace() then
fallback()
else
methods.feedkeys("<Plug>(Tabout)", "")
end
end
function M.shift_tab(fallback)
local methods = require("lvim.core.cmp").methods
local luasnip = require "luasnip"
local cmp = require "cmp"
if cmp.visible() then
cmp.select_prev_item()
elseif vim.api.nvim_get_mode().mode == "c" then
fallback()
elseif methods.jumpable(-1) then
luasnip.jump(-1)
else
local copilot_keys = vim.fn["copilot#Accept"]()
if copilot_keys ~= "" then
methods.feedkeys(copilot_keys, "i")
else
methods.feedkeys("<Plug>(Tabout)", "")
end
end
end
function M.cpmenu()
return {
{
"File",
{ "entire selection", ':call feedkeys("GVgg")' },
{ "file browser", ":Telescope file_browser", 1 },
{ "files", ":lua require('telescope.builtin').find_files()", 1 },
{ "git files", ":lua require('user.telescope').git_files()", 1 },
{ "last search", ":lua require('telescope.builtin').resume({cache_index=3})" },
{ "quit", ":qa" },
{ "save all files", ":wa" },
{ "save current file", ":w" },
{ "search word", ":lua require('user.telescope').find_string()", 1 },
},
{
"Lsp",
{ "formatting", ":lua vim.lsp.buf.formatting_seq_sync()" },
{ "workspace diagnostics", ":Telescope diagnostics" },
{ "workspace symbols", ":Telescope lsp_workspace_symbols" },
},
{
"Project",
{ "list", ":Telescope projects" },
{ "build", ":AsyncTask project-build" },
{ "run", ":AsyncTask project-run" },
{ "tasks", ":AsyncTaskList" },
},
{
"Vim",
{ "buffers", ":Telescope buffers" },
{ "check health", ":checkhealth" },
{ "colorshceme", ":lua require('telescope.builtin').colorscheme()", 1 },
{ "command history", ":lua require('telescope.builtin').command_history()" },
{ "commands", ":lua require('telescope.builtin').commands()" },
{ "cursor column", ":set cursorcolumn!" },
{ "cursor line", ":set cursorline!" },
{ "jumps", ":lua require('telescope.builtin').jumplist()" },
{ "keymaps", ":lua require('telescope.builtin').keymaps()" },
{ "paste mode", ":set paste!" },
{ "registers (A-e)", ":lua require('telescope.builtin').registers()" },
{ "relative number", ":set relativenumber!" },
{ "reload vimrc", ":source $MYVIMRC" },
{ "search highlighting", ":set hlsearch!" },
{ "search history", ":lua require('telescope.builtin').search_history()" },
{ "spell checker", ":set spell!" },
{ "vim options", ":lua require('telescope.builtin').vim_options()" },
},
{
"Help",
{ "cheatsheet", ":help index" },
{ "quick reference", ":help quickref" },
{ "search help", ":lua require('telescope.builtin').help_tags()", 1 },
{ "summary", ":help summary" },
{ "tips", ":help tips" },
{ "tutorial", ":help tutor" },
},
{
"Dap",
{ "brakpoints", ":lua require'telescope'.extensions.dap.list_breakpoints{}" },
{ "clear breakpoints", ":lua require('dap.breakpoints').clear()" },
{ "close", ":lua require'dap'.close(); require'dap'.repl.close()" },
{ "commands", ":lua require'telescope'.extensions.dap.commands{}" },
{ "configurations", ":lua require'telescope'.extensions.dap.configurations{}" },
{ "continue", ":lua require'dap'.continue()" },
{ "current scopes floating window", ":lua ViewCurrentScopesFloatingWindow()" },
{ "current scopes", ':lua ViewCurrentScopes(); vim.cmd("wincmd w|vertical resize 40")' },
{ "current value floating window", ":lua ViewCurrentValueFloatingWindow()" },
{ "frames", ":lua require'telescope'.extensions.dap.frames{}" },
{ "pause", ":lua require'dap'.pause()" },
{ "repl", ":lua require'dap'.repl.open(); vim.cmd(\"wincmd w|resize 12\")" },
{ "run to cursor", ":lua require'dap'.run_to_cursor()" },
{ "step back", ":lua require'dap'.step_back()" },
{ "step into", ":lua require'dap'.step_into()" },
{ "step out", ":lua require'dap'.step_out()" },
{ "step over", ":lua require'dap'.step_over()" },
{ "toggle breakpoint", ":lua require'dap'.toggle_breakpoint()" },
},
}
end
-- credit: https://github.com/max397574/NeovimConfig/blob/master/lua/configs/lsp/init.lua
M.codes = {
no_matching_function = {
message = " Can't find a matching function",
"redundant-parameter",
"ovl_no_viable_function_in_call",
},
different_requires = {
message = " Buddy you've imported this before, with the same name",
"different-requires",
},
empty_block = {
message = " That shouldn't be empty here",
"empty-block",
},
missing_symbol = {
message = " Here should be a symbol",
"miss-symbol",
},
expected_semi_colon = {
message = " Remember the `;` or `,`",
"expected_semi_declaration",
"miss-sep-in-table",
"invalid_token_after_toplevel_declarator",
},
redefinition = {
message = " That variable was defined before",
"redefinition",
"redefined-local",
},
no_matching_variable = {
message = " Can't find that variable",
"undefined-global",
"reportUndefinedVariable",
},
trailing_whitespace = {
message = " Remove trailing whitespace",
"trailing-whitespace",
"trailing-space",
},
unused_variable = {
message = " Don't define variables you don't use",
"unused-local",
},
unused_function = {
message = " Don't define functions you don't use",
"unused-function",
},
useless_symbols = {
message = " Remove that useless symbols",
"unknown-symbol",
},
wrong_type = {
message = " Try to use the correct types",
"init_conversion_failed",
},
undeclared_variable = {
message = " Have you delcared that variable somewhere?",
"undeclared_var_use",
},
lowercase_global = {
message = " Should that be a global? (if so make it uppercase)",
"lowercase-global",
},
}
M.show_documentation = function()
local filetype = vim.bo.filetype
if vim.tbl_contains({ "vim", "help" }, filetype) then
vim.cmd("h " .. vim.fn.expand "<cword>")
elseif vim.fn.expand "%:t" == "Cargo.toml" then
require("crates").show_popup()
elseif vim.tbl_contains({ "man" }, filetype) then
vim.cmd("Man " .. vim.fn.expand "<cword>")
else
vim.lsp.buf.hover()
end
end
return M