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
|
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"saghen/blink.cmp",
},
opts = {
servers = {
clangd = {
cmd = {
"clangd",
"--header-insertion=iwyu",
"--background-index",
"--clang-tidy",
"--log=verbose",
},
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
single_file_support = true,
},
cssls = {},
html = {},
jsonls = {},
lua_ls = {
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
diagnostics = {
globals = {
"vim",
"require",
},
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
enable = false,
},
},
},
},
marksman = {},
solargraph = {
cmd = {
vim.fn.expand('~/.local/share/nvim/mason/bin/solargraph'),
'stdio',
},
},
ts_ls = {},
},
},
config = function(_, opts)
local lspconfig = require("lspconfig")
local blink = require("blink.cmp")
for server, config in pairs(opts.servers) do
config.capabilities = blink.get_lsp_capabilities()
lspconfig[server].setup(config)
end
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then return end
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = args.buf })
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = args.buf })
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Lists all implementations", buffer = args.buf })
vim.keymap.set("n", "<Leader>cf", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
{ desc = "Formats a buffer", buffer = args.buf })
vim.keymap.set("v", "<C-f>", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
{ desc = "Formats a buffer", buffer = args.buf })
-- Disabled, kept temporarily here just for reference
if false and vim.bo.filetype == "lua" then
if client.supports_method("textDocument/formatting") then
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = args.buf,
callback = function()
vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
end,
})
end
end
end
})
vim.diagnostic.config({
underline = true,
virtual_text = { prefix = " ●", },
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
},
},
})
end,
},
}
|