local default_capabilities = { textDocument = { completion = { editsNearCursor = true, }, }, offsetEncoding = { 'utf-8', 'utf-16' }, } local root_files = { '.clangd', '.clang-tidy', '.clang-format', 'compile_commands.json', 'compile_flags.txt' } local clangd_cmd = { "clangd", "--background-index", "--pch-storage=memory", "--clang-tidy", "--header-insertion=never" } local path = vim.fs.find(root_files, { type = "file" }) local root = vim.fs.dirname(path[1]) vim.lsp.start({ name = "clangd", cmd = clangd_cmd, root_dir = root, filetypes = { 'c', 'cpp' }, single_file_support = true, capabilities = default_capabilities, })