0

I'm trying to configure clangd to be able to search symbols in nvim working directory, but it still uses only opened buffers. Configuration:

local opts = { noremap=true, silent=true }

local on_attach = function(client, bufnr)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
end

require('lspconfig').clangd.setup{
    on_attach = on_attach,
    filetypes = {"c", "cpp"},
    root_dir = require("lspconfig").util.root_pattern(vim.fn.getcwd()),
}
BabyRooJr
  • 23
  • 5

1 Answers1

0

Searching in clangd requires that the project be indexed, which in turn requires that it have a compilation database (compile_commands.json file).

The compilation database is usually generated by the build system. See https://clangd.llvm.org/installation#compile_commandsjson for instructions for specific build systems.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194