Can't Creating Project Local Settings for clangd. What to do

I am trying to create project local settings for clangd

According to the docs for nvim-lspconfig, there are 3 ways to
achieve this

  • nlsp-settings.nvim
  • exrc
  • using init.lua

And I have tried all 3, but with no success. And this is not possible by using a .clangd file. The goal is
to enable --query driver with the argument "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++".

My attempt at nlps-settings:

I ran:

:LspSettings local clangd

And that created this in the project root directory

/.nlsp-settings
└── clangd.json

Using json tab complete with a json lsp, I created

{
"clangd.arguments": [
  "--background-index",
  "--query-driver",
  "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++"
]
}

Then I ran

:LspSettings update

and that didn’t work. I then ran

:LspSettings clangd 

and that created a file

~/.config/nvim/nlsp-settings/clangd.json

And that contains the same thing as above. This doesn’t work

And then I tried exrc

So in my init.lua I enabled exrc

I have

-- bootstrap lazy.nvim, LazyVim and your plugins
vim.o.exrc = true
require("config.lazy")

In my root project directory, I have .nvimrc.lua, I have

lua << EOF

    local configs = require("nvim_lsp/configs")
    local util = require("nvim_lsp/util")
    local root_pattern = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git")

    configs.clangd = {
        default_config = util.utf8_config({
            cmd = {
                "clangd",
                "--background-index",
                "--query-driver",
                "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",
            },
            filetypes = { "c", "cpp", "objc", "objcpp" },
            root_dir = function(fname)
                local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
                return root_pattern(filename) or util.path.dirname(filename)
      end
EOF

I finally tried to edit my init.lua so that these settings get applied

local nvim_lsp = require("lspconfig")
nvim_lsp.clangd.setup({
    on_init = function(client)
        local path = client.workspace_folders[1].name

        if path == "/home/jared/Projects/CPP/NakOS" then
            client.config.settings["clangd"].checkOnSave.overrideCommand =
                { "clangd", "--query-driver", "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++" }
        end
        client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
        return true
    end,
    settings = {
        ["clangd"] = { checkOnSave = { overrideCommand = {} } },
    },
})

And none of this worked and this is unbelieably frustrating!

I’m having the same problem. I want to use the ESP-IDF version of clangd and have also tried all of the above. Annoyingly, I had everything working in nvim 0.7 and only upgraded because 0.7 doesn’t support turning off lsp logging.

I have the same issue,have you solved it now?