From c3b23be371b75a1aa54adfc64a9bc268c29cb2c3 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Wed, 27 Jul 2022 08:05:14 -0700 Subject: [PATCH] fix(lsp): "no client attached" error (closes #490) --- lua/fzf-lua/providers/lsp.lua | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lua/fzf-lua/providers/lsp.lua b/lua/fzf-lua/providers/lsp.lua index 7fc63ea..df0f691 100644 --- a/lua/fzf-lua/providers/lsp.lua +++ b/lua/fzf-lua/providers/lsp.lua @@ -5,7 +5,22 @@ local make_entry = require "fzf-lua.make_entry" local M = {} +local function CTX_UPDATE() + -- save current win/buf context, ignore when fzf + -- window is already open (actions.sym_lsym) + if not __CTX or not utils.fzf_winobj() then + __CTX = { + winid = vim.api.nvim_get_current_win(), + bufnr = vim.api.nvim_get_current_buf(), + bufname = vim.api.nvim_buf_get_name(0) + } + end +end + local function check_capabilities(feature) + -- update CTX since this gets called before normalize_lsp_opts (#490) + CTX_UPDATE() + local clients = vim.lsp.buf_get_clients(__CTX and __CTX.bufnr or 0) -- return the number of clients supporting the feature @@ -324,14 +339,8 @@ local normalize_lsp_opts = function(opts, cfg) end -- save current win/buf context - -- ignore when fzf window is already open - if not __CTX or not utils.fzf_winobj() then - __CTX = { - winid = vim.api.nvim_get_current_win(), - bufnr = vim.api.nvim_get_current_buf(), - bufname = vim.api.nvim_buf_get_name(0) - } - end + -- moved to 'check_capabilities' (#490) + -- CTX_UPDATE() opts.code_actions = nil