Showing signatures and highlighting parameters done
parent
c291a7df66
commit
9e69ec98c0
|
|
@ -218,11 +218,12 @@ local function _make_floating_popup_options(content, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
offset_x = opts.offset_x or 0
|
offset_x = opts.offset_x or 0
|
||||||
|
local first_col = vim.fn.getwininfo(vim.fn.win_getid())[1].textoff
|
||||||
|
|
||||||
return {
|
return {
|
||||||
anchor = anchor,
|
anchor = anchor,
|
||||||
row = row,
|
row = row,
|
||||||
col = col + offset_x,
|
col = col + first_col + offset_x,
|
||||||
width = width,
|
width = width,
|
||||||
height = height,
|
height = height,
|
||||||
focusable = opts.focusable,
|
focusable = opts.focusable,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ function SignatureHelp.new()
|
||||||
ns = nil,
|
ns = nil,
|
||||||
markid = nil,
|
markid = nil,
|
||||||
timer = nil,
|
timer = nil,
|
||||||
visible = false,
|
|
||||||
current_signatures = nil,
|
current_signatures = nil,
|
||||||
enabled = false,
|
enabled = false,
|
||||||
normal_mode_active = false,
|
normal_mode_active = false,
|
||||||
|
|
@ -52,8 +51,8 @@ function SignatureHelp.new()
|
||||||
max_width = 80,
|
max_width = 80,
|
||||||
anchor_bias = "below", -- below|above|auto
|
anchor_bias = "below", -- below|above|auto
|
||||||
relative = "cursor",
|
relative = "cursor",
|
||||||
offset_y = 5,
|
offset_y = 0,
|
||||||
offset_x = 5,
|
offset_x = 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
trigger_chars = { "(", "," },
|
trigger_chars = { "(", "," },
|
||||||
|
|
@ -257,16 +256,11 @@ function SignatureHelp:display(result)
|
||||||
return
|
return
|
||||||
end
|
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)
|
local content = helper.convert_signature_help_to_lines(result, self.config.win_opts.max_width)
|
||||||
if not self.showing then
|
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:
|
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
|
self.showing = true
|
||||||
end
|
end
|
||||||
local param_str = helper.get_parameter_label(result)
|
local param_str = helper.get_parameter_label(result)
|
||||||
|
|
@ -289,6 +283,7 @@ function SignatureHelp:trigger()
|
||||||
end
|
end
|
||||||
|
|
||||||
if result and result.signatures and #result.signatures > 0 then
|
if result and result.signatures and #result.signatures > 0 then
|
||||||
|
self.current_signatures = result.signatures
|
||||||
self:display(result)
|
self:display(result)
|
||||||
else
|
else
|
||||||
self:hide_sig_win()
|
self:hide_sig_win()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue