From 4c025cd1bf67264fd4f12747569c2cbb042e7093 Mon Sep 17 00:00:00 2001 From: siduck76 Date: Fri, 10 Sep 2021 15:40:54 +0530 Subject: [PATCH] debloat config | remove lspinstall --- lua/chadrc.lua | 7 ++++ lua/core/autocmds.lua | 2 +- lua/default_config.lua | 6 +++ lua/plugins/configs/lspconfig.lua | 68 +++++++------------------------ lua/plugins/init.lua | 10 ++--- 5 files changed, 31 insertions(+), 62 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 986a835..177dbd7 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -214,4 +214,11 @@ M.custom.mappings = { -- }, } +M.plugins = { + lspconfig = { + -- servers = {"html", "cssls"} + servers = {}, + }, +} + return M diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 74062cd..c2e5a67 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -12,7 +12,7 @@ vim.cmd [[ au TermOpen term://* setlocal nonumber norelativenumber | setfiletype vim.cmd [[ autocmd BufEnter,BufWinEnter,FileType,WinEnter * lua require("core.utils").hide_statusline() ]] --auto close file exploer when quiting incase a single buffer is left -vim.cmd([[ autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'nvimtree') | q | endif ]]) +-- vim.cmd([[ autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'nvimtree') | q | endif ]]) -- Open a file from its last left off position -- vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] diff --git a/lua/default_config.lua b/lua/default_config.lua index 35b08b8..134586e 100644 --- a/lua/default_config.lua +++ b/lua/default_config.lua @@ -217,4 +217,10 @@ M.custom.mappings = { -- }, } +M.plugins = { + lspconfig = { + -- servers = {"html", "cssls"} + servers = {}, + }, +} return M diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 2bfd1dd..6cd102b 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,7 +1,6 @@ -local present1, lspconfig = pcall(require, "lspconfig") -local present2, lspinstall = pcall(require, "lspinstall") +local present1, nvim_lsp = pcall(require, "lspconfig") -if not (present1 or present2) then +if not present1 then return end @@ -57,63 +56,24 @@ capabilities.textDocument.completion.completionItem.resolveSupport = { }, } --- lspInstall + lspconfig stuff +local servers = require("core.utils").load_config().plugins.lspconfig.servers -local function setup_servers() - lspinstall.setup() - local servers = lspinstall.installed_servers() - - for _, lang in pairs(servers) do - if lang ~= "lua" then - lspconfig[lang].setup { - on_attach = on_attach, - capabilities = capabilities, - flags = { - debounce_text_changes = 500, - }, - -- root_dir = vim.loop.cwd, - } - elseif lang == "lua" then - lspconfig[lang].setup { - on_attach = on_attach, - capabilities = capabilities, - flags = { - debounce_text_changes = 500, - }, - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand "$VIMRUNTIME/lua"] = true, - [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, - }, - maxPreload = 100000, - preloadFileSize = 10000, - }, - telemetry = { - enable = false, - }, - }, - }, - } - end - end +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + -- root_dir = vim.loop.cwd, + flags = { + debounce_text_changes = 150, + }, + } end -setup_servers() - --- Automatically reload after `:LspInstall ` so we don't have to restart neovim -lspinstall.post_install_hook = function() - setup_servers() -- reload installed servers - vim.cmd "bufdo e" -end +-- require("anyfile").setup_luaLsp(on_attach, capabilities) -- this will be removed soon after the custom hooks PR -- replace the default lsp diagnostic symbols local function lspSymbol(name, icon) - vim.fn.sign_define("LspDiagnosticsSign" .. name, { text = icon, numhl = "LspDiagnosticsDefaul" .. name }) + vim.fn.sign_define("LspDiagnosticsSign" .. name, { text = icon, numhl = "LspDiagnosticsDefault" .. name }) end lspSymbol("Error", "") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 6fd905a..73fc46e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -116,21 +116,17 @@ return packer.startup(function() } -- lsp stuff + use { - "kabouzeid/nvim-lspinstall", + "neovim/nvim-lspconfig", opt = true, setup = function() - require("core.utils").packer_lazy_load "nvim-lspinstall" + require("core.utils").packer_lazy_load "nvim-lspconfig" -- reload the current file so lsp actually starts for it vim.defer_fn(function() vim.cmd "silent! e %" end, 0) end, - } - - use { - "neovim/nvim-lspconfig", - after = "nvim-lspinstall", config = function() require "plugins.configs.lspconfig" end,