turn off LSP for C++
This commit is contained in:
@@ -31,14 +31,6 @@ vim.filetype.add({
|
||||
cuh = "cuda",
|
||||
},
|
||||
})
|
||||
-- clangd
|
||||
vim.lsp.config("clangd", {
|
||||
cmd = { "clangd", "--compile-commands-dir=build", "--experimental-modules-support" },
|
||||
capabilities = caps,
|
||||
on_attach = on_attach,
|
||||
filetypes = { "c", "cpp", "cc", "cxx", "c++", "ixx", "cu", "cuh", "cuda" },
|
||||
})
|
||||
vim.lsp.enable("clangd")
|
||||
|
||||
-- rust-analyzer
|
||||
vim.lsp.config("rust_analyzer", {
|
||||
@@ -86,9 +78,19 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("AutoFormatOnSave", { clear = true }),
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
local ext = vim.fn.expand("%:e")
|
||||
local cpp_exts = { cpp = true, cxx = true, hpp = true, ixx = true }
|
||||
|
||||
if cpp_exts[ext] then
|
||||
local filepath = vim.fn.expand("%:p")
|
||||
vim.fn.system({ "clang-format", "-i", filepath })
|
||||
vim.cmd("edit!") -- reload the buffer after in-place formatting
|
||||
return
|
||||
end
|
||||
|
||||
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.lsp.buf.format({ async = true, timeout_ms=5000 })
|
||||
vim.lsp.buf.format({ async = false, timeout_ms = 5000 })
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user