mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
refactor(lua): consistent use of local aliases
This commit is contained in:

committed by
Christian Clason

parent
a33284c2c0
commit
c10e36fc01
@@ -8,7 +8,7 @@ local M = {}
|
|||||||
--- @param env? table<string,string|number>
|
--- @param env? table<string,string|number>
|
||||||
--- @return string
|
--- @return string
|
||||||
local function system(cmd, silent, env)
|
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)
|
error(string.format('executable not found: "%s"', cmd[1]), 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -651,10 +651,10 @@ function M.init_pager()
|
|||||||
|
|
||||||
-- Raw manpage into (:Man!) overlooks `match('man://')` condition,
|
-- Raw manpage into (:Man!) overlooks `match('man://')` condition,
|
||||||
-- so if the buffer already exists, create new with a non existing name.
|
-- 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
|
local new_bufname = man_bufname
|
||||||
for i = 1, 100 do
|
for i = 1, 100 do
|
||||||
if vim.fn.bufexists(new_bufname) == 0 then
|
if fn.bufexists(new_bufname) == 0 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
new_bufname = ('%s?new=%s'):format(man_bufname, i)
|
new_bufname = ('%s?new=%s'):format(man_bufname, i)
|
||||||
|
@@ -148,7 +148,7 @@ end
|
|||||||
---@return fun(line: string): string
|
---@return fun(line: string): string
|
||||||
local function make_comment_function(parts, indent)
|
local function make_comment_function(parts, indent)
|
||||||
local prefix, nonindent_start, suffix = indent .. parts.left, indent:len() + 1, parts.right
|
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)
|
return function(line)
|
||||||
if is_blank(line) then
|
if is_blank(line) then
|
||||||
|
@@ -1229,7 +1229,7 @@ function M.config(opts, namespace)
|
|||||||
if float_opts then
|
if float_opts then
|
||||||
float_opts = type(float_opts) == 'table' and float_opts or {}
|
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, {
|
M.open_float(vim.tbl_extend('keep', float_opts, {
|
||||||
bufnr = bufnr,
|
bufnr = bufnr,
|
||||||
scope = 'cursor',
|
scope = 'cursor',
|
||||||
@@ -1697,7 +1697,7 @@ M.handlers.underline = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
if not api.nvim_buf_is_loaded(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1724,7 +1724,7 @@ M.handlers.underline = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local lines =
|
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(
|
vim.hl.range(
|
||||||
bufnr,
|
bufnr,
|
||||||
@@ -1795,7 +1795,7 @@ M.handlers.virtual_text = {
|
|||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
if not vim.api.nvim_buf_is_loaded(bufnr) then
|
if not api.nvim_buf_is_loaded(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2491,7 +2491,7 @@ function M.open_float(opts, ...)
|
|||||||
local location = info.location
|
local location = info.location
|
||||||
local file_name = vim.fs.basename(vim.uri_to_fname(location.uri))
|
local file_name = vim.fs.basename(vim.uri_to_fname(location.uri))
|
||||||
local info_suffix = ': ' .. info.message
|
local info_suffix = ': ' .. info.message
|
||||||
related_info_locations[#lines + 1] = info.location
|
related_info_locations[#lines + 1] = location
|
||||||
lines[#lines + 1] = string.format(
|
lines[#lines + 1] = string.format(
|
||||||
'%s%s:%s:%s%s',
|
'%s%s:%s:%s%s',
|
||||||
default_pre,
|
default_pre,
|
||||||
@@ -2881,11 +2881,11 @@ function M.status(bufnr)
|
|||||||
return result_str
|
return result_str
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('DiagnosticChanged', {
|
api.nvim_create_autocmd('DiagnosticChanged', {
|
||||||
group = vim.api.nvim_create_augroup('nvim.diagnostic.status', {}),
|
group = api.nvim_create_augroup('nvim.diagnostic.status', {}),
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
if vim.api.nvim_buf_is_loaded(ev.buf) then
|
if api.nvim_buf_is_loaded(ev.buf) then
|
||||||
vim.api.nvim__redraw({ buf = ev.buf, statusline = true })
|
api.nvim__redraw({ buf = ev.buf, statusline = true })
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
desc = 'diagnostics component for the statusline',
|
desc = 'diagnostics component for the statusline',
|
||||||
|
@@ -190,9 +190,9 @@ function M.dir(path, opts)
|
|||||||
if
|
if
|
||||||
opts.depth
|
opts.depth
|
||||||
and level < opts.depth
|
and level < opts.depth
|
||||||
and (t == 'directory' or (t == 'link' and opts.follow and (vim.uv.fs_stat(
|
and (t == 'directory' or (t == 'link' and opts.follow and (
|
||||||
M.joinpath(path, f)
|
uv.fs_stat(M.joinpath(path, f)) or {}
|
||||||
) or {}).type == 'directory'))
|
).type == 'directory'))
|
||||||
and (not opts.skip or opts.skip(f) ~= false)
|
and (not opts.skip or opts.skip(f) ~= false)
|
||||||
then
|
then
|
||||||
dirs[#dirs + 1] = { f, level + 1 }
|
dirs[#dirs + 1] = { f, level + 1 }
|
||||||
@@ -369,7 +369,7 @@ function M.find(names, opts)
|
|||||||
|
|
||||||
if
|
if
|
||||||
type_ == 'directory'
|
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
|
then
|
||||||
dirs[#dirs + 1] = f
|
dirs[#dirs + 1] = f
|
||||||
end
|
end
|
||||||
|
@@ -72,7 +72,7 @@ function M.range(bufnr, ns, higroup, start, finish, opts)
|
|||||||
0,
|
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)
|
pos1[2] = math.min(pos1[2], buf_line_count)
|
||||||
pos2[2] = math.min(pos2[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 higroup = opts.higroup or 'IncSearch'
|
||||||
|
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = api.nvim_get_current_buf()
|
||||||
local winid = vim.api.nvim_get_current_win()
|
local winid = api.nvim_get_current_win()
|
||||||
|
|
||||||
if yank_timer and not yank_timer:is_closing() then
|
if yank_timer and not yank_timer:is_closing() then
|
||||||
yank_timer:close()
|
yank_timer:close()
|
||||||
@@ -191,7 +191,7 @@ function M.on_yank(opts)
|
|||||||
yank_hl_clear()
|
yank_hl_clear()
|
||||||
end
|
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, "'[", "']", {
|
yank_timer, yank_hl_clear = M.range(bufnr, yank_ns, higroup, "'[", "']", {
|
||||||
regtype = event.regtype,
|
regtype = event.regtype,
|
||||||
inclusive = true,
|
inclusive = true,
|
||||||
|
@@ -458,7 +458,7 @@ end
|
|||||||
--- @return F
|
--- @return F
|
||||||
local function track(stat, f)
|
local function track(stat, f)
|
||||||
return function(...)
|
return function(...)
|
||||||
local start = vim.uv.hrtime()
|
local start = uv.hrtime()
|
||||||
local r = { f(...) }
|
local r = { f(...) }
|
||||||
stats[stat] = stats[stat] or { total = 0, time = 0 }
|
stats[stat] = stats[stat] or { total = 0, time = 0 }
|
||||||
stats[stat].total = stats[stat].total + 1
|
stats[stat].total = stats[stat].total + 1
|
||||||
|
@@ -1376,7 +1376,7 @@ function lsp.formatexpr(opts)
|
|||||||
local response =
|
local response =
|
||||||
client:request_sync(ms.textDocument_rangeFormatting, params, timeout_ms, bufnr)
|
client:request_sync(ms.textDocument_rangeFormatting, params, timeout_ms, bufnr)
|
||||||
if response and response.result then
|
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
|
return 0
|
||||||
end
|
end
|
||||||
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 line_ending = vim.lsp._buf_get_line_ending(bufnr)
|
||||||
local incremental_change = sync.compute_diff(
|
local incremental_change = sync.compute_diff(
|
||||||
state.lines,
|
prev_lines,
|
||||||
curr_lines,
|
curr_lines,
|
||||||
firstline,
|
firstline,
|
||||||
lastline,
|
lastline,
|
||||||
|
@@ -249,7 +249,7 @@ function State:new(bufnr)
|
|||||||
group = self.augroup,
|
group = self.augroup,
|
||||||
pattern = 'foldexpr',
|
pattern = 'foldexpr',
|
||||||
callback = function()
|
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 })
|
vim.lsp._capability.enable('folding_range', false, { bufnr = bufnr })
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@@ -443,7 +443,7 @@ function M.signature_help(config)
|
|||||||
local buf, win = util.open_floating_preview(lines, 'markdown', config)
|
local buf, win = util.open_floating_preview(lines, 'markdown', config)
|
||||||
|
|
||||||
if hl then
|
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(
|
vim.hl.range(
|
||||||
buf,
|
buf,
|
||||||
sig_help_ns,
|
sig_help_ns,
|
||||||
@@ -1072,7 +1072,7 @@ end
|
|||||||
--- @param opts? vim.lsp.WorkspaceDiagnosticsOpts
|
--- @param opts? vim.lsp.WorkspaceDiagnosticsOpts
|
||||||
--- @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_dagnostics
|
--- @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_dagnostics
|
||||||
function M.workspace_diagnostics(opts)
|
function M.workspace_diagnostics(opts)
|
||||||
vim.validate('opts', opts, 'table', true)
|
validate('opts', opts, 'table', true)
|
||||||
|
|
||||||
lsp.diagnostic._workspace_diagnostics(opts or {})
|
lsp.diagnostic._workspace_diagnostics(opts or {})
|
||||||
end
|
end
|
||||||
@@ -1435,7 +1435,7 @@ function M.selection_range(direction)
|
|||||||
|
|
||||||
lsp.buf_request(
|
lsp.buf_request(
|
||||||
0,
|
0,
|
||||||
ms.textDocument_selectionRange,
|
method,
|
||||||
params,
|
params,
|
||||||
---@param response lsp.SelectionRange[]?
|
---@param response lsp.SelectionRange[]?
|
||||||
function(err, response)
|
function(err, response)
|
||||||
|
@@ -871,7 +871,7 @@ function Client:stop(force)
|
|||||||
self._is_stopping = true
|
self._is_stopping = true
|
||||||
local rpc = self.rpc
|
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
|
if force or not self.initialized or self._graceful_shutdown_failed then
|
||||||
rpc.terminate()
|
rpc.terminate()
|
||||||
@@ -921,7 +921,7 @@ function Client:_register(registrations)
|
|||||||
for _, reg in ipairs(registrations) do
|
for _, reg in ipairs(registrations) do
|
||||||
local method = reg.method
|
local method = reg.method
|
||||||
if method == ms.workspace_didChangeWatchedFiles then
|
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
|
elseif not self:_supports_registration(method) then
|
||||||
unsupported[#unsupported + 1] = method
|
unsupported[#unsupported + 1] = method
|
||||||
end
|
end
|
||||||
@@ -955,7 +955,7 @@ function Client:_unregister(unregistrations)
|
|||||||
self:_unregister_dynamic(unregistrations)
|
self:_unregister_dynamic(unregistrations)
|
||||||
for _, unreg in ipairs(unregistrations) do
|
for _, unreg in ipairs(unregistrations) do
|
||||||
if unreg.method == ms.workspace_didChangeWatchedFiles then
|
if unreg.method == ms.workspace_didChangeWatchedFiles then
|
||||||
vim.lsp._watchfiles.unregister(unreg, self.id)
|
lsp._watchfiles.unregister(unreg, self.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1096,10 +1096,10 @@ function Client:on_attach(bufnr)
|
|||||||
-- on_attach and LspAttach callbacks the ability to schedule wrap the
|
-- on_attach and LspAttach callbacks the ability to schedule wrap the
|
||||||
-- opt-out (deleting the semanticTokensProvider from capabilities)
|
-- opt-out (deleting the semanticTokensProvider from capabilities)
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
for _, Capability in pairs(vim.lsp._capability.all) do
|
for _, Capability in pairs(lsp._capability.all) do
|
||||||
if
|
if
|
||||||
self:supports_method(Capability.method)
|
self:supports_method(Capability.method)
|
||||||
and vim.lsp._capability.is_enabled(Capability.name, {
|
and lsp._capability.is_enabled(Capability.name, {
|
||||||
bufnr = bufnr,
|
bufnr = bufnr,
|
||||||
client_id = self.id,
|
client_id = self.id,
|
||||||
})
|
})
|
||||||
@@ -1220,10 +1220,10 @@ function Client:_on_detach(bufnr)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, Capability in pairs(vim.lsp._capability.all) do
|
for _, Capability in pairs(lsp._capability.all) do
|
||||||
if
|
if
|
||||||
self:supports_method(Capability.method)
|
self:supports_method(Capability.method)
|
||||||
and vim.lsp._capability.is_enabled(Capability.name, {
|
and lsp._capability.is_enabled(Capability.name, {
|
||||||
bufnr = bufnr,
|
bufnr = bufnr,
|
||||||
client_id = self.id,
|
client_id = self.id,
|
||||||
})
|
})
|
||||||
@@ -1266,7 +1266,7 @@ local function reset_defaults(bufnr)
|
|||||||
end
|
end
|
||||||
vim._with({ buf = bufnr }, function()
|
vim._with({ buf = bufnr }, function()
|
||||||
local keymap = vim.fn.maparg('K', 'n', false, true)
|
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 })
|
vim.keymap.del('n', 'K', { buffer = bufnr })
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@@ -864,7 +864,7 @@ end
|
|||||||
--- - findstart=0: column where the completion starts, or -2 or -3
|
--- - findstart=0: column where the completion starts, or -2 or -3
|
||||||
--- - findstart=1: list of matches (actually just calls |complete()|)
|
--- - findstart=1: list of matches (actually just calls |complete()|)
|
||||||
function M._omnifunc(findstart, base)
|
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
|
assert(base) -- silence luals
|
||||||
local bufnr = api.nvim_get_current_buf()
|
local bufnr = api.nvim_get_current_buf()
|
||||||
local clients = lsp.get_clients({ bufnr = bufnr, method = ms.textDocument_completion })
|
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)
|
local function handler(error, result, ctx)
|
||||||
-- Check for retrigger requests on cancellation errors.
|
-- Check for retrigger requests on cancellation errors.
|
||||||
-- Unless `retriggerRequest` is explicitly disabled, try again.
|
-- 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
|
if error.data == nil or error.data.retriggerRequest ~= false then
|
||||||
local client = assert(lsp.get_client_by_id(ctx.client_id))
|
local client = assert(lsp.get_client_by_id(ctx.client_id))
|
||||||
client:request(ms.workspace_diagnostic, ctx.params, handler)
|
client:request(ms.workspace_diagnostic, ctx.params, handler)
|
||||||
|
@@ -450,7 +450,7 @@ function M.color_presentation()
|
|||||||
end
|
end
|
||||||
vim.list_extend(text_edits, choice.additionalTextEdits or {})
|
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)
|
end)
|
||||||
end
|
end
|
||||||
|
@@ -177,7 +177,7 @@ function M.get(filter)
|
|||||||
--- @param buf integer
|
--- @param buf integer
|
||||||
vim.tbl_map(function(buf)
|
vim.tbl_map(function(buf)
|
||||||
vim.list_extend(hints, M.get(vim.tbl_extend('keep', { bufnr = buf }, filter)))
|
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
|
return hints
|
||||||
else
|
else
|
||||||
bufnr = vim._resolve_bufnr(bufnr)
|
bufnr = vim._resolve_bufnr(bufnr)
|
||||||
|
@@ -304,7 +304,7 @@ function Completor:apply()
|
|||||||
range.end_.col,
|
range.end_.col,
|
||||||
lines
|
lines
|
||||||
)
|
)
|
||||||
local pos = current.range.start:to_cursor()
|
local pos = range.start:to_cursor()
|
||||||
api.nvim_win_set_cursor(vim.fn.bufwinid(self.bufnr), {
|
api.nvim_win_set_cursor(vim.fn.bufwinid(self.bufnr), {
|
||||||
pos[1] + #lines - 1,
|
pos[1] + #lines - 1,
|
||||||
(#lines == 1 and pos[2] or 0) + #lines[#lines],
|
(#lines == 1 and pos[2] or 0) + #lines[#lines],
|
||||||
|
@@ -225,13 +225,13 @@ end
|
|||||||
---@param message_type lsp.MessageType
|
---@param message_type lsp.MessageType
|
||||||
function log._from_lsp_level(message_type)
|
function log._from_lsp_level(message_type)
|
||||||
if message_type == protocol.MessageType.Error then
|
if message_type == protocol.MessageType.Error then
|
||||||
return vim.log.levels.ERROR
|
return log_levels.ERROR
|
||||||
elseif message_type == protocol.MessageType.Warning then
|
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
|
elseif message_type == protocol.MessageType.Info or message_type == protocol.MessageType.Log then
|
||||||
return vim.log.levels.INFO
|
return log_levels.INFO
|
||||||
else
|
else
|
||||||
return vim.log.levels.DEBUG
|
return log_levels.DEBUG
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -526,11 +526,11 @@ local function merge_dispatchers(dispatchers)
|
|||||||
---@type vim.lsp.rpc.Dispatchers
|
---@type vim.lsp.rpc.Dispatchers
|
||||||
local merged = {
|
local merged = {
|
||||||
notification = (
|
notification = (
|
||||||
dispatchers.notification and vim.schedule_wrap(dispatchers.notification)
|
dispatchers.notification and schedule_wrap(dispatchers.notification)
|
||||||
or default_dispatchers.notification
|
or default_dispatchers.notification
|
||||||
),
|
),
|
||||||
on_error = (
|
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
|
or default_dispatchers.on_error
|
||||||
),
|
),
|
||||||
on_exit = dispatchers.on_exit or default_dispatchers.on_exit,
|
on_exit = dispatchers.on_exit or default_dispatchers.on_exit,
|
||||||
|
@@ -368,7 +368,7 @@ end
|
|||||||
--- @param hl_group string
|
--- @param hl_group string
|
||||||
--- @param priority integer
|
--- @param priority integer
|
||||||
local function set_mark(bufnr, ns, token, hl_group, priority)
|
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,
|
hl_group = hl_group,
|
||||||
end_line = token.end_line,
|
end_line = token.end_line,
|
||||||
end_col = token.end_col,
|
end_col = token.end_col,
|
||||||
|
@@ -159,7 +159,7 @@ local function compute_start_range(
|
|||||||
else
|
else
|
||||||
byte_idx = start_byte_idx + str_utf_start(prev_line, start_byte_idx)
|
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
|
--- 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
|
end
|
||||||
|
|
||||||
-- Return the start difference (shared for new and prev lines)
|
-- 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 {}
|
opts = opts or {}
|
||||||
local skip = not opts.overwrite or opts.ignoreIfExists
|
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
|
if not old_fname_full then
|
||||||
vim.notify('Invalid path: ' .. old_fname, vim.log.levels.ERROR)
|
vim.notify('Invalid path: ' .. old_fname, vim.log.levels.ERROR)
|
||||||
return
|
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 }
|
active_offset = { offset - 1, offset + #parameter_label - 1 }
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
offset = offset + #param.label + 1
|
offset = offset + #plabel + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if parameter.documentation then
|
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))
|
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 }
|
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
|
end
|
||||||
|
|
||||||
--- @param title string
|
--- @param title string
|
||||||
|
@@ -343,7 +343,7 @@ function M.inspect_tree(opts)
|
|||||||
local win = api.nvim_get_current_win()
|
local win = api.nvim_get_current_win()
|
||||||
local treeview, err = TSTreeView:new(buf, opts.lang)
|
local treeview, err = TSTreeView:new(buf, opts.lang)
|
||||||
if err and err:match('no parser for lang') then
|
if err and err:match('no parser for lang') then
|
||||||
vim.api.nvim_echo({ { err, 'WarningMsg' } }, true, {})
|
api.nvim_echo({ { err, 'WarningMsg' } }, true, {})
|
||||||
return
|
return
|
||||||
elseif not treeview then
|
elseif not treeview then
|
||||||
error(err)
|
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 base_buf = base_win and api.nvim_win_get_buf(base_win)
|
||||||
local inspect_win = base_buf and vim.b[base_buf].dev_inspect
|
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
|
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
|
buf = base_buf
|
||||||
win = base_win
|
win = base_win
|
||||||
cmd = 'new'
|
cmd = 'new'
|
||||||
|
@@ -9,7 +9,7 @@ function M.check()
|
|||||||
health.info(
|
health.info(
|
||||||
string.format(
|
string.format(
|
||||||
'Treesitter ABI support: min %d, max %d',
|
'Treesitter ABI support: min %d, max %d',
|
||||||
vim.treesitter.minimum_language_version,
|
ts.minimum_language_version,
|
||||||
ts.language_version
|
ts.language_version
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@@ -188,7 +188,7 @@ end
|
|||||||
|
|
||||||
--- Returns available treesitter languages.
|
--- Returns available treesitter languages.
|
||||||
function M._complete()
|
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>
|
local parser_names_set = {} ---@type table<string, boolean>
|
||||||
for _, parser in ipairs(parsers) do
|
for _, parser in ipairs(parsers) do
|
||||||
local parser_name = vim.fn.fnamemodify(parser, ':t:r')
|
local parser_name = vim.fn.fnamemodify(parser, ':t:r')
|
||||||
|
@@ -421,7 +421,7 @@ for _, k in ipairs(keysets) do
|
|||||||
local function typename(type)
|
local function typename(type)
|
||||||
if type == 'HLGroupID' then
|
if type == 'HLGroupID' then
|
||||||
return 'kObjectTypeInteger'
|
return 'kObjectTypeInteger'
|
||||||
elseif not type or vim.startswith(type, 'Union') then
|
elseif not type or startswith(type, 'Union') then
|
||||||
return 'kObjectTypeNil'
|
return 'kObjectTypeNil'
|
||||||
elseif type == 'StringArray' then
|
elseif type == 'StringArray' then
|
||||||
return 'kUnpackTypeStringArray'
|
return 'kUnpackTypeStringArray'
|
||||||
|
@@ -591,7 +591,7 @@ local function render_fields_or_params(xs, generics, classes, cfg)
|
|||||||
inline_type(p, classes)
|
inline_type(p, classes)
|
||||||
local nm, ty = p.name, p.type
|
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 fnm = p.kind == 'operator' and fmt('op(%s)', nm) or fmt_field_name(nm)
|
||||||
local pnm = fmt(' • %-' .. indent .. 's', fnm)
|
local pnm = fmt(' • %-' .. indent .. 's', fnm)
|
||||||
@@ -1071,7 +1071,7 @@ local function gen_target(cfg)
|
|||||||
for _, f in ipairs(cfg.section_order) do
|
for _, f in ipairs(cfg.section_order) do
|
||||||
local section = sections[f]
|
local section = sections[f]
|
||||||
if section then
|
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)
|
local add_sep_and_header = not vim.tbl_contains(cfg.append_only or {}, f)
|
||||||
docs[#docs + 1] = render_section(section, add_sep_and_header)
|
docs[#docs + 1] = render_section(section, add_sep_and_header)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user