mirror of
https://github.com/neovim/neovim.git
synced 2025-12-20 21:35:38 +00:00
UI tweaks.
- Hide diagnostics on client exit - Stop insert on popup focus. - Hide popup on insertchar (for signature_help)
This commit is contained in:
@@ -343,9 +343,19 @@ function lsp.start_client(config)
|
||||
function handlers.on_exit(code, signal)
|
||||
active_clients[client_id] = nil
|
||||
uninitialized_clients[client_id] = nil
|
||||
for _, client_ids in pairs(all_buffer_active_clients) do
|
||||
local active_buffers = {}
|
||||
for bufnr, client_ids in pairs(all_buffer_active_clients) do
|
||||
if client_ids[client_id] then
|
||||
table.insert(active_buffers, bufnr)
|
||||
end
|
||||
client_ids[client_id] = nil
|
||||
end
|
||||
-- Buffer level cleanup
|
||||
vim.schedule(function()
|
||||
for _, bufnr in ipairs(active_buffers) do
|
||||
util.buf_clear_diagnostics(bufnr)
|
||||
end
|
||||
end)
|
||||
if config.on_exit then
|
||||
pcall(config.on_exit, code, signal, client_id)
|
||||
end
|
||||
|
||||
@@ -51,7 +51,9 @@ local function focusable_preview(method, params, fn)
|
||||
do
|
||||
local win = find_window_by_var(method, bufnr)
|
||||
if win then
|
||||
return api.nvim_set_current_win(win)
|
||||
api.nvim_set_current_win(win)
|
||||
api.nvim_command("stopinsert")
|
||||
return
|
||||
end
|
||||
end
|
||||
return request(method, params, function(_, _, result, _)
|
||||
@@ -234,7 +236,9 @@ end
|
||||
function M.signature_help()
|
||||
local params = util.make_position_params()
|
||||
focusable_preview('textDocument/signatureHelp', params, function(result)
|
||||
if not (result and result.signatures and result.signatures[1]) then return end
|
||||
if not (result and result.signatures and result.signatures[1]) then
|
||||
return { 'No signature available' }
|
||||
end
|
||||
|
||||
-- TODO show empty popup when signatures is empty?
|
||||
local lines = signature_help_to_preview_contents(result)
|
||||
|
||||
@@ -104,7 +104,7 @@ function M.apply_text_edits(text_edits, bufnr)
|
||||
local e = cleaned[i]
|
||||
local A = {e.A[1] - start_line, e.A[2]}
|
||||
local B = {e.B[1] - start_line, e.B[2]}
|
||||
M.set_lines(lines, A, B, e.lines)
|
||||
lines = M.set_lines(lines, A, B, e.lines)
|
||||
end
|
||||
if set_eol and #lines[#lines] == 0 then
|
||||
table.remove(lines)
|
||||
@@ -340,7 +340,8 @@ function M.open_floating_preview(contents, filetype, opts)
|
||||
end
|
||||
api.nvim_buf_set_lines(floating_bufnr, 0, -1, true, contents)
|
||||
api.nvim_buf_set_option(floating_bufnr, 'modifiable', false)
|
||||
api.nvim_command("autocmd CursorMoved,BufHidden <buffer> ++once lua pcall(vim.api.nvim_win_close, "..floating_winnr..", true)")
|
||||
-- TODO make InsertCharPre disappearing optional?
|
||||
api.nvim_command("autocmd CursorMoved,BufHidden,InsertCharPre <buffer> ++once lua pcall(vim.api.nvim_win_close, "..floating_winnr..", true)")
|
||||
return floating_bufnr, floating_winnr
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user