diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-03-12 22:50:12 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-03-12 22:50:12 +0800 |
commit | 3ad034a1b5755bd5d8ebed71637dedb9089a7dce (patch) | |
tree | 228aed35af429f3819b897da2dd3b12742063f7d /store/home/config/nvim/lua/setup/lsp | |
parent | 117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74 (diff) | |
download | crupest-main.tar.gz crupest-main.tar.bz2 crupest-main.zip |
Diffstat (limited to 'store/home/config/nvim/lua/setup/lsp')
-rw-r--r-- | store/home/config/nvim/lua/setup/lsp/clangd.lua | 25 | ||||
-rw-r--r-- | store/home/config/nvim/lua/setup/lsp/init.lua | 25 | ||||
-rw-r--r-- | store/home/config/nvim/lua/setup/lsp/lua_ls.lua | 29 |
3 files changed, 79 insertions, 0 deletions
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', "<cmd>ClangdSwitchSourceHeader<cr>", { + buffer = bufnr + }) + end + } +end + +return { + setup = setup +} diff --git a/store/home/config/nvim/lua/setup/lsp/init.lua b/store/home/config/nvim/lua/setup/lsp/init.lua new file mode 100644 index 0000000..e87c2be --- /dev/null +++ b/store/home/config/nvim/lua/setup/lsp/init.lua @@ -0,0 +1,25 @@ +local lspconfig = require("lspconfig") +local cmp_nvim_lsp = require("cmp_nvim_lsp") +local cmp_default_caps = cmp_nvim_lsp.default_capabilities() + +local lspconfig_default_caps = lspconfig.util.default_config.capabilities + +lspconfig.util.default_config = vim.tbl_extend( + "force", + lspconfig.util.default_config, + { + capabilities = vim.tbl_extend("force", lspconfig_default_caps, cmp_default_caps), + autostart = false, + }) + +local function setup() + lspconfig.cmake.setup {} + lspconfig.bashls.setup {} + require("setup.lsp.clangd").setup() + require("setup.lsp.lua_ls").setup() +end + + +return { + setup = setup +} diff --git a/store/home/config/nvim/lua/setup/lsp/lua_ls.lua b/store/home/config/nvim/lua/setup/lsp/lua_ls.lua new file mode 100644 index 0000000..93aa503 --- /dev/null +++ b/store/home/config/nvim/lua/setup/lsp/lua_ls.lua @@ -0,0 +1,29 @@ +local lspconfig = require("lspconfig") + +local function setup() + lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { + version = "LuaJIT" + }, + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, + } +end + +return { + setup = setup +} |