turn off LSP for C++
This commit is contained in:
+11
-9
@@ -31,14 +31,6 @@ vim.filetype.add({
|
|||||||
cuh = "cuda",
|
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
|
-- rust-analyzer
|
||||||
vim.lsp.config("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 }),
|
group = vim.api.nvim_create_augroup("AutoFormatOnSave", { clear = true }),
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function()
|
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
|
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||||
if client.supports_method("textDocument/formatting") then
|
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
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user