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
|
vim.opt.cot = "menu,menuone,noinsert"
vim.opt.pumblend=5
local methods = vim.lsp.protocol.Methods
local map = vim.keymap.set
require("config.lsp.conform")
-- vim.lsp.config = {
-- ['clangd'] = require("config.lsp.clangd"),
-- ['zls'] = require("config.lsp.zls"),
-- }
local servers = {
clangd = {},
zls = {},
basedpyright = {},
ruff = {},
-- lua_ls = {},
nixd = {
nixd = {
formatting = {
command = { "nixfmt" },
},
},
},
cmake = {},
qmlls = {
cmd = {"qmlls", "-E"}
},
-- rust_analyzer = {}
}
local orig_util_open_floating_preview = 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_util_open_floating_preview(contents, syntax, opts, ...)
end
vim.diagnostic.config({
-- virtual_text = { prefix = "", virt_text_pos = "eol_right_align", },
-- virtual_text = true,
float = { border = "rounded" },
signs = false,
underline = true,
update_in_insert = false,
float = true,
jump = { float = true },
})
-- is completion visible
local function pumvisible()
return tonumber(vim.fn.pumvisible()) ~= 0
end
vim.api.nvim_create_autocmd("LspAttach", { callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client == nil then
return
end
client.server_capabilities.semanticTokensProvider = nil
vim.keymap.set('n', 'grr', function()
vim.lsp.buf.references()
end, { desc = "Code references (LSP)" })
vim.keymap.set('n', 'gd', function()
vim.lsp.buf.definition()
end, { desc = "Goto definition (LSP)" })
if client:supports_method(methods.textDocument_completion) then
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
map('i', "<CR>", function()
return pumvisible() and '<C-y>' or '<CR>'
end, { expr = true })
-- TODO: this ignores/overwrites default omnifunc rn
map('i', "<C-n>", function()
return pumvisible() and '<C-n>' or vim.lsp.completion.get()
end, { expr = true })
map('i', '<Esc>', function()
return pumvisible() and '<C-E>' or '<Esc>'
end, { expr = true })
end
-- if client:supports_method(methods.textDocument_semanticTokens) then
-- end
-- use pyright hover instead of ruff
if client.name == 'ruff' then
client.server_capabilities.hoverProvider = false
end
-- vim.keymap.set('n', 'E', '<cmd>lua vim.lsp.buf.hover()<CR>', { silent = true })
if client:supports_method(methods.textDocument_inlayHint) then
vim.lsp.inlay_hint.enable()
end
-- if client:supports_method(methods.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})
-- lspconfig = require('lspconfig')
for server, config in pairs(servers) do
-- -- config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
-- -- vim.lsp.config[server].settings = config
-- -- vim.lsp.config[server] = config
-- -- vim.lsp.enable(server)
-- -- lspconfig.rust_analyzer.setup({})
-- lspconfig[server].setup(config)
vim.lsp.config[server] = config
vim.lsp.enable(server)
end
-- vim.lsp.enable({'lua_ls', 'zls', 'clangd'})
vim.lsp.enable({'zls', 'clangd', 'lua_ls'})
|