-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
787 lines (708 loc) · 24.5 KB
/
Copy pathinit.lua
File metadata and controls
787 lines (708 loc) · 24.5 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
vim.o.number = true
vim.o.relativenumber = true
vim.o.signcolumn = "yes"
vim.o.wrap = false
vim.o.swapfile = false
vim.o.tabstop = 4
vim.o.winborder = "rounded"
vim.g.havenerdfont = true
vim.o.scrolloff = 8
vim.o.sidescrolloff = 8
vim.o.termguicolors = true
vim.o.exrc = true
vim.o.cursorline = true
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
})
local grp = vim.api.nvim_create_augroup("SyncRegisters", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", {
group = grp,
callback = function()
vim.cmd("wshada")
end,
})
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter" }, {
group = grp,
callback = function()
vim.cmd("rshada")
end,
})
vim.g.mapleader = " " -- Leader '<space>'
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>', { desc = 'Clear search highlight' })
vim.keymap.set('n', '<leader>', '<Nop>', { silent = true, noremap = true, desc = 'Disable bare <leader>' })
vim.keymap.set('n', '<leader>w', ':w<CR>', { desc = 'Save current buffer' })
vim.keymap.set('n', '<leader>W', ':wa<CR>:qa<CR>', { desc = 'Save all and quit' })
vim.keymap.set('n', '<leader>f', vim.lsp.buf.format, { desc = 'Format buffer with LSP' })
vim.keymap.set('n', '<leader>x', ':bd<CR>', { desc = 'Close current buffer' })
vim.keymap.set('n', '<leader>y', '"+yy', { silent = true, noremap = true, desc = 'Yank line to clipboard' })
vim.keymap.set('v', '<leader>y', '"+y', { silent = true, noremap = true, desc = 'Yank selection to clipboard' })
vim.keymap.set('n', '<leader>Y', function()
vim.cmd('normal! ggVG"+y')
vim.notify('Yanked buffer to clipboard', vim.log.levels.INFO)
end, { desc = 'Yank entire buffer to clipboard' })
vim.keymap.set({ 'n', 'v' }, 'H', '_', { silent = true, noremap = true })
vim.keymap.set({ 'n', 'v' }, 'L', '$', { silent = true, noremap = true })
vim.api.nvim_set_keymap('n', '<F5>', ':mksession! Session.vim<CR>',
{ noremap = true, silent = true, desc = "Saves the current session" })
vim.api.nvim_set_keymap('n', '<F6>', ':source Session.vim<CR>',
{ noremap = true, silent = true, desc = "Loads the saved session" })
vim.api.nvim_create_autocmd('PackChanged', {
callback = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
if name == 'nvim-treesitter' and kind == 'update' then
if not ev.data.active then vim.cmd.packadd('nvim-treesitter') end
vim.cmd('TSUpdate')
end
end
})
vim.pack.add({
{ src = "https://github.com/tpope/vim-sleuth.git" },
{ src = "https://github.com/neovim/nvim-lspconfig.git" },
{ src = "https://github.com/nvim-treesitter/nvim-treesitter.git" },
{ src = "https://github.com/mellow-theme/mellow.nvim.git" },
{ src = "https://github.com/Saghen/blink.cmp.git" },
{ src = "https://github.com/Saghen/blink.lib.git" },
{ src = "https://github.com/giuxtaposition/blink-cmp-copilot.git" },
{ src = "https://github.com/lewis6991/gitsigns.nvim.git" },
{ src = "https://github.com/nvim-telescope/telescope.nvim.git" },
{ src = "https://github.com/nvim-telescope/telescope-ui-select.nvim.git" },
{ src = "https://github.com/akinsho/toggleterm.nvim.git" },
{ src = "https://github.com/nvim-lua/plenary.nvim.git" },
{ src = "https://github.com/folke/sidekick.nvim.git" },
{ src = "https://github.com/olimorris/codecompanion.nvim.git" },
{ src = "https://github.com/ravitemer/codecompanion-history.nvim.git" },
{ src = "https://github.com/mason-org/mason.nvim.git" },
{ src = "https://github.com/mason-org/mason-lspconfig.nvim.git" },
{ src = "https://github.com/nvim-neotest/nvim-nio.git" },
{ src = "https://github.com/jay-babu/mason-nvim-dap.nvim.git" },
{ src = "https://github.com/mfussenegger/nvim-dap.git" },
{ src = "https://github.com/rcarriga/nvim-dap-ui.git" },
{ src = "https://github.com/theHamsta/nvim-dap-virtual-text.git" },
{ src = "https://github.com/chomosuke/typst-preview.nvim.git" },
{ src = "https://github.com/echasnovski/mini.icons.git" },
{ src = "https://github.com/nvim-lualine/lualine.nvim.git" },
{ src = "https://github.com/folke/snacks.nvim.git" },
{ src = "https://github.com/j-hui/fidget.nvim.git" },
{ src = "https://github.com/b0o/incline.nvim.git" },
{ src = "https://github.com/lervag/vimtex.git" },
{ src = "https://github.com/MeanderingProgrammer/render-markdown.nvim.git" },
{ src = "https://github.com/folke/lazydev.nvim.git" },
{ src = "https://github.com/folke/which-key.nvim.git" },
{ src = "https://github.com/hat0uma/csvview.nvim.git" },
{ src = "https://github.com/tpope/vim-fugitive.git" },
{ src = "https://github.com/rbong/vim-flog.git" },
{ src = "https://github.com/tpope/vim-surround.git" },
{ src = "https://github.com/midoBB/nvim-quicktype.git" },
{ src = "https://github.com/MunifTanjim/nui.nvim.git" },
{ src = "https://github.com/esmuellert/codediff.nvim.git" },
{ src = "https://github.com/archie-judd/telescope-words.nvim.git" },
{ src = "https://github.com/rachartier/tiny-inline-diagnostic.nvim.git" },
{ src = "https://github.com/duane9/nvim-rg.git" },
{ src = "https://github.com/AckslD/nvim-neoclip.lua.git" },
{ src = "https://github.com/kkharji/sqlite.lua" },
{ src = "https://github.com/fdavies93/daily-notes.nvim.git" },
{ src = "https://github.com/stevearc/oil.nvim.git" },
{ src = "https://github.com/emrearmagan/dockyard.nvim.git" },
{ src = "https://github.com/archie-judd/blink-cmp-words.git" },
{ src = "https://github.com/Sang-it/fluoride.git" },
{ src = "https://github.com/jbyuki/venn.nvim.git" },
{ src = "https://github.com/erichlf/devcontainer-cli.nvim.git" },
{ src = "https://github.com/folke/todo-comments.nvim.git" },
{ src = "https://github.com/folke/trouble.nvim.git" },
{ src = "https://github.com/fei6409/log-highlight.nvim.git" },
{ src = "https://github.com/lukas-reineke/indent-blankline.nvim.git" },
{ src = "https://github.com/TheGLander/indent-rainbowline.nvim.git" },
{ src = "https://github.com/mr-u0b0dy/crazy-coverage.nvim.git" },
})
vim.keymap.set('n', '<leader>U', function()
vim.pack.update()
end, { desc = 'Update pack (:w to apply)' })
local toggleterm = require("toggleterm")
toggleterm.setup { float_opts = { border = 'curved', zindex = 500 } }
local Terminal = require("toggleterm.terminal").Terminal
local floatterm = Terminal:new { direction = 'float', hidden = true }
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]])
vim.keymap.set({ 'n', 't' }, '<A-i>', function()
floatterm:toggle()
end, { desc = 'Toggle floating terminal' })
local btop_term
vim.keymap.set({ "n", "t" }, "<A-p>", function()
if not btop_term then
btop_term = Terminal:new({
direction = "float", cmd = "btop", hidden = true, close_on_exit = true,
})
btop_term:open()
return
end
if btop_term:is_open() then
btop_term:shutdown()
btop_term = nil
else
btop_term:open()
end
end, { desc = "Toggle floating btop-terminal" })
local mellow_config = require("mellow_config")
mellow_config.setup()
require("nvim-treesitter").setup({
ensure_installed = {
"c", "cpp", "lua",
"vim", "vimdoc",
"markdown", "rust", "python",
"javascript", "java",
},
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
once = true,
callback = function()
require("lazydev").setup({
library = { { path = "${3rd}/luv/library", words = { "vim%.uv" } } },
integrations = { lspconfig = true, cmp = true },
})
end,
})
local servers = {
"lua_ls", "rust_analyzer", "clangd", "pyright", "tinymist", "ts_ls", "jdtls", "texlab",
"wgsl_analyzer"
}
require("mason").setup {}
require("mason-lspconfig").setup {
ensure_installed = servers,
automatic_installation = true,
automatic_enable = { exclude = servers },
}
local blink = require('blink.cmp')
blink.build():wait(10000)
blink.setup {
sources = {
default = { 'lsp', 'path' },
per_filetype = {
markdown = { inherit_defaults = true, "dictionary" },
text = { inherit_defaults = true, "dictionary" },
typst = { inherit_defaults = true, "dictionary" },
latex = { inherit_defaults = true, "dictionary" },
lua = { inherit_defaults = true, 'lazydev' },
},
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
thesaurus = {
name = "blink-cmp-words",
module = "blink-cmp-words.thesaurus",
},
dictionary = {
name = "blink-cmp-words",
module = "blink-cmp-words.dictionary",
score_offset = -100,
},
},
},
completion = {
menu = { draw = { treesitter = { "lsp" } }, },
documentation = { auto_show = true, treesitter_highlighting = true, },
},
signature = { enabled = true, },
fuzzy = { implementation = "prefer_rust_with_warning" },
}
local capabilities = blink.get_lsp_capabilities()
vim.lsp.config('lua_ls', {
capabilities = capabilities,
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath('config')
and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc'))
then
return
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua or {}, {
runtime = { version = 'LuaJIT' },
workspace = {
checkThirdParty = false,
library = { vim.env.VIMRUNTIME },
},
})
end,
})
for _, server in ipairs(servers) do
vim.lsp.config(server, {
capabilities = capabilities,
})
vim.lsp.enable(server)
end
-- Trigger FileType for loaded buffers to ensure LSP attaches immediately
vim.schedule(function()
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].filetype ~= "" then
vim.api.nvim_exec_autocmds("FileType", { buffer = buf })
end
end
end)
-- DAP stack is loaded lazily on first use (see load_dap below) to keep startup fast.
local dap, dapui
local dap_loaded = false
local function load_dap()
if dap_loaded then
return
end
dap_loaded = true
require("mason-nvim-dap").setup {
ensure_installed = { "codelldb", "debugpy" },
automatic_installation = true,
}
dap = require("dap")
dap.adapters.codelldb = {
type = 'server',
port = "${port}",
executable = {
-- Mason installs codelldb here:
command = vim.fn.stdpath("data") .. "/mason/bin/codelldb",
args = { "--port", "${port}" },
}
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
require("nvim-dap-virtual-text").setup {}
dapui = require('dapui')
dapui.setup()
local dap_keymaps = {
{ 'n', '<Up>', dap.step_out, 'DAP Step Out' },
{ 'n', '<Down>', dap.step_into, 'DAP Step Into' },
{ 'n', '<Left>', dap.continue, 'DAP Continue' },
{ 'n', '<Right>', dap.step_over, 'DAP Step Over' },
{ 'n', '<S-Right>', dap.run_to_cursor, 'DAP Run to Cursor' },
}
local function set_dap_keymaps()
for _, map in ipairs(dap_keymaps) do
vim.keymap.set(map[1], map[2], map[3], { desc = map[4] })
end
end
local function unset_dap_keymaps()
for _, map in ipairs(dap_keymaps) do
pcall(vim.keymap.del, map[1], map[2])
end
end
dap.listeners.after.event_initialized["dap_keymaps"] = set_dap_keymaps
dap.listeners.after.event_terminated["dap_keymaps"] = unset_dap_keymaps
dap.listeners.after.event_exited["dap_keymaps"] = unset_dap_keymaps
end
vim.keymap.set('n', '<A-d>', function()
load_dap()
dapui.toggle()
end, { desc = "Toggle Debug UI" })
vim.keymap.set('n', '<leader>dr', function()
load_dap()
dap.toggle_breakpoint()
dapui.toggle()
dap.continue()
end, { desc = "Debug run to current line" })
vim.keymap.set('n', '<leader>db', function()
load_dap()
dap.toggle_breakpoint()
end, { desc = "Toggle Breakpoint" })
vim.keymap.set('n', '<leader>ds', function()
load_dap()
dap.continue()
end, { desc = "DAP Start" })
vim.keymap.set('n', '<leader>dR', function()
load_dap()
dap.restart()
end, { desc = "DAP Restart" })
vim.keymap.set('n', '<leader>dq', function()
load_dap()
dap.stop()
end, { desc = "DAP Quit / Stop" })
local icons = {
ERROR = ' ',
WARN = ' ',
INFO = ' ',
HINT = ' ',
DEBUG = ' ',
NOTIFICATION = ' ',
checkmark = ' ',
x = ' ',
FERRIS = ' ',
}
require('mini.icons').setup()
MiniIcons.mock_nvim_web_devicons()
vim.diagnostic.config({
virtual_text = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = icons.ERROR,
[vim.diagnostic.severity.WARN] = icons.WARN,
[vim.diagnostic.severity.INFO] = icons.INFO,
[vim.diagnostic.severity.HINT] = icons.HINT,
},
},
})
local function yank_diag_message(register, notify_msg)
local lnum = vim.api.nvim_win_get_cursor(0)[1] - 1
local diags = vim.diagnostic.get(0, { lnum = lnum })
if #diags == 0 then
vim.notify("No diagnostic on current line", vim.log.levels.INFO)
return
end
vim.fn.setreg(register, diags[1].message)
vim.notify(notify_msg, vim.log.levels.INFO)
end
vim.keymap.set("n", "yd", function()
yank_diag_message('"', "Diagnostic copied")
end, { desc = "Yank diagnostic message" })
vim.keymap.set("n", "<leader>yd", function()
yank_diag_message('+', "Diagnostic copied to clipboard")
end, { desc = "Yank diagnostic message" })
vim.keymap.set('n', 'gK', function()
local new_config = not vim.diagnostic.config().underline
vim.diagnostic.config({ underline = new_config })
end, { desc = 'Toggle diagnostic underline' })
vim.keymap.set("n", "<leader>dt", "<cmd>TinyInlineDiag toggle<cr>", { desc = "Toggle diagnostics" })
vim.keymap.set("n", "<leader>Q", vim.diagnostic.setqflist, { desc = "Add buffer diagnostics to quickfix list" })
local gitsigns = require('gitsigns')
gitsigns.setup {}
vim.keymap.set('n', '<leader>gB', gitsigns.blame, { desc = 'Toggle git blame' })
vim.keymap.set('n', '[c', function() gitsigns.nav_hunk('prev') end, { desc = 'Jump to previous git Change (hunk)' })
vim.keymap.set('n', ']c', function() gitsigns.nav_hunk('next') end, { desc = 'Jump to next git Change (hunk)' })
vim.keymap.set('n', '<leader>gd', ':CodeDiff<CR>', { desc = 'Toggle git split code diff' })
local telescope = require("telescope")
local builtin = require('telescope.builtin')
local actions = require('telescope.actions')
telescope.setup {
defaults = {
layout_config = { width = 0.91 },
color_devicons = true,
},
}
telescope.load_extension("ui-select")
telescope.load_extension("todo-comments")
vim.keymap.set('n', '<leader> ', builtin.buffers, { desc = 'Telescope opened buffers' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>sv', function()
builtin.find_files({
attach_mappings = function(_, _)
actions.select_default:replace(actions.select_vertical)
return true
end,
})
end, { desc = 'Telescope find files (split)' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = 'Telescope keymap' })
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = 'Telescope help tags' })
vim.keymap.set('n', '<leader>gb', builtin.git_branches, { desc = 'Telescope git branches' })
vim.keymap.set('n', '<leader>gs', builtin.git_status, { desc = 'Telescope git status' })
vim.keymap.set('n', '<leader>gS', builtin.git_stash, { desc = 'Telescope git stashes' })
vim.keymap.set('n', '<leader>gk', builtin.keymaps, { desc = 'Telescope key maps' })
vim.keymap.set('n', '<leader>sq', function()
builtin.diagnostics({ wrap_results = true, line_width = "full" })
end, { desc = 'Telescope dianostics' })
vim.keymap.set('n', 'z=', builtin.spell_suggest, { noremap = true, desc = 'Telescope spell suggest' })
vim.keymap.set("n", "<leader>st", "<cmd>TodoTelescope<CR>", { desc = "Telescope: search TODO/FIX/NOTE" })
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(_)
vim.lsp.inlay_hint.enable(true)
vim.keymap.set('n', 'grd', builtin.lsp_definitions, { desc = 'Telescope LSP definitions' })
vim.keymap.set('n', 'grr', builtin.lsp_references, { desc = 'Telescope LSP references' })
vim.keymap.set('n', 'gri', builtin.lsp_implementations, { desc = 'Telescope LSP implementations' })
vim.keymap.set('n', 'grD', vim.lsp.buf.declaration, { desc = 'Telescope LSP declaration' })
vim.keymap.set('n', 'gro', builtin.lsp_document_symbols, { desc = 'Telescope LSP document symbols' })
vim.keymap.set('n', 'grt', builtin.lsp_type_definitions, { desc = 'Telescope LSP type definitions' })
end
})
-- CodeCompanion is loaded lazily on first use to keep startup fast.
local codecompanion_loaded = false
local function load_codecompanion()
if codecompanion_loaded then
return
end
codecompanion_loaded = true
require("codecompanion").setup {
extensions = { history = { enabled = true } },
display = {
chat = {
intro_message = "Blechdepp Chat",
},
},
}
end
vim.keymap.set('n', '<leader>co', function()
load_codecompanion()
vim.cmd('CodeCompanionChat')
end, { noremap = true, desc = 'CodeCompanionChat Open' })
vim.keymap.set('n', '<leader>ch', function()
load_codecompanion()
vim.cmd('CodeCompanionHistory')
end, { noremap = true, desc = 'CodeCompanion History' })
-- Sidekick is loaded lazily on first use to keep startup fast.
local sidekick_loaded = false
vim.keymap.set({ 'n', 't' }, '<A-c>', function()
if not sidekick_loaded then
sidekick_loaded = true
require("sidekick").setup {
nes = { enabled = false },
cli = { win = { layout = "right" } },
}
end
require('sidekick.cli').toggle()
vim.cmd('stopinsert')
end, { noremap = true, desc = 'Toggle Sidekick (Agent)' })
require("typst-preview").setup {}
vim.keymap.set('n', '<leader>tp', ':TypstPreview<CR>', { desc = 'View typst preview' })
local helpers = require 'incline.helpers'
local devicons = require 'nvim-web-devicons'
require('incline').setup {
window = {
padding = 0,
margin = { horizontal = 0 },
},
render = function(props)
-- local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
local fullpath = vim.api.nvim_buf_get_name(props.buf)
local root = vim.fs.root(props.buf, { '.git', 'pyproject.toml', 'package.json' }) or vim.fn.getcwd()
local filename = vim.fn.fnamemodify(fullpath, ':~:.')
if fullpath:find('^' .. vim.pesc(root) .. '/') then
filename = fullpath:sub(#root + 2) -- strip "<root>/"
end
if filename == '' then
filename = '[No Name]'
end
local ft_icon, ft_color = devicons.get_icon_color(filename)
local modified = vim.bo[props.buf].modified
return {
ft_icon and { ' ', ft_icon, ' ', guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or
'',
' ',
{ filename, gui = modified and 'bold,italic' or 'bold' },
' ',
-- guibg = '#44406e',
}
end,
}
require('lualine').setup {
options = {
section_separators = '', component_separators = '│',
},
}
local snacks = require("snacks")
snacks.setup {
scroll = { enabled = false },
zen = {
toggles = {
dim = false,
git_signs = false,
diagnostics = false,
},
enabled = true,
}
}
vim.keymap.set('n', '<leader>z', function() snacks.zen() end, { desc = 'Snacks Zen' })
require("fidget").setup {
notification = {
configs = {
default = vim.tbl_extend("force", require("fidget.notification").default_config, {
icon = icons.NOTIFICATION,
debug_annote = icons.DEBUG,
error_annote = icons.ERROR,
info_annote = icons.INFO,
warn_annote = icons.WARN,
}),
},
override_vim_notify = true,
window = { winblend = 0, border = "rounded" },
},
progress = { display = { done_icon = icons.checkmark } },
}
vim.keymap.set('n', '<leader>M', ':Fidget history<CR>', { desc = 'Show fidget message history' })
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = { '*.tex', '*.typ', '*.md' },
command = 'setlocal spell spelllang=en_us'
})
vim.keymap.set('n', '<leader>vs', function()
if vim.wo.spell then
vim.wo.spell = false
vim.notify(icons.x .. ' Disabled spellcheck', vim.log.levels.INFO)
else
vim.wo.spell = true
vim.o.spelllang = { 'en_us' }
vim.notify(icons.checkmark .. 'Enabled spellcheck', vim.log.levels.INFO)
end
end, { desc = 'Toggle spellcheck' })
require("render-markdown").setup {
file_types = { "markdown", "codecompanion" },
overrides = {
filetype = {
markdown = {},
codecompanion = {},
}
}
}
require("which-key").setup {
delay = 800,
win = { border = "rounded" }
}
require("csvview").setup {}
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*.csv",
command = "CsvViewEnable",
})
vim.api.nvim_create_user_command("LogHours", function()
local file = os.getenv("NVIM_WORKHOURS_FILE")
if file and file ~= "" then
vim.cmd("edit " .. file)
else
vim.notify("NVIM_WORKHOURS_FILE is not set", vim.log.levels.ERROR)
end
end, { desc = "Open work hours CSV file" })
-- Umlaute:
local chars = {
a = 'ä',
A = 'Ä',
o = 'ö',
O = 'Ö',
u = 'ü',
U = 'Ü',
s = 'ß'
}
for key, val in pairs(chars) do
vim.keymap.set('i', '<M-' .. key .. '>', val, { noremap = true, silent = true })
end
vim.keymap.set(
"n",
"<Leader>sd",
telescope.extensions.telescope_words.search_dictionary,
{ desc = "Telescope: search dictionary" }
)
vim.keymap.set(
"n",
"<Leader>sD",
telescope.extensions.telescope_words.search_thesaurus,
{ desc = "Telescope: search thesaurus" }
)
require("neoclip").setup {
enable_persistent_history = true,
}
telescope.load_extension('neoclip')
vim.keymap.set(
"n",
"<Leader>h",
telescope.extensions.neoclip.default,
{ desc = "Telescope: search yank clipboard (history)" }
)
require("daily-notes").setup {}
vim.keymap.set('n', '<leader>nn', ":DailyNote<CR>", { desc = "New daily Note" })
vim.keymap.set('n', '<leader>sn', function()
builtin.find_files({
cwd = vim.fn.expand("~/daily-notes"),
prompt_title = "Daily Notes",
})
end, { desc = "Search Daily Notes" })
local oil = require("oil")
oil.setup {
lsp_file_methods = {
enabled = true,
timeout_ms = 1000,
autosave_changes = true,
},
columns = {
"icon",
},
preview_split = "right",
float = {
border = "rounded",
preview_split = "right",
padding = 4,
override = function(conf)
conf.zindex = 51
return conf
end
},
}
vim.keymap.set('n', '<A-e>', oil.toggle_float, { desc = "Toggle Oil Float" })
vim.keymap.set('n', '<leader>so', ":Oil<CR>", { desc = "Oil" })
require("dockyard").setup {}
vim.keymap.set('n', '<leader>dy', ":DockyardFloat<CR>", { desc = "Open Dock-Yard" })
local fluoride = require("fluoride")
fluoride.setup {
window = {
border = "rounded",
},
}
vim.keymap.set('n', '<A-\'>', fluoride.toggle, { desc = "Toggle Fluoride" })
-- venn.nvim: enable or disable keymappings
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.b.venn_enabled = true
vim.cmd [[setlocal ve=all]]
-- draw a line on HJKL keystokes
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
-- draw a box by pressing "f" with visual selection
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
else
vim.cmd [[setlocal ve=]]
vim.api.nvim_buf_del_keymap(0, "n", "J")
vim.api.nvim_buf_del_keymap(0, "n", "K")
vim.api.nvim_buf_del_keymap(0, "n", "L")
vim.api.nvim_buf_del_keymap(0, "n", "H")
vim.api.nvim_buf_del_keymap(0, "v", "f")
vim.b.venn_enabled = nil
end
end
-- toggle keymappings for venn using <leader>v
vim.api.nvim_set_keymap('n', '<leader>vn', ":lua Toggle_venn()<CR>", { noremap = true })
require("devcontainer-cli").setup({
-- only the most useful options shown; see full config below
interactive = false,
toplevel = true,
remove_existing_container = true,
-- dotfiles_repository = "https://github.com/erichlf/dotfiles.git",
-- dotfiles_branch = "devcontainer-cli",devcontainercli
-- dotfiles_targetPath = "~/dotfiles",
-- dotfiles_installCommand = "install.sh",
shell = "bash",
nvim_binary = "nvim",
log_level = "debug",
console_level = "info",
})
require("todo-comments").setup {}
require("trouble").setup {}
vim.keymap.set("n", "<leader>qq", "<cmd>Trouble diagnostics toggle<CR>", { desc = "Diagnostics (Trouble)" })
vim.keymap.set("n", "<leader>qx", "<cmd>Trouble qflist toggle<CR>", { desc = "Quickfix (Trouble)" })
local opts = {
indent = { char = '' }
}
require("ibl").setup(require("indent-rainbowline").make_opts(opts, {
color_transparency = 0.1,
colors = mellow_config.ibl_rainbow_colors()
}))
require("left")
require("crazy-coverage").setup {
coverage_dirs = {
"target/llvm-cov-target",
"build/coverage",
}
}
-- Init private work plugins:
require("work_private").setup {
capabilities = capabilities
}