preselect 1st item in code action. lsp_signature hook

neovim_0.6
ray-x 3 years ago
parent b196af9311
commit a6f668e05f

@ -119,6 +119,9 @@ local function on_code_action_results(results, ctx)
log("new buffer", listview.bufnr)
vim.api.nvim_buf_add_highlight(listview.bufnr, -1, 'Title', 0, 0, -1)
-- let move down 2 pos
ListViewCtrl:on_next()
ListViewCtrl:on_next()
end
local diagnostic = vim.diagnostic or vim.lsp.diagnostic

@ -87,7 +87,7 @@ local function def_preview(timeout_ms)
local sr, _, er, _ = ts.get_node_scope(def_node)
log(sr, er)
lines_num = math.max(lines_num, er - sr + 1)
lines_num = math.max(lines_num, er - sr + 3) -- comments etc
end
-- TODO: 12 should be an option
@ -102,10 +102,11 @@ local function def_preview(timeout_ms)
end
end
local width = 40
local maxwidth = math.floor(vim.fn.winwidth(0) * 4 / 5)
for key, value in pairs(definition) do
-- log(key, value, width)
width = math.max(width, #value + 4)
width = math.min(120, width)
width = math.min(maxwidth, width)
end
definition = vim.list_extend({"  [" .. get_symbol() .. "] Definition: "}, definition)
local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
@ -115,7 +116,7 @@ local function def_preview(timeout_ms)
relative = "cursor",
style = "minimal",
ft = filetype,
rect = {width = width, height = #definition + 2},
rect = {width = width, height = #definition + 3},
data = definition,
enter = true,
border = _NgConfigValues.border or "shadow"

@ -257,11 +257,11 @@ function M.setup(user_opts)
-- TODO: when active signature merge to neovim, remove this setup:
if _NgConfigValues.signature_help_cfg then
if _NgConfigValues.signature_help_cfg or _NgConfigValues.lsp_signature_help then
log("setup signature from navigator")
local hassig, sig = pcall(require, "lsp_signature")
if hassig then
sig.setup(_NgConfigValues.signature_help_cfg)
sig.setup(_NgConfigValues.signature_help_cfg or {})
end
else
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(require"navigator.signature".signature_handler, {

Loading…
Cancel
Save