feat: stop lsp for cpp c files

This commit is contained in:
talksik
2025-04-24 07:14:18 -07:00
parent df9b8770c3
commit 1c89b267b2
+21
View File
@@ -403,6 +403,24 @@ require('lazy').setup({
callback = function(event) callback = function(event)
-- Disable LSP by default -- Disable LSP by default
-- vim.lsp.stop_client(vim.lsp.get_clients()) -- vim.lsp.stop_client(vim.lsp.get_clients())
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client then
local filetype = vim.bo[event.buf].filetype
-- Check if the attached client supports C++ filetypes
local cpp_supported = false
for _, ft in ipairs(client.config.filetypes or {}) do
if ft == 'cpp' or ft == 'c' or ft == 'objc' or ft == 'objcpp' then
cpp_supported = true
break
end
end
-- If the filetype is C++ and the client supports it, we can choose to detach
if cpp_supported and (filetype == 'cpp' or filetype == 'h' or filetype == 'c' or filetype == 'objc' or filetype == 'objcpp') then
vim.lsp.stop_client(event.data.client_id)
print("LSP stopped for " .. filetype .. " file.")
return
end
-- NOTE: Remember that Lua is a real programming language, and as such it is possible -- NOTE: Remember that Lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself. -- to define small helper and utility functions so you don't have to repeat yourself.
@@ -485,6 +503,9 @@ require('lazy').setup({
callback = vim.lsp.buf.clear_references, callback = vim.lsp.buf.clear_references,
}) })
end end
end
end, end,
}) })