mirror of
https://github.com/neovim/neovim.git
synced 2025-09-03 18:08:16 +00:00
Compare commits
3 Commits
a33284c2c0
...
7a71235399
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7a71235399 | ||
![]() |
bc6737250d | ||
![]() |
c10e36fc01 |
@@ -825,7 +825,7 @@ will be set to zero, but can be changed and used for the replacing cmdline or
|
||||
message window. Cmdline state is emitted as |ui-cmdline| events, which the UI
|
||||
must handle.
|
||||
|
||||
["msg_show", kind, content, replace_last, history, append, msg_id, progress] ~
|
||||
["msg_show", kind, content, replace_last, history, append, msg_id] ~
|
||||
Display a message to the user.
|
||||
|
||||
kind
|
||||
@@ -886,18 +886,6 @@ must handle.
|
||||
Unique identifier for the message. It can either be an integer or
|
||||
string. When message of same id appears it should replace the older message.
|
||||
|
||||
progress
|
||||
Progress-message properties:
|
||||
• title: Title string of the progress message.
|
||||
• status: Status of the progress message. Can contain one of
|
||||
the following values
|
||||
• success: The progress item completed successfully
|
||||
• running: The progress is ongoing
|
||||
• failed: The progress item failed
|
||||
• cancel: The progressing process should be canceled.
|
||||
• percent: How much progress is done on the progress
|
||||
message
|
||||
|
||||
["msg_clear"] ~
|
||||
Clear all messages currently displayed by "msg_show", emitted after
|
||||
clearing the screen (messages sent by other "msg_" events below should
|
||||
|
@@ -39,6 +39,11 @@ TREESITTER
|
||||
|
||||
• todo
|
||||
|
||||
UI
|
||||
|
||||
• `progress` attribute removed form |ui-messages| msg_show event
|
||||
|
||||
|
||||
==============================================================================
|
||||
BREAKING CHANGES *news-breaking*
|
||||
|
||||
@@ -190,7 +195,7 @@ EVENTS
|
||||
|
||||
• |CmdlineLeavePre| triggered before preparing to leave the command line.
|
||||
• New `append` paremeter for |ui-messages| `msg_show` event.
|
||||
• New `msg_id` and `progress` paremeter for |ui-messages| `msg_show` event.
|
||||
• New `msg_id` paremeter for |ui-messages| `msg_show` event.
|
||||
• Creating or updating a progress message with |nvim_echo()| triggers a |Progress| event.
|
||||
|
||||
HIGHLIGHTS
|
||||
|
@@ -8,7 +8,7 @@ local M = {}
|
||||
--- @param env? table<string,string|number>
|
||||
--- @return string
|
||||
local function system(cmd, silent, env)
|
||||
if vim.fn.executable(cmd[1]) == 0 then
|
||||
if fn.executable(cmd[1]) == 0 then
|
||||
error(string.format('executable not found: "%s"', cmd[1]), 0)
|
||||
end
|
||||
|
||||
@@ -651,10 +651,10 @@ function M.init_pager()
|
||||
|
||||
-- Raw manpage into (:Man!) overlooks `match('man://')` condition,
|
||||
-- so if the buffer already exists, create new with a non existing name.
|
||||
if vim.fn.bufexists(man_bufname) == 1 then
|
||||
if fn.bufexists(man_bufname) == 1 then
|
||||
local new_bufname = man_bufname
|
||||
for i = 1, 100 do
|
||||
if vim.fn.bufexists(new_bufname) == 0 then
|
||||
if fn.bufexists(new_bufname) == 0 then
|
||||
break
|
||||
end
|
||||
new_bufname = ('%s?new=%s'):format(man_bufname, i)
|
||||
|
@@ -148,7 +148,7 @@ end
|
||||
---@return fun(line: string): string
|
||||
local function make_comment_function(parts, indent)
|
||||
local prefix, nonindent_start, suffix = indent .. parts.left, indent:len() + 1, parts.right
|
||||
local blank_comment = indent .. vim.trim(parts.left) .. vim.trim(parts.right)
|
||||
local blank_comment = indent .. vim.trim(parts.left) .. vim.trim(suffix)
|
||||
|
||||
return function(line)
|
||||
if is_blank(line) then
|
||||
|
@@ -8,9 +8,10 @@ local M = {}
|
||||
--- @param listed string[] Already listed servers
|
||||
--- @return string[] # List of servers found on the current machine in stdpath("run").
|
||||
function M.serverlist(listed)
|
||||
local root = vim.fs.normalize(vim.fn.stdpath('run') .. '/..')
|
||||
local socket_paths = vim.fs.find(function(name, _)
|
||||
return name:match('nvim.*')
|
||||
end, { path = vim.fn.stdpath('run'), type = 'socket', limit = math.huge })
|
||||
end, { path = root, type = 'socket', limit = math.huge })
|
||||
|
||||
local found = {} ---@type string[]
|
||||
for _, socket in ipairs(socket_paths) do
|
||||
|
@@ -1229,7 +1229,7 @@ function M.config(opts, namespace)
|
||||
if float_opts then
|
||||
float_opts = type(float_opts) == 'table' and float_opts or {}
|
||||
|
||||
opts.jump.on_jump = function(_, bufnr)
|
||||
jump_opts.on_jump = function(_, bufnr)
|
||||
M.open_float(vim.tbl_extend('keep', float_opts, {
|
||||
bufnr = bufnr,
|
||||
scope = 'cursor',
|
||||
@@ -1697,7 +1697,7 @@ M.handlers.underline = {
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
opts = opts or {}
|
||||
|
||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1724,7 +1724,7 @@ M.handlers.underline = {
|
||||
end
|
||||
|
||||
local lines =
|
||||
vim.api.nvim_buf_get_lines(diagnostic.bufnr, diagnostic.lnum, diagnostic.lnum + 1, true)
|
||||
api.nvim_buf_get_lines(diagnostic.bufnr, diagnostic.lnum, diagnostic.lnum + 1, true)
|
||||
|
||||
vim.hl.range(
|
||||
bufnr,
|
||||
@@ -1795,7 +1795,7 @@ M.handlers.virtual_text = {
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
opts = opts or {}
|
||||
|
||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
if not api.nvim_buf_is_loaded(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -2491,7 +2491,7 @@ function M.open_float(opts, ...)
|
||||
local location = info.location
|
||||
local file_name = vim.fs.basename(vim.uri_to_fname(location.uri))
|
||||
local info_suffix = ': ' .. info.message
|
||||
related_info_locations[#lines + 1] = info.location
|
||||
related_info_locations[#lines + 1] = location
|
||||
lines[#lines + 1] = string.format(
|
||||
'%s%s:%s:%s%s',
|
||||
default_pre,
|
||||
@@ -2881,11 +2881,11 @@ function M.status(bufnr)
|
||||
return result_str
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('DiagnosticChanged', {
|
||||
group = vim.api.nvim_create_augroup('nvim.diagnostic.status', {}),
|
||||
api.nvim_create_autocmd('DiagnosticChanged', {
|
||||
group = api.nvim_create_augroup('nvim.diagnostic.status', {}),
|
||||
callback = function(ev)
|
||||
if vim.api.nvim_buf_is_loaded(ev.buf) then
|
||||
vim.api.nvim__redraw({ buf = ev.buf, statusline = true })
|
||||
if api.nvim_buf_is_loaded(ev.buf) then
|
||||
api.nvim__redraw({ buf = ev.buf, statusline = true })
|
||||
end
|
||||
end,
|
||||
desc = 'diagnostics component for the statusline',
|
||||
|
@@ -190,9 +190,9 @@ function M.dir(path, opts)
|
||||
if
|
||||
opts.depth
|
||||
and level < opts.depth
|
||||
and (t == 'directory' or (t == 'link' and opts.follow and (vim.uv.fs_stat(
|
||||
M.joinpath(path, f)
|
||||
) or {}).type == 'directory'))
|
||||
and (t == 'directory' or (t == 'link' and opts.follow and (
|
||||
uv.fs_stat(M.joinpath(path, f)) or {}
|
||||
).type == 'directory'))
|
||||
and (not opts.skip or opts.skip(f) ~= false)
|
||||
then
|
||||
dirs[#dirs + 1] = { f, level + 1 }
|
||||
@@ -369,7 +369,7 @@ function M.find(names, opts)
|
||||
|
||||
if
|
||||
type_ == 'directory'
|
||||
or (type_ == 'link' and opts.follow and (vim.uv.fs_stat(f) or {}).type == 'directory')
|
||||
or (type_ == 'link' and opts.follow and (uv.fs_stat(f) or {}).type == 'directory')
|
||||
then
|
||||
dirs[#dirs + 1] = f
|
||||
end
|
||||
|
@@ -72,7 +72,7 @@ function M.range(bufnr, ns, higroup, start, finish, opts)
|
||||
0,
|
||||
}
|
||||
|
||||
local buf_line_count = vim.api.nvim_buf_line_count(bufnr)
|
||||
local buf_line_count = api.nvim_buf_line_count(bufnr)
|
||||
pos1[2] = math.min(pos1[2], buf_line_count)
|
||||
pos2[2] = math.min(pos2[2], buf_line_count)
|
||||
|
||||
@@ -182,8 +182,8 @@ function M.on_yank(opts)
|
||||
|
||||
local higroup = opts.higroup or 'IncSearch'
|
||||
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local winid = api.nvim_get_current_win()
|
||||
|
||||
if yank_timer and not yank_timer:is_closing() then
|
||||
yank_timer:close()
|
||||
@@ -191,7 +191,7 @@ function M.on_yank(opts)
|
||||
yank_hl_clear()
|
||||
end
|
||||
|
||||
vim.api.nvim__ns_set(yank_ns, { wins = { winid } })
|
||||
api.nvim__ns_set(yank_ns, { wins = { winid } })
|
||||
yank_timer, yank_hl_clear = M.range(bufnr, yank_ns, higroup, "'[", "']", {
|
||||
regtype = event.regtype,
|
||||
inclusive = true,
|
||||
|
@@ -458,7 +458,7 @@ end
|
||||
--- @return F
|
||||
local function track(stat, f)
|
||||
return function(...)
|
||||
local start = vim.uv.hrtime()
|
||||
local start = uv.hrtime()
|
||||
local r = { f(...) }
|
||||
stats[stat] = stats[stat] or { total = 0, time = 0 }
|
||||
stats[stat].total = stats[stat].total + 1
|
||||
|
@@ -1376,7 +1376,7 @@ function lsp.formatexpr(opts)
|
||||
local response =
|
||||
client:request_sync(ms.textDocument_rangeFormatting, params, timeout_ms, bufnr)
|
||||
if response and response.result then
|
||||
lsp.util.apply_text_edits(response.result, bufnr, client.offset_encoding)
|
||||
util.apply_text_edits(response.result, bufnr, client.offset_encoding)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
@@ -104,7 +104,7 @@ local function incremental_changes(state, encoding, bufnr, firstline, lastline,
|
||||
|
||||
local line_ending = vim.lsp._buf_get_line_ending(bufnr)
|
||||
local incremental_change = sync.compute_diff(
|
||||
state.lines,
|
||||
prev_lines,
|
||||
curr_lines,
|
||||
firstline,
|
||||
lastline,
|
||||
|
@@ -249,7 +249,7 @@ function State:new(bufnr)
|
||||
group = self.augroup,
|
||||
pattern = 'foldexpr',
|
||||
callback = function()
|
||||
if vim.v.option_type == 'global' or vim.api.nvim_get_current_buf() == bufnr then
|
||||
if vim.v.option_type == 'global' or api.nvim_get_current_buf() == bufnr then
|
||||
vim.lsp._capability.enable('folding_range', false, { bufnr = bufnr })
|
||||
end
|
||||
end,
|
||||
|
@@ -443,7 +443,7 @@ function M.signature_help(config)
|
||||
local buf, win = util.open_floating_preview(lines, 'markdown', config)
|
||||
|
||||
if hl then
|
||||
vim.api.nvim_buf_clear_namespace(buf, sig_help_ns, 0, -1)
|
||||
api.nvim_buf_clear_namespace(buf, sig_help_ns, 0, -1)
|
||||
vim.hl.range(
|
||||
buf,
|
||||
sig_help_ns,
|
||||
@@ -1072,7 +1072,7 @@ end
|
||||
--- @param opts? vim.lsp.WorkspaceDiagnosticsOpts
|
||||
--- @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_dagnostics
|
||||
function M.workspace_diagnostics(opts)
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
validate('opts', opts, 'table', true)
|
||||
|
||||
lsp.diagnostic._workspace_diagnostics(opts or {})
|
||||
end
|
||||
@@ -1435,7 +1435,7 @@ function M.selection_range(direction)
|
||||
|
||||
lsp.buf_request(
|
||||
0,
|
||||
ms.textDocument_selectionRange,
|
||||
method,
|
||||
params,
|
||||
---@param response lsp.SelectionRange[]?
|
||||
function(err, response)
|
||||
|
@@ -871,7 +871,7 @@ function Client:stop(force)
|
||||
self._is_stopping = true
|
||||
local rpc = self.rpc
|
||||
|
||||
vim.lsp._watchfiles.cancel(self.id)
|
||||
lsp._watchfiles.cancel(self.id)
|
||||
|
||||
if force or not self.initialized or self._graceful_shutdown_failed then
|
||||
rpc.terminate()
|
||||
@@ -921,7 +921,7 @@ function Client:_register(registrations)
|
||||
for _, reg in ipairs(registrations) do
|
||||
local method = reg.method
|
||||
if method == ms.workspace_didChangeWatchedFiles then
|
||||
vim.lsp._watchfiles.register(reg, self.id)
|
||||
lsp._watchfiles.register(reg, self.id)
|
||||
elseif not self:_supports_registration(method) then
|
||||
unsupported[#unsupported + 1] = method
|
||||
end
|
||||
@@ -955,7 +955,7 @@ function Client:_unregister(unregistrations)
|
||||
self:_unregister_dynamic(unregistrations)
|
||||
for _, unreg in ipairs(unregistrations) do
|
||||
if unreg.method == ms.workspace_didChangeWatchedFiles then
|
||||
vim.lsp._watchfiles.unregister(unreg, self.id)
|
||||
lsp._watchfiles.unregister(unreg, self.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1096,10 +1096,10 @@ function Client:on_attach(bufnr)
|
||||
-- on_attach and LspAttach callbacks the ability to schedule wrap the
|
||||
-- opt-out (deleting the semanticTokensProvider from capabilities)
|
||||
vim.schedule(function()
|
||||
for _, Capability in pairs(vim.lsp._capability.all) do
|
||||
for _, Capability in pairs(lsp._capability.all) do
|
||||
if
|
||||
self:supports_method(Capability.method)
|
||||
and vim.lsp._capability.is_enabled(Capability.name, {
|
||||
and lsp._capability.is_enabled(Capability.name, {
|
||||
bufnr = bufnr,
|
||||
client_id = self.id,
|
||||
})
|
||||
@@ -1220,10 +1220,10 @@ function Client:_on_detach(bufnr)
|
||||
})
|
||||
end
|
||||
|
||||
for _, Capability in pairs(vim.lsp._capability.all) do
|
||||
for _, Capability in pairs(lsp._capability.all) do
|
||||
if
|
||||
self:supports_method(Capability.method)
|
||||
and vim.lsp._capability.is_enabled(Capability.name, {
|
||||
and lsp._capability.is_enabled(Capability.name, {
|
||||
bufnr = bufnr,
|
||||
client_id = self.id,
|
||||
})
|
||||
@@ -1266,7 +1266,7 @@ local function reset_defaults(bufnr)
|
||||
end
|
||||
vim._with({ buf = bufnr }, function()
|
||||
local keymap = vim.fn.maparg('K', 'n', false, true)
|
||||
if keymap and keymap.callback == vim.lsp.buf.hover and keymap.buffer == 1 then
|
||||
if keymap and keymap.callback == lsp.buf.hover and keymap.buffer == 1 then
|
||||
vim.keymap.del('n', 'K', { buffer = bufnr })
|
||||
end
|
||||
end)
|
||||
|
@@ -864,7 +864,7 @@ end
|
||||
--- - findstart=0: column where the completion starts, or -2 or -3
|
||||
--- - findstart=1: list of matches (actually just calls |complete()|)
|
||||
function M._omnifunc(findstart, base)
|
||||
vim.lsp.log.debug('omnifunc.findstart', { findstart = findstart, base = base })
|
||||
lsp.log.debug('omnifunc.findstart', { findstart = findstart, base = base })
|
||||
assert(base) -- silence luals
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
local clients = lsp.get_clients({ bufnr = bufnr, method = ms.textDocument_completion })
|
||||
|
@@ -498,7 +498,7 @@ function M._workspace_diagnostics(opts)
|
||||
local function handler(error, result, ctx)
|
||||
-- Check for retrigger requests on cancellation errors.
|
||||
-- Unless `retriggerRequest` is explicitly disabled, try again.
|
||||
if error ~= nil and error.code == lsp.protocol.ErrorCodes.ServerCancelled then
|
||||
if error ~= nil and error.code == protocol.ErrorCodes.ServerCancelled then
|
||||
if error.data == nil or error.data.retriggerRequest ~= false then
|
||||
local client = assert(lsp.get_client_by_id(ctx.client_id))
|
||||
client:request(ms.workspace_diagnostic, ctx.params, handler)
|
||||
|
@@ -450,7 +450,7 @@ function M.color_presentation()
|
||||
end
|
||||
vim.list_extend(text_edits, choice.additionalTextEdits or {})
|
||||
|
||||
lsp.util.apply_text_edits(text_edits, bufnr, client.offset_encoding)
|
||||
util.apply_text_edits(text_edits, bufnr, client.offset_encoding)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
@@ -177,7 +177,7 @@ function M.get(filter)
|
||||
--- @param buf integer
|
||||
vim.tbl_map(function(buf)
|
||||
vim.list_extend(hints, M.get(vim.tbl_extend('keep', { bufnr = buf }, filter)))
|
||||
end, vim.api.nvim_list_bufs())
|
||||
end, api.nvim_list_bufs())
|
||||
return hints
|
||||
else
|
||||
bufnr = vim._resolve_bufnr(bufnr)
|
||||
|
@@ -304,7 +304,7 @@ function Completor:apply()
|
||||
range.end_.col,
|
||||
lines
|
||||
)
|
||||
local pos = current.range.start:to_cursor()
|
||||
local pos = range.start:to_cursor()
|
||||
api.nvim_win_set_cursor(vim.fn.bufwinid(self.bufnr), {
|
||||
pos[1] + #lines - 1,
|
||||
(#lines == 1 and pos[2] or 0) + #lines[#lines],
|
||||
|
@@ -225,13 +225,13 @@ end
|
||||
---@param message_type lsp.MessageType
|
||||
function log._from_lsp_level(message_type)
|
||||
if message_type == protocol.MessageType.Error then
|
||||
return vim.log.levels.ERROR
|
||||
return log_levels.ERROR
|
||||
elseif message_type == protocol.MessageType.Warning then
|
||||
return vim.log.levels.WARN
|
||||
return log_levels.WARN
|
||||
elseif message_type == protocol.MessageType.Info or message_type == protocol.MessageType.Log then
|
||||
return vim.log.levels.INFO
|
||||
return log_levels.INFO
|
||||
else
|
||||
return vim.log.levels.DEBUG
|
||||
return log_levels.DEBUG
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -526,11 +526,11 @@ local function merge_dispatchers(dispatchers)
|
||||
---@type vim.lsp.rpc.Dispatchers
|
||||
local merged = {
|
||||
notification = (
|
||||
dispatchers.notification and vim.schedule_wrap(dispatchers.notification)
|
||||
dispatchers.notification and schedule_wrap(dispatchers.notification)
|
||||
or default_dispatchers.notification
|
||||
),
|
||||
on_error = (
|
||||
dispatchers.on_error and vim.schedule_wrap(dispatchers.on_error)
|
||||
dispatchers.on_error and schedule_wrap(dispatchers.on_error)
|
||||
or default_dispatchers.on_error
|
||||
),
|
||||
on_exit = dispatchers.on_exit or default_dispatchers.on_exit,
|
||||
|
@@ -368,7 +368,7 @@ end
|
||||
--- @param hl_group string
|
||||
--- @param priority integer
|
||||
local function set_mark(bufnr, ns, token, hl_group, priority)
|
||||
vim.api.nvim_buf_set_extmark(bufnr, ns, token.line, token.start_col, {
|
||||
api.nvim_buf_set_extmark(bufnr, ns, token.line, token.start_col, {
|
||||
hl_group = hl_group,
|
||||
end_line = token.end_line,
|
||||
end_col = token.end_col,
|
||||
|
@@ -159,7 +159,7 @@ local function compute_start_range(
|
||||
else
|
||||
byte_idx = start_byte_idx + str_utf_start(prev_line, start_byte_idx)
|
||||
--- Convert to 0 based for input, and from 0 based for output
|
||||
char_idx = vim.str_utfindex(prev_line, position_encoding, byte_idx - 1) + 1
|
||||
char_idx = str_utfindex(prev_line, position_encoding, byte_idx - 1) + 1
|
||||
end
|
||||
|
||||
-- Return the start difference (shared for new and prev lines)
|
||||
|
@@ -595,7 +595,7 @@ function M.rename(old_fname, new_fname, opts)
|
||||
opts = opts or {}
|
||||
local skip = not opts.overwrite or opts.ignoreIfExists
|
||||
|
||||
local old_fname_full = vim.uv.fs_realpath(vim.fs.normalize(old_fname, { expand_env = false }))
|
||||
local old_fname_full = uv.fs_realpath(vim.fs.normalize(old_fname, { expand_env = false }))
|
||||
if not old_fname_full then
|
||||
vim.notify('Invalid path: ' .. old_fname, vim.log.levels.ERROR)
|
||||
return
|
||||
@@ -869,7 +869,7 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers
|
||||
active_offset = { offset - 1, offset + #parameter_label - 1 }
|
||||
break
|
||||
end
|
||||
offset = offset + #param.label + 1
|
||||
offset = offset + #plabel + 1
|
||||
end
|
||||
end
|
||||
if parameter.documentation then
|
||||
|
@@ -365,7 +365,7 @@ local function trigger_event(p, event_name, kind)
|
||||
spec.version = spec.version or (uv.fs_stat(p.path) and git_get_default_branch(p.path))
|
||||
|
||||
local data = { kind = kind, spec = spec, path = p.path }
|
||||
vim.api.nvim_exec_autocmds(event_name, { pattern = p.path, data = data })
|
||||
api.nvim_exec_autocmds(event_name, { pattern = p.path, data = data })
|
||||
end
|
||||
|
||||
--- @param title string
|
||||
|
@@ -343,7 +343,7 @@ function M.inspect_tree(opts)
|
||||
local win = api.nvim_get_current_win()
|
||||
local treeview, err = TSTreeView:new(buf, opts.lang)
|
||||
if err and err:match('no parser for lang') then
|
||||
vim.api.nvim_echo({ { err, 'WarningMsg' } }, true, {})
|
||||
api.nvim_echo({ { err, 'WarningMsg' } }, true, {})
|
||||
return
|
||||
elseif not treeview then
|
||||
error(err)
|
||||
@@ -627,7 +627,7 @@ function M.edit_query(lang)
|
||||
local base_buf = base_win and api.nvim_win_get_buf(base_win)
|
||||
local inspect_win = base_buf and vim.b[base_buf].dev_inspect
|
||||
if base_win and base_buf and api.nvim_win_is_valid(inspect_win) then
|
||||
vim.api.nvim_set_current_win(inspect_win)
|
||||
api.nvim_set_current_win(inspect_win)
|
||||
buf = base_buf
|
||||
win = base_win
|
||||
cmd = 'new'
|
||||
|
@@ -9,7 +9,7 @@ function M.check()
|
||||
health.info(
|
||||
string.format(
|
||||
'Treesitter ABI support: min %d, max %d',
|
||||
vim.treesitter.minimum_language_version,
|
||||
ts.minimum_language_version,
|
||||
ts.language_version
|
||||
)
|
||||
)
|
||||
|
@@ -188,7 +188,7 @@ end
|
||||
|
||||
--- Returns available treesitter languages.
|
||||
function M._complete()
|
||||
local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
|
||||
local parsers = api.nvim_get_runtime_file('parser/*', true)
|
||||
local parser_names_set = {} ---@type table<string, boolean>
|
||||
for _, parser in ipairs(parsers) do
|
||||
local parser_name = vim.fn.fnamemodify(parser, ':t:r')
|
||||
|
@@ -421,7 +421,7 @@ for _, k in ipairs(keysets) do
|
||||
local function typename(type)
|
||||
if type == 'HLGroupID' then
|
||||
return 'kObjectTypeInteger'
|
||||
elseif not type or vim.startswith(type, 'Union') then
|
||||
elseif not type or startswith(type, 'Union') then
|
||||
return 'kObjectTypeNil'
|
||||
elseif type == 'StringArray' then
|
||||
return 'kUnpackTypeStringArray'
|
||||
|
@@ -591,7 +591,7 @@ local function render_fields_or_params(xs, generics, classes, cfg)
|
||||
inline_type(p, classes)
|
||||
local nm, ty = p.name, p.type
|
||||
|
||||
local desc = p.classvar and string.format('See |%s|.', cfg.fn_helptag_fmt(p)) or p.desc
|
||||
local desc = p.classvar and fmt('See |%s|.', cfg.fn_helptag_fmt(p)) or p.desc
|
||||
|
||||
local fnm = p.kind == 'operator' and fmt('op(%s)', nm) or fmt_field_name(nm)
|
||||
local pnm = fmt(' • %-' .. indent .. 's', fnm)
|
||||
@@ -1071,7 +1071,7 @@ local function gen_target(cfg)
|
||||
for _, f in ipairs(cfg.section_order) do
|
||||
local section = sections[f]
|
||||
if section then
|
||||
print(string.format(" Rendering section: '%s'", section.title))
|
||||
print(fmt(" Rendering section: '%s'", section.title))
|
||||
local add_sep_and_header = not vim.tbl_contains(cfg.append_only or {}, f)
|
||||
docs[#docs + 1] = render_section(section, add_sep_and_header)
|
||||
end
|
||||
|
@@ -165,7 +165,7 @@ void wildmenu_hide(void)
|
||||
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
||||
|
||||
void msg_show(String kind, Array content, Boolean replace_last, Boolean history, Boolean append,
|
||||
Object id, Dict progress)
|
||||
Object id)
|
||||
FUNC_API_SINCE(6) FUNC_API_FAST FUNC_API_REMOTE_ONLY;
|
||||
void msg_clear(void)
|
||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
||||
|
@@ -152,7 +152,6 @@ bool keep_msg_more = false; // keep_msg was set by msgmore()
|
||||
// Extended msg state, currently used for external UIs with ext_messages
|
||||
static const char *msg_ext_kind = NULL;
|
||||
static MsgID msg_ext_id = { .type = kObjectTypeInteger, .data.integer = 0 };
|
||||
static DictOf(Object) msg_ext_progress = ARRAY_DICT_INIT;
|
||||
static Array *msg_ext_chunks = NULL;
|
||||
static garray_T msg_ext_last_chunk = GA_INIT(sizeof(char), 40);
|
||||
static sattr_T msg_ext_last_attr = -1;
|
||||
@@ -312,6 +311,7 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
||||
}
|
||||
is_multihl = true;
|
||||
msg_ext_skip_flush = true;
|
||||
bool is_progress = strequal(kind, "progress");
|
||||
|
||||
// provide a new id if not given
|
||||
if (id.type == kObjectTypeNil) {
|
||||
@@ -323,6 +323,14 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
||||
}
|
||||
}
|
||||
|
||||
// progress message are special displayed as "title: msg...percent%"
|
||||
if (is_progress && msg_data && msg_data->title.size != 0) {
|
||||
// this block draws the "title:" before the progress-message
|
||||
String title = cstr_as_string(concat_str(msg_data->title.data, ": "));
|
||||
msg_multiline(title, 0, true, false, &need_clear);
|
||||
api_free_string(title);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
|
||||
HlMessageChunk chunk = kv_A(hl_msg, i);
|
||||
if (err) {
|
||||
@@ -332,6 +340,13 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
||||
}
|
||||
assert(!ui_has(kUIMessages) || kind == NULL || msg_ext_kind == kind);
|
||||
}
|
||||
|
||||
if (is_progress && msg_data && msg_data->percent > 0) {
|
||||
// this block draws the "...percent%" before the progress-message
|
||||
char percent_buf[10];
|
||||
vim_snprintf(percent_buf, sizeof(percent_buf), "...%ld%%", (long)msg_data->percent);
|
||||
msg_multiline(cstr_as_string(percent_buf), 0, true, false, &need_clear);
|
||||
}
|
||||
if (history && kv_size(hl_msg)) {
|
||||
msg_hist_add_multihl(id, hl_msg, false, msg_data);
|
||||
}
|
||||
@@ -1106,18 +1121,6 @@ static void msg_hist_add_multihl(MsgID msg_id, HlMessage msg, bool temp, Message
|
||||
msg_ext_history = true;
|
||||
|
||||
msg_ext_id = msg_id;
|
||||
if (strequal(msg_ext_kind, "progress") && msg_data != NULL && ui_has(kUIMessages)) {
|
||||
kv_resize(msg_ext_progress, 3);
|
||||
if (msg_data->title.size != 0) {
|
||||
PUT_C(msg_ext_progress, "title", STRING_OBJ(msg_data->title));
|
||||
}
|
||||
if (msg_data->status.size != 0) {
|
||||
PUT_C(msg_ext_progress, "status", STRING_OBJ(msg_data->status));
|
||||
}
|
||||
if (msg_data->percent >= 0) {
|
||||
PUT_C(msg_ext_progress, "percent", INTEGER_OBJ(msg_data->percent));
|
||||
}
|
||||
}
|
||||
msg_hist_clear(msg_hist_max);
|
||||
}
|
||||
|
||||
@@ -2210,8 +2213,7 @@ void msg_puts_len(const char *const str, const ptrdiff_t len, int hl_id, bool hi
|
||||
if (msg_silent != 0 || *str == NUL) {
|
||||
if (*str == NUL && ui_has(kUIMessages)) {
|
||||
ui_call_msg_show(cstr_as_string("empty"), (Array)ARRAY_DICT_INIT, false, false, false,
|
||||
INTEGER_OBJ(-1),
|
||||
(Dict)ARRAY_DICT_INIT);
|
||||
INTEGER_OBJ(-1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -3239,7 +3241,7 @@ void msg_ext_ui_flush(void)
|
||||
Array *tofree = msg_ext_init_chunks();
|
||||
|
||||
ui_call_msg_show(cstr_as_string(msg_ext_kind), *tofree, msg_ext_overwrite, msg_ext_history,
|
||||
msg_ext_append, msg_ext_id, msg_ext_progress);
|
||||
msg_ext_append, msg_ext_id);
|
||||
// clear info after emiting message.
|
||||
if (msg_ext_history) {
|
||||
api_free_array(*tofree);
|
||||
@@ -3260,7 +3262,6 @@ void msg_ext_ui_flush(void)
|
||||
msg_ext_append = false;
|
||||
msg_ext_kind = NULL;
|
||||
msg_ext_id = INTEGER_OBJ(0);
|
||||
kv_destroy(msg_ext_progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -162,7 +162,9 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
it('serverlist() returns the list of servers', function()
|
||||
local current_server = clear()
|
||||
-- Set XDG_RUNTIME_DIR to a temp dir in this session to properly test serverlist({peer = true}). See #35492
|
||||
local tmp_dir = assert(vim.uv.fs_mkdtemp(vim.fs.dirname(t.tmpname(false)) .. '/XXXXXX'))
|
||||
local current_server = clear({ env = { XDG_RUNTIME_DIR = tmp_dir } })
|
||||
-- There should already be at least one server.
|
||||
local _n = eval('len(serverlist())')
|
||||
|
||||
@@ -191,16 +193,29 @@ describe('server', function()
|
||||
if t.is_os('win') then
|
||||
return
|
||||
end
|
||||
local peer_addr = n.new_pipename()
|
||||
local client =
|
||||
n.new_session(true, { args = { '--clean', '--listen', peer_addr, '--embed' }, merge = false })
|
||||
|
||||
local old_servs_num = #fn.serverlist({ peer = true })
|
||||
local peer_temp = n.new_pipename()
|
||||
local peer_name = peer_temp:match('[^/]*$')
|
||||
|
||||
local tmp_dir2 = assert(vim.uv.fs_mkdtemp(vim.fs.dirname(t.tmpname(false)) .. '/XXXXXX'))
|
||||
local peer_addr = ('%s/%s'):format(tmp_dir2, peer_name)
|
||||
-- Set XDG_RUNTIME_DIR to a temp dir in this session to properly test serverlist({peer = true}). See #35492
|
||||
local client = n.new_session(true, {
|
||||
args = { '--clean', '--listen', peer_addr, '--embed' },
|
||||
env = { XDG_RUNTIME_DIR = tmp_dir2 },
|
||||
merge = false,
|
||||
})
|
||||
n.set_session(client)
|
||||
eq(peer_addr, fn.serverlist()[1])
|
||||
|
||||
n.set_session(current_server)
|
||||
|
||||
new_servs = fn.serverlist({ peer = true })
|
||||
local servers_without_peer = fn.serverlist()
|
||||
eq(true, vim.list_contains(new_servs, peer_addr))
|
||||
eq(true, #servers_without_peer < #new_servs)
|
||||
eq(true, old_servs_num < #new_servs)
|
||||
client:close()
|
||||
end)
|
||||
end)
|
||||
|
@@ -3197,12 +3197,7 @@ describe('progress-message', function()
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = { { 'test-message' } },
|
||||
progress = {
|
||||
percent = 10,
|
||||
status = 'running',
|
||||
title = 'testsuit',
|
||||
},
|
||||
content = { { 'testsuit: test-message...10%' } },
|
||||
history = true,
|
||||
id = 1,
|
||||
kind = 'progress',
|
||||
@@ -3232,12 +3227,7 @@ describe('progress-message', function()
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = { { 'test-message-updated' } },
|
||||
progress = {
|
||||
percent = 50,
|
||||
status = 'running',
|
||||
title = 'TestSuit',
|
||||
},
|
||||
content = { { 'TestSuit: test-message-updated...50%' } },
|
||||
history = true,
|
||||
id = 1,
|
||||
kind = 'progress',
|
||||
@@ -3294,15 +3284,10 @@ describe('progress-message', function()
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = { { 'test-message' } },
|
||||
content = { { 'TestSuit: test-message...10%' } },
|
||||
history = true,
|
||||
id = 1,
|
||||
kind = 'progress',
|
||||
progress = {
|
||||
percent = 10,
|
||||
status = 'running',
|
||||
title = 'TestSuit',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -3491,15 +3476,10 @@ describe('progress-message', function()
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = { { 'supports str-id' } },
|
||||
content = { { 'TestSuit: supports str-id...30%' } },
|
||||
history = true,
|
||||
id = 'str-id',
|
||||
kind = 'progress',
|
||||
progress = {
|
||||
percent = 30,
|
||||
status = 'running',
|
||||
title = 'TestSuit',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -3519,4 +3499,19 @@ describe('progress-message', function()
|
||||
data = {},
|
||||
})
|
||||
end)
|
||||
|
||||
it('tui displays progress message in proper format', function()
|
||||
clear()
|
||||
setup_screen(false)
|
||||
api.nvim_echo(
|
||||
{ { 'test-message' } },
|
||||
true,
|
||||
{ kind = 'progress', title = 'TestSuit', percent = 10, status = 'running' }
|
||||
)
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*3
|
||||
TestSuit: test-message...10% |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user