diff options
| author | Aotrix <[email protected]> | 2025-02-24 01:39:08 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2025-02-24 01:39:08 +0100 |
| commit | c45f7969d52bf7f4e036873a83ae33640c94b195 (patch) | |
| tree | 1cc857c5398809fc87d6d56edf0d5befd2a440d7 /lua | |
| parent | 3c6815fcefa91a67e90b2a5c4b995672ecf2e4e8 (diff) | |
added working lsp
Diffstat (limited to 'lua')
| -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, } |
