From 9e69ec98c0ad711bba72474517cfa40295480194 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sat, 21 Dec 2024 16:36:03 -0600 Subject: [PATCH] Showing signatures and highlighting parameters done --- lua/signup/helper.lua | 3 ++- lua/signup/init.lua | 15 +++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lua/signup/helper.lua b/lua/signup/helper.lua index a6339fc..27991e8 100644 --- a/lua/signup/helper.lua +++ b/lua/signup/helper.lua @@ -218,11 +218,12 @@ local function _make_floating_popup_options(content, opts) end offset_x = opts.offset_x or 0 + local first_col = vim.fn.getwininfo(vim.fn.win_getid())[1].textoff return { anchor = anchor, row = row, - col = col + offset_x, + col = col + first_col + offset_x, width = width, height = height, focusable = opts.focusable, diff --git a/lua/signup/init.lua b/lua/signup/init.lua index c61d82b..07ae904 100644 --- a/lua/signup/init.lua +++ b/lua/signup/init.lua @@ -16,7 +16,6 @@ function SignatureHelp.new() ns = nil, markid = nil, timer = nil, - visible = false, current_signatures = nil, enabled = false, normal_mode_active = false, @@ -52,8 +51,8 @@ function SignatureHelp.new() max_width = 80, anchor_bias = "below", -- below|above|auto relative = "cursor", - offset_y = 5, - offset_x = 5, + offset_y = 0, + offset_x = 0, }, trigger_chars = { "(", "," }, @@ -257,16 +256,11 @@ function SignatureHelp:display(result) return end - -- Prevent duplicate displays of identical content - if - self.current_signatures and vim.deep_equal(result.signatures, self.current_signatures) - -- and result.activeParameter == self.current_active_parameter - then - return - end local content = helper.convert_signature_help_to_lines(result, self.config.win_opts.max_width) if not self.showing then self.sig_buf, self.sig_win = helper.create_float_window(content, "lua", self.config.win_opts) -- TODO: programmatically set file type: + local param_str = helper.get_parameter_label(result) + self:set_active_parameter_highlights(param_str, content) self.showing = true end local param_str = helper.get_parameter_label(result) @@ -289,6 +283,7 @@ function SignatureHelp:trigger() end if result and result.signatures and #result.signatures > 0 then + self.current_signatures = result.signatures self:display(result) else self:hide_sig_win()