From 6706aafee0c0b7ca0949cd3e2b22f472ade2834e Mon Sep 17 00:00:00 2001 From: weirdgiraffe Date: Mon, 19 Feb 2024 11:06:12 +0100 Subject: [PATCH] fixup: prevent errors if lsp clients are not yet ready --- lua/go/codelens.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/go/codelens.lua b/lua/go/codelens.lua index 01a4759..e4881e2 100644 --- a/lua/go/codelens.lua +++ b/lua/go/codelens.lua @@ -4,6 +4,10 @@ local codelens = require('vim.lsp.codelens') -- runs callback if gopls supports codelens local function with_gopls_codelens(callback) + -- prevent errors from codelens if lsp is not ready + if not vim.lsp.buf.server_ready() then + return + end for _, gopls in pairs(vim.lsp.get_active_clients({ name = 'gopls', bufnr = 0 })) do if gopls:supports_method('textDocument/codeLens') then callback()