-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAstroNvim-clangd
More file actions
87 lines (87 loc) · 2.9 KB
/
AstroNvim-clangd
File metadata and controls
87 lines (87 loc) · 2.9 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
return {
"AstroNvim/astrolsp",
opts = {
features = {
codelens = true, -- enable/disable codelens refresh on start
inlay_hints = true, -- enable inlay hints on start
semantic_tokens = true, -- enable semantic token highlighting
},
formatting = {
format_on_save = {
enabled = true, -- enable autoformatting on save
allow_filetypes = { "lua", "c", "cpp" }, -- restrict to certain filetypes if needed
ignore_filetypes = {}, -- leave empty if you don't want to exclude any filetype
},
disabled = {
-- Disable formatting for lua_ls if you're using an external formatter like StyLua
-- "lua_ls",
},
timeout_ms = 1000, -- increase the timeout if needed
},
servers = {
"lua_ls", -- enable lua-language-server (ensure it's installed)
"clangd", -- enable clangd for C/C++
},
config = {
-- Customize clangd settings
clangd = {
capabilities = {
offsetEncoding = { "utf-8" },
},
filetypes = { "c", "cpp", "objc", "objcpp" },
cmd = { "/data/data/com.termux/files/usr/bin/clangd" }, -- specify the path to clangd
},
-- Customize lua-language-server settings
lua_ls = {
cmd = { "/data/data/com.termux/files/usr/bin/lua-language-server" }, -- specify the path to lua-language-server
settings = {
Lua = {
diagnostics = { globals = { "vim" } }, -- avoid undefined "vim" error in Lua
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
},
},
handlers = {
function(server, opts) require("lspconfig")[server].setup(opts) end,
},
autocmds = {
lsp_codelens_refresh = {
cond = "textDocument/codeLens",
{
event = { "InsertLeave", "BufEnter" },
desc = "Refresh codelens (buffer)",
callback = function(args)
if require("astrolsp").config.features.codelens then
vim.lsp.codelens.refresh { bufnr = args.buf }
end
end,
},
},
},
mappings = {
n = {
gD = {
function() vim.lsp.buf.declaration() end,
desc = "Declaration of current symbol",
cond = "textDocument/declaration",
},
["<Leader>uY"] = {
function() require("astrolsp.toggles").buffer_semantic_tokens() end,
desc = "Toggle LSP semantic highlight (buffer)",
cond = function(client)
return client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil
end,
},
},
},
on_attach = function(bufnr, client)
-- Optional: Disable semantic tokens if needed
-- client.server_capabilities.semanticTokensProvider = nil
end,
},
}