From 71d029ef3a22c3ab6ca5f71261ecc20d42ac9679 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier Date: Thu, 4 Dec 2025 18:39:58 +0100 Subject: [PATCH] fix: check if lsp config is a table or a function before trying to index it --- lua/krust.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/krust.lua b/lua/krust.lua index 72c1b44..0368da2 100644 --- a/lua/krust.lua +++ b/lua/krust.lua @@ -31,7 +31,13 @@ M.setup = function(opts) local original_start = vim.lsp.start vim.lsp.start = function(config, opts) - if config.name == "rust_analyzer" or (config.cmd and config.cmd[1] and config.cmd[1]:match("rust[-_]analyzer")) then + local is_rust_analyzer = config.name == "rust_analyzer" + -- Check if cmd is a table (array) before trying to index it + if not is_rust_analyzer and type(config.cmd) == "table" and config.cmd[1] then + is_rust_analyzer = config.cmd[1]:match("rust[-_]analyzer") ~= nil + end + + if is_rust_analyzer then config.capabilities = config.capabilities or vim.lsp.protocol.make_client_capabilities() config.capabilities.experimental = config.capabilities.experimental or {} if not config.capabilities.experimental.colorDiagnosticOutput then