From 473e71165e47f029d1a578856ab936dd6f4bf9ed Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Wed, 12 Mar 2025 22:50:12 +0800 Subject: feat(nvim): improve configs a lot. --- store/home/config/nvim/lua/setup/lsp/clangd.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 store/home/config/nvim/lua/setup/lsp/clangd.lua (limited to 'store/home/config/nvim/lua/setup/lsp/clangd.lua') diff --git a/store/home/config/nvim/lua/setup/lsp/clangd.lua b/store/home/config/nvim/lua/setup/lsp/clangd.lua new file mode 100644 index 0000000..6080510 --- /dev/null +++ b/store/home/config/nvim/lua/setup/lsp/clangd.lua @@ -0,0 +1,25 @@ +local lspconfig = require("lspconfig") + +local brew_clangd_path = "/usr/local/opt/llvm/bin/clangd" + +local function setup() + local clangd = "clangd" + + if vim.uv.fs_stat(brew_clangd_path) ~= nil then + clangd = brew_clangd_path + end + + -- setup lsp clangd + lspconfig.clangd.setup { + cmd = { clangd }, + on_attach = function(_, bufnr) + vim.keymap.set('n', 'grs', "ClangdSwitchSourceHeader", { + buffer = bufnr + }) + end + } +end + +return { + setup = setup +} -- cgit v1.2.3