mirror of
https://github.com/neovim/neovim.git
synced 2026-04-26 09:14:15 +00:00
backport: feat(api): rename buffer to buf (#38899)
feat(api): rename buffer to buf Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Jordan <46637683+JordanllHarper@users.noreply.github.com>
This commit is contained in:
@@ -447,7 +447,7 @@ do
|
||||
assert(bufnr > 0, 'Invalid buffer number')
|
||||
api.nvim_create_autocmd('BufWipeout', {
|
||||
group = group,
|
||||
buffer = bufnr,
|
||||
buf = bufnr,
|
||||
callback = function()
|
||||
rawset(t, bufnr, nil)
|
||||
end,
|
||||
@@ -867,7 +867,7 @@ local function schedule_display(namespace, bufnr, args)
|
||||
local group = api.nvim_create_augroup(key, { clear = true })
|
||||
api.nvim_create_autocmd(insert_leave_auto_cmds, {
|
||||
group = group,
|
||||
buffer = bufnr,
|
||||
buf = bufnr,
|
||||
callback = function()
|
||||
execute_scheduled_display(namespace, bufnr)
|
||||
end,
|
||||
@@ -1352,8 +1352,8 @@ local function once_buf_loaded(bufnr, fn)
|
||||
if api.nvim_buf_is_loaded(bufnr) then
|
||||
fn()
|
||||
else
|
||||
return api.nvim_create_autocmd('BufRead', {
|
||||
buffer = bufnr,
|
||||
api.nvim_create_autocmd('BufRead', {
|
||||
buf = bufnr,
|
||||
once = true,
|
||||
callback = function()
|
||||
fn()
|
||||
@@ -1455,7 +1455,7 @@ function M.set(namespace, bufnr, diagnostics, opts)
|
||||
|
||||
api.nvim_exec_autocmds('DiagnosticChanged', {
|
||||
modeline = false,
|
||||
buffer = bufnr,
|
||||
buf = bufnr,
|
||||
-- TODO(lewis6991): should this be deepcopy()'d like they are in vim.diagnostic.get()
|
||||
data = { diagnostics = diagnostics },
|
||||
})
|
||||
@@ -1944,14 +1944,13 @@ M.handlers.virtual_text = {
|
||||
{ clear = true }
|
||||
)
|
||||
end
|
||||
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_text_augroup, buffer = bufnr })
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_text_augroup, buf = bufnr })
|
||||
|
||||
local line_diagnostics = diagnostic_lines(diagnostics, true)
|
||||
|
||||
if opts.virtual_text.current_line ~= nil then
|
||||
api.nvim_create_autocmd('CursorMoved', {
|
||||
buffer = bufnr,
|
||||
buf = bufnr,
|
||||
group = ns.user_data.virt_text_augroup,
|
||||
callback = function()
|
||||
render_virtual_text(
|
||||
@@ -1976,7 +1975,7 @@ M.handlers.virtual_text = {
|
||||
diagnostic_cache_extmarks[bufnr][ns.user_data.virt_text_ns] = {}
|
||||
if api.nvim_buf_is_valid(bufnr) then
|
||||
api.nvim_buf_clear_namespace(bufnr, ns.user_data.virt_text_ns, 0, -1)
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_text_augroup, buffer = bufnr })
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_text_augroup, buf = bufnr })
|
||||
end
|
||||
end
|
||||
end,
|
||||
@@ -2197,7 +2196,7 @@ M.handlers.virtual_lines = {
|
||||
)
|
||||
end
|
||||
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_lines_augroup, buffer = bufnr })
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_lines_augroup, buf = bufnr })
|
||||
|
||||
diagnostics =
|
||||
reformat_diagnostics(opts.virtual_lines.format or format_virtual_lines, diagnostics)
|
||||
@@ -2207,7 +2206,7 @@ M.handlers.virtual_lines = {
|
||||
-- diagnostics we need when the cursor line doesn't change.
|
||||
local line_diagnostics = diagnostic_lines(diagnostics, true)
|
||||
api.nvim_create_autocmd('CursorMoved', {
|
||||
buffer = bufnr,
|
||||
buf = bufnr,
|
||||
group = ns.user_data.virt_lines_augroup,
|
||||
callback = function()
|
||||
render_virtual_lines(
|
||||
@@ -2237,7 +2236,7 @@ M.handlers.virtual_lines = {
|
||||
diagnostic_cache_extmarks[bufnr][ns.user_data.virt_lines_ns] = {}
|
||||
if api.nvim_buf_is_valid(bufnr) then
|
||||
api.nvim_buf_clear_namespace(bufnr, ns.user_data.virt_lines_ns, 0, -1)
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_lines_augroup, buffer = bufnr })
|
||||
api.nvim_clear_autocmds({ group = ns.user_data.virt_lines_augroup, buf = bufnr })
|
||||
end
|
||||
end
|
||||
end,
|
||||
@@ -2713,7 +2712,7 @@ function M.reset(namespace, bufnr)
|
||||
if api.nvim_buf_is_valid(iter_bufnr) then
|
||||
api.nvim_exec_autocmds('DiagnosticChanged', {
|
||||
modeline = false,
|
||||
buffer = iter_bufnr,
|
||||
buf = iter_bufnr,
|
||||
data = { diagnostics = {} },
|
||||
})
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user