From 5a0dd8ea39a394956e3d3a52eab51c20a21ce4c2 Mon Sep 17 00:00:00 2001 From: Nydragon Date: Tue, 28 May 2024 14:47:42 +0900 Subject: [PATCH] refactor: reduce number of requires --- lua/nvim-lsp-config.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lua/nvim-lsp-config.lua b/lua/nvim-lsp-config.lua index f4513a3..6896c48 100644 --- a/lua/nvim-lsp-config.lua +++ b/lua/nvim-lsp-config.lua @@ -38,20 +38,23 @@ local lsp_flags = { -- This is the default in Nvim 0.7+ debounce_text_changes = 150, } -require("lspconfig")["pyright"].setup({ + +local lspconfig = require("lspconfig") + +lspconfig.pyright.setup({ on_attach = on_attach, flags = lsp_flags, }) -require("lspconfig").clangd.setup({}) +lspconfig.clangd.setup({}) -require("lspconfig").rust_analyzer.setup({}) +lspconfig.rust_analyzer.setup({}) -require("lspconfig").nixd.setup({}) +lspconfig.nixd.setup({}) -require("lspconfig").r_language_server.setup({}) +lspconfig.r_language_server.setup({}) -require("lspconfig").lua_ls.setup({ +lspconfig.lua_ls.setup({ on_init = function(client) local path = client.workspace_folders[1].name if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then @@ -81,6 +84,6 @@ require("lspconfig").lua_ls.setup({ }, }) -require("lspconfig").bashls.setup({}) +lspconfig.bashls.setup({}) -require("lspconfig").zls.setup({}) +lspconfig.zls.setup({})