help clangd find compiler and resource-dir

This commit is contained in:
dlond 2025-05-25 17:02:21 +12:00
parent be59c986be
commit d7711c7cdb
1 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,8 @@ return {
'hrsh7th/cmp-nvim-lsp', -- LSP completion source for nvim-cmp 'hrsh7th/cmp-nvim-lsp', -- LSP completion source for nvim-cmp
}, },
config = function(_, opts) config = function(_, opts)
-- local query_driver = vim.fn.trim(vim.fn.system 'which clang++')
-- local resource_dir = vim.fn.trim(vim.fn.system 'clang++ --print-resource-dir')
-- This config function runs AFTER the plugin and its dependencies are loaded. -- This config function runs AFTER the plugin and its dependencies are loaded.
-- It sets up the LSP servers. -- It sets up the LSP servers.
@ -36,7 +38,12 @@ return {
}, },
}, },
clangd = { clangd = {
cmd = { 'clangd' }, cmd = {
'clangd',
'--compile-commands-dir=build',
'--query-driver=' .. vim.fn.trim(vim.fn.system 'which clang++'),
'--resource-dir' .. vim.fn.trim(vim.fn.system 'clang++ --print-resource-dir'),
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }, filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_dir = require('lspconfig.util').root_pattern('CMakeLists.txt', '.git'), root_dir = require('lspconfig.util').root_pattern('CMakeLists.txt', '.git'),
}, },