From 75f313b260c1eceaf4e0d128105533f336b2afa8 Mon Sep 17 00:00:00 2001 From: dlond Date: Wed, 21 May 2025 06:29:09 +1200 Subject: [PATCH] adding lsp server options pt 10 --- lua/custom/plugins/lsp.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua index 85667a41..4bfc47fe 100644 --- a/lua/custom/plugins/lsp.lua +++ b/lua/custom/plugins/lsp.lua @@ -49,27 +49,25 @@ return { }, clangd = { cmd = (function() - if nix_paths.clang_driver_path and nix_paths.macos_sdk_path and nix_paths.libcxx_include_path then + if nix_paths.clang_driver_path then return { 'clangd', '--query-driver=' .. nix_paths.clang_driver_path, - -- Explicitly pass system root and C++ standard library include path as clangd arguments. - -- These are compiler flags that clangd can use to understand the environment. + -- No other compiler flags like -isysroot or -isystem should be passed directly here. + -- Clangd gets those from compile_commands.json or by querying the driver. '--compile-commands-dir=' .. vim.fn.getcwd() - .. '/build', -- Assuming compile_commands.json is in /build - '-extra-arg=-isysroot=' .. nix_paths.macos_sdk_path, - '-extra-arg=-isystem=' .. nix_paths.libcxx_include_path, - -- You could also try adding the resource-dir from compile_commands.json if needed: - -- "-extra-arg=-resource-dir=/nix/store/YOUR_CLANG_RESOURCE_DIR_HASH/lib/clang/VERSION" + .. '/build', -- Ensure clangd finds compile_commands.json } else - vim.notify('Warning: One or more Nix paths for clangd (driver, sdk, libcxx) not defined. Clangd might have issues.', vim.log.levels.WARN) + vim.notify( + 'Warning: Nix path for clang_driver_path not defined in custom.nix_paths.lua. Clangd might use system clangd or have issues.', + vim.log.levels.WARN + ) return { 'clangd' } -- Fallback end end)(), - -- Ensure clangd knows the project root to find compile_commands.json and .clangd - root_dir = require('lspconfig.util').root_pattern('compile_commands.json', '.git', '.clangd'), + root_dir = require('lspconfig.util').root_pattern('compile_commands.json', '.git'), -- Helps find project root }, pyright = { settings = {