lspconfig file: place default conf in a function

This will make sure that whenever the onattach or capabilities is pulled from the default lspconfig file, thosse dofile etc code ( which is now in defautls func ) wont be called , like before.
This commit is contained in:
siduck 2023-09-28 07:22:02 +05:30
parent cb18b424b9
commit 4a8fb69157
2 changed files with 24 additions and 23 deletions

View File

@ -1,10 +1,6 @@
dofile(vim.g.base46_cache .. "lsp")
require "nvchad.lsp"
local M = {} local M = {}
-- export on_attach & capabilities for custom lspconfigs -- export on_attach & capabilities for custom lspconfigs
M.on_attach = function(client, bufnr) M.on_attach = function(client, bufnr)
local utils = require "core.utils" local utils = require "core.utils"
local conf = utils.load_config().ui.lsp local conf = utils.load_config().ui.lsp
@ -45,27 +41,32 @@ M.capabilities.textDocument.completion.completionItem = {
}, },
} }
require("lspconfig").lua_ls.setup { M.defaults = function()
on_attach = M.on_attach, dofile(vim.g.base46_cache .. "lsp")
capabilities = M.capabilities, require "nvchad.lsp"
settings = { require("lspconfig").lua_ls.setup {
Lua = { on_attach = M.on_attach,
diagnostics = { capabilities = M.capabilities,
globals = { "vim" },
}, settings = {
workspace = { Lua = {
library = { diagnostics = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true, globals = { "vim" },
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, },
[vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true, workspace = {
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
[vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true,
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
},
maxPreload = 100000,
preloadFileSize = 10000,
}, },
maxPreload = 100000,
preloadFileSize = 10000,
}, },
}, },
}, }
} end
return M return M

View File

@ -133,7 +133,7 @@ local default_plugins = {
require("core.utils").lazy_load "nvim-lspconfig" require("core.utils").lazy_load "nvim-lspconfig"
end, end,
config = function() config = function()
require "plugins.configs.lspconfig" require("plugins.configs.lspconfig").defaults()
end, end,
}, },