From 4a59c83ba15b3c8e9fe68e51f993aab60aafbaef Mon Sep 17 00:00:00 2001 From: Marcelo Jacobus Date: Tue, 20 Aug 2024 10:18:11 -0300 Subject: [PATCH] Prevent LSP errors on startup --- init.lua | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index d9af56b..90d9a9d 100644 --- a/init.lua +++ b/init.lua @@ -4,28 +4,32 @@ require("config.lazy") -- init.lua local lspconfig = require("lspconfig") --- Setup Ruby Language Server -lspconfig.ruby_ls.setup({ - cmd = { "ruby-lsp" }, - filetypes = { "ruby" }, - settings = { - ruby = { - diagnostics = true, - completion = true, +if lspconfig and lspconfig.ruby_ls and lspconfig.ruby_ls.setup then + -- Setup Ruby Language Server + lspconfig.ruby_ls.setup({ + cmd = { "ruby-lsp" }, + filetypes = { "ruby" }, + settings = { + ruby = { + diagnostics = true, + completion = true, + }, }, - }, -}) + }) +end --- Setup Solargraph -lspconfig.solargraph.setup({ - cmd = { "solargraph", "stdio" }, - filetypes = { "ruby" }, - settings = { - solargraph = { - diagnostics = true, +if lspconfig and lspconfig.solargraph and lspconfig.solargraph.setup then + -- Setup Solargraph + lspconfig.solargraph.setup({ + cmd = { "solargraph", "stdio" }, + filetypes = { "ruby" }, + settings = { + solargraph = { + diagnostics = true, + }, }, - }, -}) + }) +end -- vim.defer_fn(function() -- vim.cmd([[highlight Comment guifg=#222436 guibg=#5c5e77 gui=italic]])