From 4a8fb6915750d5ffd9ab0a31c2e30dc53dabf65e Mon Sep 17 00:00:00 2001 From: siduck Date: Thu, 28 Sep 2023 07:22:02 +0530 Subject: [PATCH] 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. --- lua/plugins/configs/lspconfig.lua | 45 ++++++++++++++++--------------- lua/plugins/init.lua | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 5b636ad..a605c7e 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,10 +1,6 @@ -dofile(vim.g.base46_cache .. "lsp") -require "nvchad.lsp" - local M = {} -- export on_attach & capabilities for custom lspconfigs - M.on_attach = function(client, bufnr) local utils = require "core.utils" local conf = utils.load_config().ui.lsp @@ -45,27 +41,32 @@ M.capabilities.textDocument.completion.completionItem = { }, } -require("lspconfig").lua_ls.setup { - on_attach = M.on_attach, - capabilities = M.capabilities, +M.defaults = function() + dofile(vim.g.base46_cache .. "lsp") + require "nvchad.lsp" - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - 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, + require("lspconfig").lua_ls.setup { + on_attach = M.on_attach, + capabilities = M.capabilities, + + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + 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 diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3f76ffd..3070c1a 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -133,7 +133,7 @@ local default_plugins = { require("core.utils").lazy_load "nvim-lspconfig" end, config = function() - require "plugins.configs.lspconfig" + require("plugins.configs.lspconfig").defaults() end, },