12345678910111213141516171819202122232425262728 |
- -- 在 ~/.config/nvim/lua/plugins/lsp.lua 中添加或修改
- return {
- {
- "neovim/nvim-lspconfig",
- opts = {
- servers = {
- clangd = {
- cmd = {
- "clangd",
- "--background-index",
- "--clang-tidy",
- "--header-insertion=never",
- "--completion-style=detailed",
- "--query-driver=/usr/bin/gcc,/usr/bin/g++,/usr/bin/clang,/usr/bin/clang++",
- "--all-scopes-completion",
- "--cross-file-rename",
- },
- filetypes = { "c", "cpp", "objc", "objcpp", "cuda" },
- -- 设置编译命令目录为CMake生成的compile_commands.json所在目录
- root_dir = function(fname)
- return require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt", ".git")(fname)
- or vim.fn.getcwd()
- end,
- },
- },
- },
- },
- }
|