aboutsummaryrefslogtreecommitdiff
path: root/store/home/config/nvim/lua/setup/lsp.lua
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-06-04 15:25:48 +0800
committerYuqian Yang <crupest@crupest.life>2025-06-04 18:38:00 +0800
commitc3cdc6e002eec05be3bcaa4fb14e5dff06e975da (patch)
treea7f8e4865c814a998b1396b6afa9e2c345c1b158 /store/home/config/nvim/lua/setup/lsp.lua
parent4390f309aee8dea8014714d3ef6539f40e10ebd3 (diff)
downloadcrupest-c3cdc6e002eec05be3bcaa4fb14e5dff06e975da.tar.gz
crupest-c3cdc6e002eec05be3bcaa4fb14e5dff06e975da.tar.bz2
crupest-c3cdc6e002eec05be3bcaa4fb14e5dff06e975da.zip
config(nvim): new lsp config and use neo-tree.
Diffstat (limited to 'store/home/config/nvim/lua/setup/lsp.lua')
-rw-r--r--store/home/config/nvim/lua/setup/lsp.lua67
1 files changed, 67 insertions, 0 deletions
diff --git a/store/home/config/nvim/lua/setup/lsp.lua b/store/home/config/nvim/lua/setup/lsp.lua
new file mode 100644
index 0000000..15deacd
--- /dev/null
+++ b/store/home/config/nvim/lua/setup/lsp.lua
@@ -0,0 +1,67 @@
+-- spellchecker: words denols luals
+
+vim.lsp.config("*", {
+ capabilities = vim.tbl_extend("force",
+ vim.lsp.protocol.make_client_capabilities(),
+ require("cmp_nvim_lsp").default_capabilities()
+ )
+})
+
+local function setup_clangd()
+ local clangd = "clangd"
+ local brew_clangd_path = "/usr/local/opt/llvm/bin/clangd"
+
+ if vim.uv.fs_stat(brew_clangd_path) ~= nil then
+ clangd = brew_clangd_path
+ end
+
+ vim.lsp.config("clangd", {
+ cmd = { clangd }
+ })
+ local old_on_attach = vim.lsp.config.clangd.on_attach
+ vim.lsp.config.clangd.on_attach = function(client, bufnr)
+ if old_on_attach then old_on_attach(client, bufnr) end
+ vim.keymap.set('n', 'grs', "<cmd>ClangdSwitchSourceHeader<cr>", {
+ buffer = bufnr
+ })
+ end
+end
+
+local function setup_luals()
+ vim.lsp.config("lua_ls", {
+ 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
+
+local function setup()
+ vim.lsp.enable('denols')
+ vim.lsp.enable('cmake')
+ vim.lsp.enable('bashls')
+ vim.lsp.enable('html')
+ vim.lsp.enable('cssls')
+ setup_clangd()
+ setup_luals()
+end
+
+
+return {
+ setup = setup
+}