-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
707 lines (636 loc) · 20.1 KB
/
Copy pathinit.lua
File metadata and controls
707 lines (636 loc) · 20.1 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
-- ================================
-- init.lua - Kyle B, 20/03/2026
-- ================================
-- ================================
-- OPTIONS
-- ================================
vim.opt.termguicolors = true -- use more colors
vim.g.have_nerd_font = true -- show nerd font icons
vim.cmd.colorscheme("catppuccin") -- the best colorscheme don't argue
vim.opt.scrolloff = 10 -- keep 10 lines vertically on screen
vim.opt.sidescrolloff = 10 -- keep 10 lines horizontally on screen
vim.opt.colorcolumn = "120" -- show a line down screen on char pos 120
vim.cmd("set expandtab") -- use spaces instead of tabs
vim.cmd("set tabstop=2") -- tab width
vim.cmd("set softtabstop=2") -- soft tab stop not tabs on tab/bkspace
vim.cmd("set shiftwidth=2") -- indent width
vim.opt.number = true -- show line numbers
vim.opt.relativenumber = true -- line numbers relative to cursor
vim.opt.cursorline = true -- current line highlighted
vim.opt.signcolumn = "yes" -- space for signs like lsp and git stuff
vim.opt.showmode = false -- hide mode (custom statusline shows it)
vim.opt.ignorecase = true -- ignore case when searching
vim.opt.smartcase = true -- case sensitive when mixed case search
vim.opt.splitright = true -- split to the right
vim.opt.splitbelow = true -- split down
vim.opt.fillchars = { eob = " " } -- hide "~" on empty lines
vim.opt.wrap = false -- turn off wrapping
vim.opt.foldmethod = "expr" -- use expression for folding
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- use treesitter for folding
vim.opt.foldlevel = 99 -- start with all folds open
vim.opt.swapfile = false -- turn off swapfile
local undodir = vim.fn.expand("~/.vim/undodir")
if
vim.fn.isdirectory(undodir) == 0 -- create dir if not exists
then
vim.fn.mkdir(undodir, "p")
end
vim.opt.undofile = true -- keep undo history
vim.opt.undodir = undodir -- set dir for undo history
-- ================================
-- STATUSLINE
-- ================================
-- Git Branch
local cached_branch = ""
local last_check = 0
local function git_branch()
local now = vim.loop.now()
if now - last_check > 5000 then
cached_branch = vim.fn.system("git branch --show-current 2>/dev/null | tr -d '\n'")
last_check = now
end
if cached_branch ~= "" then
return "\u{e725} " .. cached_branch .. " "
end
return ""
end
-- File Type
local function file_type()
local ft = vim.bo.filetype
local icons = {
lua = "\u{e620} ",
python = "\u{e73c} ",
javascript = "\u{e74e} ",
typescript = "\u{e628} ",
javascriptreact = "\u{e7ba} ",
typescriptreact = "\u{e7ba} ",
html = "\u{e736} ",
css = "\u{e749} ",
scss = "\u{e749} ",
json = "\u{e60b} ",
markdown = "\u{e73e} ",
vim = "\u{e62b} ",
sh = "\u{f489} ",
bash = "\u{f489} ",
zsh = "\u{f489} ",
rust = "\u{e7a8} ",
go = "\u{e724} ",
c = "\u{e61e} ",
cpp = "\u{e61d} ",
java = "\u{e738} ",
php = "\u{e73d} ",
ruby = "\u{e739} ",
swift = "\u{e755} ",
kotlin = "\u{e634} ",
dart = "\u{e798} ",
elixir = "\u{e62d} ",
haskell = "\u{e777} ",
sql = "\u{e706} ",
yaml = "\u{f481} ",
toml = "\u{e615} ",
xml = "\u{f05c} ",
dockerfile = "\u{f308} ",
gitcommit = "\u{f418} ",
gitconfig = "\u{f1d3} ",
vue = "\u{fd42} ",
svelte = "\u{e697} ",
astro = "\u{e628} ",
}
if ft == "" then
return " \u{f15b} "
end
return ((icons[ft] or " \u{f15b} ") .. ft)
end
local function file_size()
local size = vim.fn.getfsize(vim.fn.expand("%"))
if size < 0 then
return ""
end
local size_str
if size < 1024 then
size_str = size .. "B"
elseif size < 1024 * 1024 then
size_str = string.format("%.1fK", size / 1024)
else
size_str = string.format("%.1fM", size / 1024 / 1024)
end
return " \u{f016} " .. size_str .. " " -- nf-fa-file_o
end
local function mode_icon()
local mode = vim.fn.mode()
local modes = {
n = " \u{f121} NORMAL",
i = " \u{f11c} INSERT",
v = " \u{f0168} VISUAL",
V = " \u{f0168} V-LINE",
["\22"] = " \u{f0168} V-BLOCK",
c = " \u{f120} COMMAND",
s = " \u{f0c5} SELECT",
S = " \u{f0c5} S-LINE",
["\19"] = " \u{f0c5} S-BLOCK",
R = " \u{f044} REPLACE",
r = " \u{f044} REPLACE",
["!"] = " \u{f489} SHELL",
t = " \u{f120} TERMINAL",
}
return modes[mode] or (" \u{f059} " .. mode)
end
_G.mode_icon = mode_icon
_G.git_branch = git_branch
_G.file_type = file_type
_G.file_size = file_size
vim.cmd([[
highlight StatusLineBold gui=bold cterm=bold
]])
local function setup_dynamic_statusline()
vim.api.nvim_set_hl(0, "StatusLine", { bg = "#313244", fg = "#cdd6f4" })
vim.api.nvim_set_hl(0, "StatusLineNC", { bg = "#181825", fg = "#585b70" }) -- inactive windows
vim.api.nvim_set_hl(0, "StatusLineBold", { bold = true, bg = "#313244", fg = "#cdd6f4" })
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter" }, {
callback = function()
vim.opt_local.statusline = table.concat({
" ",
"%#StatusLineBold#",
"%{v:lua.mode_icon()}",
"%#StatusLine#",
" \u{e0b1} %f %h%m%r",
"%{v:lua.git_branch()}",
"\u{e0b1} ",
"%{v:lua.file_type()}",
" \u{e0b1} ",
"%{v:lua.file_size()}",
"%=",
" %l:%c %P ",
})
end,
})
vim.api.nvim_set_hl(0, "StatusLineBold", { bold = true })
vim.api.nvim_create_autocmd({ "WinLeave", "BufLeave" }, {
callback = function()
vim.opt_local.statusline = " %f %h%m%r \u{e0b1} %{v:lua.file_type()} %= %l:%c %P "
end,
})
end
setup_dynamic_statusline()
-- ================================
-- KEYMAPS
-- ================================
vim.g.mapleader = " " -- leader key
vim.g.maplocalleader = "\\" -- local leader key
vim.keymap.set("n", "<leader>x", "<cmd>restart<cr>", { desc = "restart nvim" })
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>", { desc = "tmux-sessionizer" })
vim.keymap.set("n", "<leader>r", "<cmd>update<cr><cmd>make!<cr>", { desc = "run makeprg" })
vim.keymap.set("n", "<leader>R", ":set makeprg=", { desc = "set makeprg" })
vim.keymap.set("n", "<leader>e", "<cmd>Ex<cr>", { desc = "open netrw" })
vim.keymap.set("n", "<leader>bd", "<cmd>bdelete<cr>", { desc = "delete buffer" })
vim.keymap.set("n", "<leader>bn", "<cmd>bnext<cr>", { desc = "next buffer" })
vim.keymap.set("n", "<leader>bp", "<cmd>bprevious<cr>", { desc = "previous buffer" })
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "yank to system clipboard" })
vim.keymap.set("n", "n", "nzzzv", { desc = "search keeps result centered" })
vim.keymap.set("n", "N", "Nzzzv", { desc = "search keeps result centered" })
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "keep CTRL-d centered" })
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "keep CTRL-u centered" })
vim.keymap.set("n", "G", "Gzz", { desc = "center bottom line" })
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>", { desc = "clear highlight" })
vim.api.nvim_set_keymap("i", "jj", "<Esc>", { noremap = false, desc = "`jj` to exit insert mode" })
vim.keymap.set("n", "<leader>sv", "<cmd>vsplit<cr>", { desc = "split vertically" })
vim.keymap.set("n", "<leader>sh", "<cmd>split<cr>", { desc = "split horizontally" })
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "move to the left window" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "move to the down window" })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "move to the up window" })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "move to the right window" })
vim.keymap.set("n", "<C-Up>", "<cmd>resize -2<cr>", { desc = "change window height" })
vim.keymap.set("n", "<C-Down>", "<cmd>resize +2<cr>", { desc = "change window height" })
vim.keymap.set("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "change window width" })
vim.keymap.set("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "change window width" })
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "move line down" })
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "move line up" })
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "move selection down" })
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "move selection up" })
vim.keymap.set("v", ">", ">gv", { desc = "indent left and reselect" })
vim.keymap.set("v", "<", "<gv", { desc = "indent left and reselect" })
-- ================================
-- AUTOCMDS
-- ================================
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = true })
-- highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking text",
group = augroup,
callback = function()
vim.highlight.on_yank()
end,
})
-- wrap and spellcheck on md files
vim.api.nvim_create_autocmd("FileType", {
group = augroup,
pattern = { "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.spell = true
end,
})
-- ================================
-- PLUGINS (vim.pack)
-- ================================
local function packadd(name)
vim.cmd("packadd " .. name)
end
vim.pack.add({
"https://github.com/wakatime/vim-wakatime",
"https://github.com/ibhagwan/fzf-lua",
"https://github.com/rcarriga/nvim-notify",
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/NeogitOrg/neogit",
"https://github.com/folke/which-key.nvim",
"https://github.com/folke/todo-comments.nvim",
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate",
},
"https://github.com/lewis6991/gitsigns.nvim",
-- LSP
"https://github.com/neovim/nvim-lspconfig",
"https://github.com/mason-org/mason.nvim",
"https://github.com/mason-org/mason-lspconfig.nvim",
"https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim",
"https://github.com/creativenull/efmls-configs-nvim",
"https://github.com/Saghen/blink.cmp",
"https://github.com/L3MON4D3/LuaSnip",
"https://github.com/nvimdev/lspsaga.nvim",
})
packadd("vim-wakatime")
packadd("fzf-lua")
packadd("nvim-notify")
packadd("plenary.nvim")
packadd("neogit")
packadd("which-key.nvim")
packadd("todo-comments.nvim")
packadd("nvim-treesitter")
packadd("gitsigns.nvim")
-- LSP
packadd("nvim-lspconfig")
packadd("mason.nvim")
packadd("mason-lspconfig.nvim")
packadd("mason-tool-installer.nvim")
packadd("efmls-configs-nvim")
packadd("blink.cmp")
packadd("LuaSnip")
packadd("lspsaga.nvim")
-- ================================
-- PLUGINS (config)
-- ================================
-- Treesitter
local setup_treesitter = function()
local treesitter = require("nvim-treesitter")
treesitter.setup({})
local ensure_installed = {
"vim",
"vimdoc",
"rust",
"c",
"cpp",
"lua",
"html",
"css",
"javascript",
"typescript",
"astro",
"svelte",
"markdown",
"bash",
"python",
}
local config = require("nvim-treesitter.config")
local already_installed = config.get_installed()
local parsers_to_install = {}
for _, parser in ipairs(ensure_installed) do
if not vim.tbl_contains(already_installed, parser) then
table.insert(parsers_to_install, parser)
end
end
if #parsers_to_install > 0 then
treesitter.install(parsers_to_install)
end
local group = vim.api.nvim_create_augroup("TreeSitterConfig", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
group = group,
callback = function(args)
if vim.list_contains(treesitter.get_installed(), vim.treesitter.language.get_lang(args.match)) then
vim.treesitter.start(args.buf)
end
end,
})
end
setup_treesitter()
-- Notify
require("notify").setup({})
-- FZF
require("fzf-lua").setup({})
vim.keymap.set("n", "<leader>ff", function()
require("fzf-lua").files()
end, { desc = "Find files" })
vim.keymap.set("n", "<leader>fg", function()
require("fzf-lua").live_grep()
end, { desc = "Live grep" })
vim.keymap.set("n", "<leader>fb", function()
require("fzf-lua").buffers()
end, { desc = "Find buffers" })
vim.keymap.set("n", "<leader>fh", function()
require("fzf-lua").help_tags()
end, { desc = "Help tags" })
vim.keymap.set("n", "<leader>fx", function()
require("fzf-lua").diagnostics_document()
end, { desc = "Document diagnostics" })
vim.keymap.set("n", "<leader>fX", function()
require("fzf-lua").diagnostics_workspace()
end, { desc = "Workspace diagnostics" })
-- Neogit
require("neogit").setup({})
vim.keymap.set("n", "<leader>gg", "<cmd>Neogit<cr>", { desc = "Open Neogit" })
-- which-key
require("which-key").setup({})
vim.keymap.set("n", "<leader>?", function()
require("which-key").show({ global = false })
end, { desc = "Buffer Local Keymaps (which-key)" })
require("todo-comments").setup({})
-- Gitsigns
require("gitsigns").setup({})
-- lspsaga
require("lspsaga").setup({
ui = {
code_action = "",
},
})
-- ================================
-- LSP
-- ================================
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"pyright",
"bashls",
"ast_grep",
"clangd",
"jdtls",
"rust_analyzer",
"efm",
},
})
require("mason-tool-installer").setup({
ensure_installed = {
"ast_grep",
"astro-language-server",
-- "luacheck", (commented because installed with system)
"stylua",
"flake8",
"black",
"prettierd",
"eslint_d",
"fixjson",
"shellcheck",
"shfmt",
"cpplint",
"clang-format",
},
})
local diagnostic_signs = {
Error = " ",
Warn = " ",
Hint = "",
Info = "",
}
vim.diagnostic.config({
virtual_text = { prefix = "●", spacing = 4, current_line = true },
signs = {
text = {
[vim.diagnostic.severity.ERROR] = diagnostic_signs.Error,
[vim.diagnostic.severity.WARN] = diagnostic_signs.Warn,
[vim.diagnostic.severity.INFO] = diagnostic_signs.Info,
[vim.diagnostic.severity.HINT] = diagnostic_signs.Hint,
},
},
underline = true,
update_in_insert = false,
severity_sort = true,
float = { border = "rounded", scope = "line", source = "always", header = "", prefix = "", focusable = false },
})
do
local orig = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or "rounded"
return orig(contents, syntax, opts, ...)
end
end
local function lsp_on_attach(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if not client then
return
end
local bufnr = ev.buf
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "<leader>gd", function()
require("fzf-lua").lsp_definitions({ jump_to_single_result = true })
end, vim.tbl_extend("force", opts, { desc = "Go to definition" }))
vim.keymap.set(
"n",
"<leader>gD",
vim.lsp.buf.definition,
vim.tbl_extend("force", opts, { desc = "Go to definition (native)" })
)
vim.keymap.set("n", "<leader>gS", function()
vim.cmd("vsplit")
vim.lsp.buf.definition()
end, vim.tbl_extend("force", opts, { desc = "Go to definition in split" }))
vim.keymap.set(
"n",
"<leader>ca",
"<cmd>Lspsaga code_action<cr>",
vim.tbl_extend("force", opts, { desc = "Code action" })
)
vim.keymap.set(
"n",
"<leader>rn",
"<cmd>Lspsaga rename<cr>",
vim.tbl_extend("force", opts, { desc = "Rename symbol" })
)
vim.keymap.set(
"n",
"<leader>D",
"<cmd>Lspsaga show_line_diagnostics<cr>",
vim.tbl_extend("force", opts, { desc = "Show line diagnostics" })
)
vim.keymap.set(
"n",
"<leader>d",
"<cmd>Lspsaga show_cursor_diagnostics<cr>",
vim.tbl_extend("force", opts, { desc = "Show cursor diagnostics" })
)
vim.keymap.set(
"n",
"<leader>nd",
"<cmd>Lspsaga diagnostic_jump_next<cr>",
vim.tbl_extend("force", opts, { desc = "Next diagnostic" })
)
vim.keymap.set(
"n",
"<leader>pd",
"<cmd>Lspsaga diagnostic_jump_next<cr>",
vim.tbl_extend("force", opts, { desc = "Previous diagnostic" })
)
vim.keymap.set(
"n",
"K",
"<cmd>Lspsaga hover_doc<cr>",
vim.tbl_extend("force", opts, { desc = "Hover documentation" })
)
vim.keymap.set("n", "<leader>t", "<cmd>Lspsaga term_toggle<cr>", opts, { desc = "Toggle Floating Terminal" })
vim.keymap.set("n", "<leader>fd", function()
require("fzf-lua").lsp_definitions({ jump_to_single_result = true })
end, vim.tbl_extend("force", opts, { desc = "Find definitions" }))
vim.keymap.set("n", "<leader>fr", function()
require("fzf-lua").lsp_references()
end, vim.tbl_extend("force", opts, { desc = "Find references" }))
vim.keymap.set("n", "<leader>ft", function()
require("fzf-lua").lsp_typedefs()
end, vim.tbl_extend("force", opts, { desc = "Find type definitions" }))
vim.keymap.set("n", "<leader>fs", function()
require("fzf-lua").lsp_document_symbols()
end, vim.tbl_extend("force", opts, { desc = "Find document symbols" }))
vim.keymap.set("n", "<leader>fw", function()
require("fzf-lua").lsp_workspace_symbols()
end, vim.tbl_extend("force", opts, { desc = "Find workspace symbols" }))
vim.keymap.set("n", "<leader>fi", function()
require("fzf-lua").lsp_implementations()
end, vim.tbl_extend("force", opts, { desc = "Find implementations" }))
vim.keymap.set("n", "<leader>cf", vim.lsp.buf.format, { desc = "format buffer" })
if client:supports_method("textDocument/codeAction", bufnr) then
vim.keymap.set("n", "<leader>oi", function()
vim.lsp.buf.code_action({
context = { only = { "source.organizeImports" }, diagnostics = {} },
apply = true,
bufnr = bufnr,
})
vim.defer_fn(function()
vim.lsp.buf.format({ bufnr = bufnr })
end, 50)
end, vim.tbl_extend("force", opts, { desc = "Organize imports" }))
end
end
vim.api.nvim_create_autocmd("LspAttach", { group = augroup, callback = lsp_on_attach })
vim.keymap.set("n", "<leader>q", function()
vim.diagnostic.setloclist({ open = true })
end, { desc = "Open diagnostic list" })
vim.keymap.set("n", "<leader>dl", vim.diagnostic.open_float, { desc = "Show line diagnostics" })
require("blink.cmp").setup({
keymap = {
preset = "none",
["<C-Space>"] = { "show", "hide" },
["<CR>"] = { "accept", "fallback" },
["<C-j>"] = { "select_next", "fallback" },
["<C-k>"] = { "select_prev", "fallback" },
["<Tab>"] = { "snippet_forward", "fallback" },
["<S-Tab>"] = { "snippet_backward", "fallback" },
},
appearance = { nerd_font_variant = "mono" },
completion = { menu = { auto_show = true } },
sources = { default = { "lsp", "path", "buffer", "snippets" } },
snippets = {
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
},
fuzzy = {
implementation = "prefer_rust",
},
})
vim.lsp.config["*"] = {
capabilities = require("blink.cmp").get_lsp_capabilities(),
}
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = { globals = { "vim" } },
telemetry = { enable = false },
},
},
})
vim.lsp.config("pyright", {})
vim.lsp.config("bashls", {})
vim.lsp.config("ts_ls", {})
vim.lsp.config("rust_analyzer", {})
vim.lsp.config("astro_language_server", {})
vim.lsp.config("clangd", {})
vim.lsp.config("ast_grep", {})
vim.lsp.config("jdtls", {})
do
local luacheck = require("efmls-configs.linters.luacheck")
local stylua = require("efmls-configs.formatters.stylua")
local flake8 = require("efmls-configs.linters.flake8")
local black = require("efmls-configs.formatters.black")
local prettier_d = require("efmls-configs.formatters.prettier_d")
local eslint_d = require("efmls-configs.linters.eslint_d")
local fixjson = require("efmls-configs.formatters.fixjson")
local shellcheck = require("efmls-configs.linters.shellcheck")
local shfmt = require("efmls-configs.formatters.shfmt")
local cpplint = require("efmls-configs.linters.cpplint")
local clangfmt = require("efmls-configs.formatters.clang_format")
vim.lsp.config("efm", {
filetypes = {
"c",
"cpp",
"css",
"go",
"html",
"javascript",
"javascriptreact",
"json",
"jsonc",
"lua",
"markdown",
"python",
"sh",
"typescript",
"typescriptreact",
"vue",
"svelte",
},
init_options = { documentFormatting = true },
settings = {
languages = {
c = { clangfmt, cpplint },
cpp = { clangfmt, cpplint },
css = { prettier_d },
html = { prettier_d },
javascript = { eslint_d, prettier_d },
javascriptreact = { eslint_d, prettier_d },
json = { eslint_d, fixjson },
jsonc = { eslint_d, fixjson },
lua = { luacheck, stylua },
markdown = { prettier_d },
python = { flake8, black },
sh = { shellcheck, shfmt },
typescript = { eslint_d, prettier_d },
typescriptreact = { eslint_d, prettier_d },
vue = { eslint_d, prettier_d },
svelte = { eslint_d, prettier_d },
},
},
})
end
vim.lsp.enable({
"lua_ls",
"pyright",
"bashls",
"ts_ls",
"rust_analyzer",
"astro_language_server",
"clangd",
"ast_grep",
"jdtls",
"efm",
})