From e38f2cf73d658c0ccd32932436b142036481c136 Mon Sep 17 00:00:00 2001 From: A-Lamia Date: Thu, 10 Aug 2023 21:30:41 +1000 Subject: [PATCH] feat: clear lsp references on ui open if you are hovering over some text with an lsp, it highlights all the references, when entering ssr these highlights are still visible, this can be visually noisy --- lua/ssr.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/ssr.lua b/lua/ssr.lua index 124d183..8947986 100644 --- a/lua/ssr.lua +++ b/lua/ssr.lua @@ -78,6 +78,13 @@ function Ui:open() self.ns = api.nvim_create_namespace "" self.cur_match_ns = api.nvim_create_namespace "" + local function clear_extmark(namespace) + local ns_id = vim.api.nvim_get_namespaces()[namespace] + vim.api.nvim_buf_clear_namespace(self.origin_buf, ns_id, 0, -1) + end + + pcall(clear_extmark, "vim_lsp_references") + local function set_extmark(row, text) return api.nvim_buf_set_extmark(self.ui_buf, self.ns, row, 0, { virt_text = text, virt_text_pos = "overlay" }) end