diff options
| -rw-r--r-- | lua/aotrix/plugins/lsp.lua | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lua/aotrix/plugins/lsp.lua b/lua/aotrix/plugins/lsp.lua index 625618f..efb3d80 100644 --- a/lua/aotrix/plugins/lsp.lua +++ b/lua/aotrix/plugins/lsp.lua @@ -1,6 +1,40 @@ return { "neovim/nvim-lspconfig", config = function() - require('lspconfig').clangd.setup({}) + require('lspconfig').clangd.setup({ + root_dir = function(fname) + return require("lspconfig.util").root_pattern( + "CMakeLists.txt", + "Makefile", + "configure.ac", + "configure.in", + "config.h.in", + "meson.build", + "meson_options.txt", + "build.ninja" + )(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")( + fname + ) or require("lspconfig.util").find_git_ancestor(fname) + end, + capabilities = { + offsetEncoding = { "utf-16" }, + }, + cmd = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + init_options = { + usePlaceholders = true, + completeUnimported = true, + clangdFileStatus = true, + }, + }) + + vim.keymap.set("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<cr>") end, } |
