Merge #32001 from MariaSolOs/consistent-namespaces

This commit is contained in:
Justin M. Keyes 2025-01-15 02:01:44 -08:00 committed by GitHub
commit 3ee63edc1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 76 additions and 67 deletions

View File

@ -508,6 +508,15 @@ be a parameter (typically manifest as mutually-exclusive buf/win/… flags like
- Example: `nvim_buf_del_mark` acts on a `Buffer` object (the first parameter) - Example: `nvim_buf_del_mark` acts on a `Buffer` object (the first parameter)
and uses the "del" {verb}. and uses the "del" {verb}.
*dev-namespace-name*
Use namespace names like `nvim.foo.bar`: >
vim.api.nvim_create_namespace('nvim.lsp.codelens')
<
*dev-augroup-name*
Use autocommand group names like `nvim.foo.bar`: >
vim.api.nvim_create_augroup('nvim.treesitter.dev')
<
INTERFACE PATTERNS *dev-api-patterns* INTERFACE PATTERNS *dev-api-patterns*

View File

@ -122,7 +122,7 @@ fully disable the mouse or popup-menu, do any of the following:
< <
To remove the default popup-menu without disabling mouse: >vim To remove the default popup-menu without disabling mouse: >vim
aunmenu PopUp aunmenu PopUp
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
To remove only the "How-to disable mouse" menu item (and its separator): >vim To remove only the "How-to disable mouse" menu item (and its separator): >vim
aunmenu PopUp.How-to\ disable\ mouse aunmenu PopUp.How-to\ disable\ mouse

View File

@ -46,7 +46,7 @@ local query = vim.treesitter.query.parse(
(#set! @code lang @_lang)) (#set! @code lang @_lang))
]] ]]
) )
local run_message_ns = vim.api.nvim_create_namespace('vimdoc/run_message') local run_message_ns = vim.api.nvim_create_namespace('nvim.vimdoc.run_message')
vim.api.nvim_buf_clear_namespace(0, run_message_ns, 0, -1) vim.api.nvim_buf_clear_namespace(0, run_message_ns, 0, -1)
for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do

View File

@ -21,7 +21,7 @@ local query_lint_on = vim.g.query_lint_on or { 'BufEnter', 'BufWrite' }
if not vim.b.disable_query_linter and #query_lint_on > 0 then if not vim.b.disable_query_linter and #query_lint_on > 0 then
vim.api.nvim_create_autocmd(query_lint_on, { vim.api.nvim_create_autocmd(query_lint_on, {
group = vim.api.nvim_create_augroup('querylint', { clear = false }), group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }),
buffer = buf, buffer = buf,
callback = function() callback = function()
vim.treesitter.query.lint(buf) vim.treesitter.query.lint(buf)

View File

@ -145,7 +145,7 @@ local vim9 = (function()
-- work well for calling ":source X" from within a vimscript/vim9script -- work well for calling ":source X" from within a vimscript/vim9script
-- function -- function
M.make_source_cmd = function() M.make_source_cmd = function()
local group = vim.api.nvim_create_augroup('vim9script-source', {}) local group = vim.api.nvim_create_augroup('nvim.vim9script_source', {})
vim.api.nvim_create_autocmd('SourceCmd', { vim.api.nvim_create_autocmd('SourceCmd', {
pattern = '*.vim', pattern = '*.vim',
group = group, group = group,

View File

@ -151,7 +151,7 @@ function properties.trim_trailing_whitespace(bufnr, val)
) )
if val == 'true' then if val == 'true' then
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
group = 'editorconfig', group = 'nvim.editorconfig',
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
local view = vim.fn.winsaveview() local view = vim.fn.winsaveview()
@ -163,7 +163,7 @@ function properties.trim_trailing_whitespace(bufnr, val)
else else
vim.api.nvim_clear_autocmds({ vim.api.nvim_clear_autocmds({
event = 'BufWritePre', event = 'BufWritePre',
group = 'editorconfig', group = 'nvim.editorconfig',
buffer = bufnr, buffer = bufnr,
}) })
end end
@ -180,7 +180,7 @@ function properties.insert_final_newline(bufnr, val)
local endofline = val == 'true' local endofline = val == 'true'
if vim.bo[bufnr].endofline ~= endofline then if vim.bo[bufnr].endofline ~= endofline then
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
group = 'editorconfig', group = 'nvim.editorconfig',
buffer = bufnr, buffer = bufnr,
once = true, once = true,
callback = function() callback = function()

View File

@ -412,7 +412,7 @@ do
end end
end end
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim_popupmenu', {}) local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim.popupmenu', {})
vim.api.nvim_create_autocmd('MenuPopup', { vim.api.nvim_create_autocmd('MenuPopup', {
pattern = '*', pattern = '*',
group = nvim_popupmenu_augroup, group = nvim_popupmenu_augroup,
@ -429,7 +429,7 @@ end
--- Default autocommands. See |default-autocmds| --- Default autocommands. See |default-autocmds|
do do
local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim_terminal', {}) local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim.terminal', {})
vim.api.nvim_create_autocmd('BufReadCmd', { vim.api.nvim_create_autocmd('BufReadCmd', {
pattern = 'term://*', pattern = 'term://*',
group = nvim_terminal_augroup, group = nvim_terminal_augroup,
@ -509,14 +509,14 @@ do
vim.api.nvim_create_autocmd('CmdwinEnter', { vim.api.nvim_create_autocmd('CmdwinEnter', {
pattern = '[:>]', pattern = '[:>]',
desc = 'Limit syntax sync to maxlines=1 in the command window', desc = 'Limit syntax sync to maxlines=1 in the command window',
group = vim.api.nvim_create_augroup('nvim_cmdwin', {}), group = vim.api.nvim_create_augroup('nvim.cmdwin', {}),
command = 'syntax sync minlines=1 maxlines=1', command = 'syntax sync minlines=1 maxlines=1',
}) })
vim.api.nvim_create_autocmd('SwapExists', { vim.api.nvim_create_autocmd('SwapExists', {
pattern = '*', pattern = '*',
desc = 'Skip the swapfile prompt when the swapfile is owned by a running Nvim process', desc = 'Skip the swapfile prompt when the swapfile is owned by a running Nvim process',
group = vim.api.nvim_create_augroup('nvim_swapfile', {}), group = vim.api.nvim_create_augroup('nvim.swapfile', {}),
callback = function() callback = function()
local info = vim.fn.swapinfo(vim.v.swapname) local info = vim.fn.swapinfo(vim.v.swapname)
local user = vim.uv.os_get_passwd().username local user = vim.uv.os_get_passwd().username
@ -543,7 +543,7 @@ do
end end
if tty then if tty then
local group = vim.api.nvim_create_augroup('nvim_tty', {}) local group = vim.api.nvim_create_augroup('nvim.tty', {})
--- Set an option after startup (so that OptionSet is fired), but only if not --- Set an option after startup (so that OptionSet is fired), but only if not
--- already set by the user. --- already set by the user.

View File

@ -356,7 +356,7 @@ local bufnr_and_namespace_cacher_mt = {
-- bufnr -> ns -> Diagnostic[] -- bufnr -> ns -> Diagnostic[]
local diagnostic_cache = {} --- @type table<integer,table<integer,vim.Diagnostic[]>> local diagnostic_cache = {} --- @type table<integer,table<integer,vim.Diagnostic[]>>
do do
local group = api.nvim_create_augroup('DiagnosticBufWipeout', {}) local group = api.nvim_create_augroup('nvim.diagnostic.buf_wipeout', {})
setmetatable(diagnostic_cache, { setmetatable(diagnostic_cache, {
--- @param t table<integer,vim.Diagnostic[]> --- @param t table<integer,vim.Diagnostic[]>
--- @param bufnr integer --- @param bufnr integer
@ -1402,7 +1402,7 @@ M.handlers.signs = {
local ns = M.get_namespace(namespace) local ns = M.get_namespace(namespace)
if not ns.user_data.sign_ns then if not ns.user_data.sign_ns then
ns.user_data.sign_ns = ns.user_data.sign_ns =
api.nvim_create_namespace(string.format('%s/diagnostic/signs', ns.name)) api.nvim_create_namespace(string.format('nvim.%s.diagnostic.signs', ns.name))
end end
-- Handle legacy diagnostic sign definitions -- Handle legacy diagnostic sign definitions
@ -1500,7 +1500,7 @@ M.handlers.underline = {
local ns = M.get_namespace(namespace) local ns = M.get_namespace(namespace)
if not ns.user_data.underline_ns then if not ns.user_data.underline_ns then
ns.user_data.underline_ns = ns.user_data.underline_ns =
api.nvim_create_namespace(string.format('%s/diagnostic/underline', ns.name)) api.nvim_create_namespace(string.format('nvim.%s.diagnostic.underline', ns.name))
end end
local underline_ns = ns.user_data.underline_ns local underline_ns = ns.user_data.underline_ns
@ -1572,7 +1572,7 @@ M.handlers.virtual_text = {
local ns = M.get_namespace(namespace) local ns = M.get_namespace(namespace)
if not ns.user_data.virt_text_ns then if not ns.user_data.virt_text_ns then
ns.user_data.virt_text_ns = ns.user_data.virt_text_ns =
api.nvim_create_namespace(string.format('%s/diagnostic/virtual_text', ns.name)) api.nvim_create_namespace(string.format('nvim.%s.diagnostic.virtual_text', ns.name))
end end
local virt_text_ns = ns.user_data.virt_text_ns local virt_text_ns = ns.user_data.virt_text_ns

View File

@ -115,7 +115,7 @@ function M.range(bufnr, ns, higroup, start, finish, opts)
end end
end end
local yank_ns = api.nvim_create_namespace('hlyank') local yank_ns = api.nvim_create_namespace('nvim.hlyank')
local yank_timer --- @type uv.uv_timer_t? local yank_timer --- @type uv.uv_timer_t?
local yank_cancel --- @type fun()? local yank_cancel --- @type fun()?

View File

@ -843,7 +843,7 @@ local function buf_attach(bufnr)
attached_buffers[bufnr] = true attached_buffers[bufnr] = true
local uri = vim.uri_from_bufnr(bufnr) local uri = vim.uri_from_bufnr(bufnr)
local augroup = ('lsp_b_%d_save'):format(bufnr) local augroup = ('nvim.lsp.b_%d_save'):format(bufnr)
local group = api.nvim_create_augroup(augroup, { clear = true }) local group = api.nvim_create_augroup(augroup, { clear = true })
api.nvim_create_autocmd('BufWritePre', { api.nvim_create_autocmd('BufWritePre', {
group = group, group = group,

View File

@ -171,7 +171,7 @@ end
-- 1. Implement clearing `bufstate` and event hooks -- 1. Implement clearing `bufstate` and event hooks
-- when no clients in the buffer support the corresponding method. -- when no clients in the buffer support the corresponding method.
-- 2. Then generalize this state management to other LSP modules. -- 2. Then generalize this state management to other LSP modules.
local augroup_setup = api.nvim_create_augroup('vim_lsp_folding_range/setup', {}) local augroup_setup = api.nvim_create_augroup('nvim.lsp.folding_range.setup', {})
--- Initialize `bufstate` and event hooks, then request folding ranges. --- Initialize `bufstate` and event hooks, then request folding ranges.
--- Manage their lifecycle within this function. --- Manage their lifecycle within this function.

View File

@ -20,7 +20,7 @@ local function client_positional_params(params)
end end
end end
local hover_ns = api.nvim_create_namespace('vim_lsp_hover_range') local hover_ns = api.nvim_create_namespace('nvim.lsp.hover_range')
--- @class vim.lsp.buf.hover.Opts : vim.lsp.util.open_floating_preview.Opts --- @class vim.lsp.buf.hover.Opts : vim.lsp.util.open_floating_preview.Opts
--- @field silent? boolean --- @field silent? boolean
@ -324,7 +324,7 @@ local function process_signature_help_results(results)
return signatures return signatures
end end
local sig_help_ns = api.nvim_create_namespace('vim_lsp_signature_help') local sig_help_ns = api.nvim_create_namespace('nvim.lsp.signature_help')
--- @class vim.lsp.buf.signature_help.Opts : vim.lsp.util.open_floating_preview.Opts --- @class vim.lsp.buf.signature_help.Opts : vim.lsp.util.open_floating_preview.Opts
--- @field silent? boolean --- @field silent? boolean

View File

@ -21,7 +21,7 @@ local lens_cache_by_buf = setmetatable({}, {
---client_id -> namespace ---client_id -> namespace
local namespaces = setmetatable({}, { local namespaces = setmetatable({}, {
__index = function(t, key) __index = function(t, key)
local value = api.nvim_create_namespace('vim_lsp_codelens:' .. key) local value = api.nvim_create_namespace('nvim.lsp.codelens:' .. key)
rawset(t, key, value) rawset(t, key, value)
return value return value
end, end,
@ -30,7 +30,7 @@ local namespaces = setmetatable({}, {
---@private ---@private
M.__namespaces = namespaces M.__namespaces = namespaces
local augroup = api.nvim_create_augroup('vim_lsp_codelens', {}) local augroup = api.nvim_create_augroup('nvim.lsp.codelens', {})
api.nvim_create_autocmd('LspDetach', { api.nvim_create_autocmd('LspDetach', {
group = augroup, group = augroup,

View File

@ -630,7 +630,7 @@ local function enable_completions(client_id, bufnr, opts)
-- Set up autocommands. -- Set up autocommands.
local group = local group =
api.nvim_create_augroup(string.format('vim/lsp/completion-%d', bufnr), { clear = true }) api.nvim_create_augroup(string.format('nvim.lsp.completion_%d', bufnr), { clear = true })
api.nvim_create_autocmd('CompleteDone', { api.nvim_create_autocmd('CompleteDone', {
group = group, group = group,
buffer = bufnr, buffer = bufnr,

View File

@ -5,7 +5,7 @@ local api = vim.api
local M = {} local M = {}
local augroup = api.nvim_create_augroup('vim_lsp_diagnostic', {}) local augroup = api.nvim_create_augroup('nvim.lsp.diagnostic', {})
local DEFAULT_CLIENT_ID = -1 local DEFAULT_CLIENT_ID = -1

View File

@ -382,7 +382,7 @@ end
--- @diagnostic disable-next-line: deprecated --- @diagnostic disable-next-line: deprecated
RCS[ms.textDocument_hover] = M.hover RCS[ms.textDocument_hover] = M.hover
local sig_help_ns = api.nvim_create_namespace('vim_lsp_signature_help') local sig_help_ns = api.nvim_create_namespace('nvim.lsp.signature_help')
--- @deprecated remove in 0.13 --- @deprecated remove in 0.13
--- |lsp-handler| for the method "textDocument/signatureHelp". --- |lsp-handler| for the method "textDocument/signatureHelp".

View File

@ -29,8 +29,8 @@ local bufstates = vim.defaulttable(function(_)
}) })
end) end)
local namespace = api.nvim_create_namespace('vim_lsp_inlayhint') local namespace = api.nvim_create_namespace('nvim.lsp.inlayhint')
local augroup = api.nvim_create_augroup('vim_lsp_inlayhint', {}) local augroup = api.nvim_create_augroup('nvim.lsp.inlayhint', {})
--- |lsp-handler| for the method `textDocument/inlayHint` --- |lsp-handler| for the method `textDocument/inlayHint`
--- Store hints for a specific buffer and client --- Store hints for a specific buffer and client

View File

@ -166,7 +166,7 @@ function STHighlighter.new(bufnr)
local self = setmetatable({}, { __index = STHighlighter }) local self = setmetatable({}, { __index = STHighlighter })
self.bufnr = bufnr self.bufnr = bufnr
self.augroup = api.nvim_create_augroup('vim_lsp_semantic_tokens:' .. bufnr, { clear = true }) self.augroup = api.nvim_create_augroup('nvim.lsp.semantic_tokens:' .. bufnr, { clear = true })
self.client_state = {} self.client_state = {}
STHighlighter.active[bufnr] = self STHighlighter.active[bufnr] = self
@ -225,7 +225,7 @@ function STHighlighter:attach(client_id)
local state = self.client_state[client_id] local state = self.client_state[client_id]
if not state then if not state then
state = { state = {
namespace = api.nvim_create_namespace('vim_lsp_semantic_tokens:' .. client_id), namespace = api.nvim_create_namespace('nvim.lsp.semantic_tokens:' .. client_id),
active_request = {}, active_request = {},
current_result = {}, current_result = {},
} }
@ -805,7 +805,7 @@ function M._refresh(err, _, ctx)
return vim.NIL return vim.NIL
end end
local namespace = api.nvim_create_namespace('vim_lsp_semantic_tokens') local namespace = api.nvim_create_namespace('nvim.lsp.semantic_tokens')
api.nvim_set_decoration_provider(namespace, { api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr, topline, botline) on_win = function(_, _, bufnr, topline, botline)
local highlighter = STHighlighter.active[bufnr] local highlighter = STHighlighter.active[bufnr]

View File

@ -1357,7 +1357,7 @@ end
---@param bufnrs table list of buffers where the preview window will remain visible ---@param bufnrs table list of buffers where the preview window will remain visible
---@see autocmd-events ---@see autocmd-events
local function close_preview_autocmd(events, winnr, bufnrs) local function close_preview_autocmd(events, winnr, bufnrs)
local augroup = api.nvim_create_augroup('preview_window_' .. winnr, { local augroup = api.nvim_create_augroup('nvim.preview_window_' .. winnr, {
clear = true, clear = true,
}) })
@ -1619,7 +1619,7 @@ function M.open_floating_preview(contents, syntax, opts)
api.nvim_buf_set_var(bufnr, 'lsp_floating_preview', floating_winnr) api.nvim_buf_set_var(bufnr, 'lsp_floating_preview', floating_winnr)
end end
local augroup_name = ('closing_floating_preview_%d'):format(floating_winnr) local augroup_name = ('nvim.closing_floating_preview_%d'):format(floating_winnr)
local ok = local ok =
pcall(api.nvim_get_autocmds, { group = augroup_name, pattern = tostring(floating_winnr) }) pcall(api.nvim_get_autocmds, { group = augroup_name, pattern = tostring(floating_winnr) })
if not ok then if not ok then
@ -1650,7 +1650,7 @@ function M.open_floating_preview(contents, syntax, opts)
end end
do --[[ References ]] do --[[ References ]]
local reference_ns = api.nvim_create_namespace('vim_lsp_references') local reference_ns = api.nvim_create_namespace('nvim.lsp.references')
--- Removes document highlights from a buffer. --- Removes document highlights from a buffer.
--- ---

View File

@ -1,6 +1,6 @@
local G = vim.lsp._snippet_grammar local G = vim.lsp._snippet_grammar
local snippet_group = vim.api.nvim_create_augroup('vim/snippet', {}) local snippet_group = vim.api.nvim_create_augroup('nvim.snippet', {})
local snippet_ns = vim.api.nvim_create_namespace('vim/snippet') local snippet_ns = vim.api.nvim_create_namespace('nvim.snippet')
local hl_group = 'SnippetTabstop' local hl_group = 'SnippetTabstop'
local jump_forward_key = '<tab>' local jump_forward_key = '<tab>'
local jump_backward_key = '<s-tab>' local jump_backward_key = '<s-tab>'

View File

@ -192,7 +192,7 @@ local M = {}
---@type table<integer,TS.FoldInfo> ---@type table<integer,TS.FoldInfo>
local foldinfos = {} local foldinfos = {}
local group = api.nvim_create_augroup('treesitter/fold', {}) local group = api.nvim_create_augroup('nvim.treesitter.fold', {})
--- Update the folds in the windows that contain the buffer and use expr foldmethod (assuming that --- Update the folds in the windows that contain the buffer and use expr foldmethod (assuming that
--- the user doesn't use different foldexpr for the same buffer). --- the user doesn't use different foldexpr for the same buffer).

View File

@ -1,6 +1,6 @@
local api = vim.api local api = vim.api
local namespace = api.nvim_create_namespace('vim.treesitter.query_linter') local namespace = api.nvim_create_namespace('nvim.treesitter.query_linter')
local M = {} local M = {}

View File

@ -119,7 +119,7 @@ function TSTreeView:new(bufnr, lang)
end end
local t = { local t = {
ns = api.nvim_create_namespace('treesitter/dev-inspect'), ns = api.nvim_create_namespace('nvim.treesitter.dev_inspect'),
nodes = nodes, nodes = nodes,
named = named, named = named,
---@type vim.treesitter.dev.TSTreeViewOpts ---@type vim.treesitter.dev.TSTreeViewOpts
@ -135,7 +135,7 @@ function TSTreeView:new(bufnr, lang)
return t return t
end end
local decor_ns = api.nvim_create_namespace('ts.dev') local decor_ns = api.nvim_create_namespace('nvim.treesitter.dev')
---@param range Range4 ---@param range Range4
---@return string ---@return string
@ -442,7 +442,7 @@ function M.inspect_tree(opts)
end, end,
}) })
local group = api.nvim_create_augroup('treesitter/dev', {}) local group = api.nvim_create_augroup('nvim.treesitter.dev', {})
api.nvim_create_autocmd('CursorMoved', { api.nvim_create_autocmd('CursorMoved', {
group = group, group = group,
@ -547,7 +547,7 @@ function M.inspect_tree(opts)
}) })
end end
local edit_ns = api.nvim_create_namespace('treesitter/dev-edit') local edit_ns = api.nvim_create_namespace('nvim.treesitter.dev_edit')
---@param query_win integer ---@param query_win integer
---@param base_win integer ---@param base_win integer
@ -633,7 +633,7 @@ function M.edit_query(lang)
-- can infer the language later. -- can infer the language later.
api.nvim_buf_set_name(query_buf, string.format('%s/query_editor.scm', lang)) api.nvim_buf_set_name(query_buf, string.format('%s/query_editor.scm', lang))
local group = api.nvim_create_augroup('treesitter/dev-edit', {}) local group = api.nvim_create_augroup('nvim.treesitter.dev_edit', {})
api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, { api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, {
group = group, group = group,
buffer = query_buf, buffer = query_buf,

View File

@ -2,7 +2,7 @@ local api = vim.api
local query = vim.treesitter.query local query = vim.treesitter.query
local Range = require('vim.treesitter._range') local Range = require('vim.treesitter._range')
local ns = api.nvim_create_namespace('treesitter/highlighter') local ns = api.nvim_create_namespace('nvim.treesitter.highlighter')
---@alias vim.treesitter.highlighter.Iter fun(end_line: integer|nil): integer, TSNode, vim.treesitter.query.TSMetadata, TSQueryMatch ---@alias vim.treesitter.highlighter.Iter fun(end_line: integer|nil): integer, TSNode, vim.treesitter.query.TSMetadata, TSQueryMatch

View File

@ -289,7 +289,7 @@ end, false)
api.nvim_create_autocmd('OptionSet', { api.nvim_create_autocmd('OptionSet', {
pattern = { 'runtimepath' }, pattern = { 'runtimepath' },
group = api.nvim_create_augroup('ts_query_cache_reset', { clear = true }), group = api.nvim_create_augroup('nvim.treesitter.query_cache_reset', { clear = true }),
callback = function() callback = function()
M.get:clear() M.get:clear()
end, end,

View File

@ -7,7 +7,7 @@ local M = {}
--- Note: {patterns} is assumed to be sorted by occurrence in the file. --- Note: {patterns} is assumed to be sorted by occurrence in the file.
--- @param patterns {start:string,stop:string,match:string}[] --- @param patterns {start:string,stop:string,match:string}[]
function M.highlight_groups(patterns) function M.highlight_groups(patterns)
local ns = vim.api.nvim_create_namespace('vimhelp') local ns = vim.api.nvim_create_namespace('nvim.vimhelp')
vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) vim.api.nvim_buf_clear_namespace(0, ns, 0, -1)
local save_cursor = vim.fn.getcurpos() local save_cursor = vim.fn.getcurpos()

View File

@ -1,4 +1,4 @@
local group = vim.api.nvim_create_augroup('editorconfig', {}) local group = vim.api.nvim_create_augroup('nvim.editorconfig', {})
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead', 'BufFilePost' }, { vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead', 'BufFilePost' }, {
group = group, group = group,
callback = function(args) callback = function(args)

View File

@ -24,7 +24,7 @@ end, {
end, end,
}) })
local augroup = vim.api.nvim_create_augroup('man', {}) local augroup = vim.api.nvim_create_augroup('nvim.man', {})
vim.api.nvim_create_autocmd('BufReadCmd', { vim.api.nvim_create_autocmd('BufReadCmd', {
group = augroup, group = augroup,

View File

@ -32,7 +32,7 @@ describe('default', function()
describe('popupmenu', function() describe('popupmenu', function()
it('can be disabled by user', function() it('can be disabled by user', function()
n.clear { n.clear {
args = { '+autocmd! nvim_popupmenu', '+aunmenu PopUp' }, args = { '+autocmd! nvim.popupmenu', '+aunmenu PopUp' },
} }
local screen = Screen.new(40, 8) local screen = Screen.new(40, 8)
n.insert([[ n.insert([[

View File

@ -173,7 +173,7 @@ describe('swapfile detection', function()
local screen2 = Screen.new(256, 40) local screen2 = Screen.new(256, 40)
screen2._default_attr_ids = nil screen2._default_attr_ids = nil
exec(init) exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
-- With shortmess+=F -- With shortmess+=F
command('set shortmess+=F') command('set shortmess+=F')
@ -277,7 +277,7 @@ describe('swapfile detection', function()
set_session(nvim1) set_session(nvim1)
screen:attach() screen:attach()
exec(init) exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
feed(':split Xfile1\n') feed(':split Xfile1\n')
-- The default SwapExists handler does _not_ skip this prompt. -- The default SwapExists handler does _not_ skip this prompt.
screen:expect({ screen:expect({
@ -296,7 +296,7 @@ describe('swapfile detection', function()
set_session(nvim2) set_session(nvim2)
screen:attach() screen:attach()
exec(init) exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
command('set more') command('set more')
command('au bufadd * let foo_w = wincol()') command('au bufadd * let foo_w = wincol()')
feed(':e Xfile1<CR>') feed(':e Xfile1<CR>')
@ -327,7 +327,7 @@ describe('swapfile detection', function()
exec(init) exec(init)
if not swapexists then if not swapexists then
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
end end
command('set nohidden') command('set nohidden')

View File

@ -144,7 +144,7 @@ describe('vim.hl.on_yank', function()
vim.api.nvim_buf_set_mark(0, ']', 1, 1, {}) vim.api.nvim_buf_set_mark(0, ']', 1, 1, {})
vim.hl.on_yank({ timeout = math.huge, on_macro = true, event = { operator = 'y' } }) vim.hl.on_yank({ timeout = math.huge, on_macro = true, event = { operator = 'y' } })
end) end)
local ns = api.nvim_create_namespace('hlyank') local ns = api.nvim_create_namespace('nvim.hlyank')
local win = api.nvim_get_current_win() local win = api.nvim_get_current_win()
eq({ win }, api.nvim__ns_get(ns).wins) eq({ win }, api.nvim__ns_get(ns).wins)
command('wincmd w') command('wincmd w')
@ -158,7 +158,7 @@ describe('vim.hl.on_yank', function()
vim.api.nvim_buf_set_mark(0, ']', 1, 1, {}) vim.api.nvim_buf_set_mark(0, ']', 1, 1, {})
vim.hl.on_yank({ timeout = math.huge, on_macro = true, event = { operator = 'y' } }) vim.hl.on_yank({ timeout = math.huge, on_macro = true, event = { operator = 'y' } })
end) end)
local ns = api.nvim_create_namespace('hlyank') local ns = api.nvim_create_namespace('nvim.hlyank')
eq(api.nvim_get_current_win(), api.nvim__ns_get(ns).wins[1]) eq(api.nvim_get_current_win(), api.nvim__ns_get(ns).wins[1])
command('wincmd w') command('wincmd w')
exec_lua(function() exec_lua(function()

View File

@ -351,7 +351,7 @@ describe(':terminal buffer', function()
end) end)
it('TermRequest synchronization #27572', function() it('TermRequest synchronization #27572', function()
command('autocmd! nvim_terminal TermRequest') command('autocmd! nvim.terminal TermRequest')
local term = exec_lua([[ local term = exec_lua([[
_G.input = {} _G.input = {}
local term = vim.api.nvim_open_term(0, { local term = vim.api.nvim_open_term(0, {

View File

@ -176,7 +176,7 @@ local function test_terminal_with_fake_shell(backslash)
end) end)
it('with no argument, acts like jobstart(…,{term=true})', function() it('with no argument, acts like jobstart(…,{term=true})', function()
command('autocmd! nvim_terminal TermClose') command('autocmd! nvim.terminal TermClose')
feed_command('terminal') feed_command('terminal')
screen:expect([[ screen:expect([[
^ready $ | ^ready $ |
@ -246,7 +246,7 @@ local function test_terminal_with_fake_shell(backslash)
end) end)
it('ignores writes if the backing stream closes', function() it('ignores writes if the backing stream closes', function()
command('autocmd! nvim_terminal TermClose') command('autocmd! nvim.terminal TermClose')
feed_command('terminal') feed_command('terminal')
feed('iiXXXXXXX') feed('iiXXXXXXX')
poke_eventloop() poke_eventloop()
@ -258,14 +258,14 @@ local function test_terminal_with_fake_shell(backslash)
end) end)
it('works with findfile()', function() it('works with findfile()', function()
command('autocmd! nvim_terminal TermClose') command('autocmd! nvim.terminal TermClose')
feed_command('terminal') feed_command('terminal')
eq('term://', string.match(eval('bufname("%")'), '^term://')) eq('term://', string.match(eval('bufname("%")'), '^term://'))
eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")')) eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")'))
end) end)
it('works with :find', function() it('works with :find', function()
command('autocmd! nvim_terminal TermClose') command('autocmd! nvim.terminal TermClose')
feed_command('terminal') feed_command('terminal')
screen:expect([[ screen:expect([[
^ready $ | ^ready $ |

View File

@ -644,7 +644,7 @@ describe('TUI', function()
aunmenu PopUp aunmenu PopUp
" Delete the default MenuPopup event handler. " Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
menu PopUp.foo :let g:menustr = 'foo'<CR> menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR> menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR> menu PopUp.baz :let g:menustr = 'baz'<CR>

View File

@ -1094,7 +1094,7 @@ describe('ext_multigrid', function()
end) end)
it('supports mouse', function() it('supports mouse', function()
command('autocmd! nvim_popupmenu') -- Delete the default MenuPopup event handler. command('autocmd! nvim.popupmenu') -- Delete the default MenuPopup event handler.
insert('some text\nto be clicked') insert('some text\nto be clicked')
screen:expect{grid=[[ screen:expect{grid=[[
## grid 1 ## grid 1

View File

@ -841,7 +841,7 @@ describe('ui/ext_popupmenu', function()
aunmenu PopUp aunmenu PopUp
" Delete the default MenuPopup event handler. " Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
menu PopUp.foo :let g:menustr = 'foo'<CR> menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR> menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR> menu PopUp.baz :let g:menustr = 'baz'<CR>
@ -4089,7 +4089,7 @@ describe('builtin popupmenu', function()
set mouse=a mousemodel=popup set mouse=a mousemodel=popup
" Delete the default MenuPopup event handler. " Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
aunmenu PopUp aunmenu PopUp
menu PopUp.foo :let g:menustr = 'foo'<CR> menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR> menu PopUp.bar :let g:menustr = 'bar'<CR>
@ -4946,7 +4946,7 @@ describe('builtin popupmenu', function()
it(':popup command', function() it(':popup command', function()
exec([[ exec([[
" Delete the default MenuPopup event handler. " Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
func ChangeMenu() func ChangeMenu()
aunmenu PopUp.&Paste aunmenu PopUp.&Paste
@ -5106,7 +5106,7 @@ describe('builtin popupmenu', function()
exec([[ exec([[
set mousemodel=popup_setpos set mousemodel=popup_setpos
" Delete the default MenuPopup event handler. " Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
aunmenu * aunmenu *
source $VIMRUNTIME/menu.vim source $VIMRUNTIME/menu.vim
call setline(1, join(range(20))) call setline(1, join(range(20)))

View File

@ -65,7 +65,7 @@ mapclear
mapclear! mapclear!
aunmenu * aunmenu *
tlunmenu * tlunmenu *
autocmd! nvim_popupmenu autocmd! nvim.popupmenu
" Undo the 'grepprg' and 'grepformat' setting in _defaults.lua. " Undo the 'grepprg' and 'grepformat' setting in _defaults.lua.
set grepprg& grepformat& set grepprg& grepformat&