mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 18:41:48 +00:00
backport test: lint naming conventions (#39124)
test: lint naming conventions Problem: Naming conventions are not automatically checked. Solution: Add a check to the doc generator. Eventually we should extract this somehow, but that will require refactoring the doc generator... Note: this also checks non-public functions, basically anything that passes through `gen_eval_files.lua` and `gen_vimdoc.lua`. And that's a good thing.
This commit is contained in:
@@ -342,23 +342,23 @@ local VIM_CMD_ARG_MAX = 20
|
||||
--- ```
|
||||
---
|
||||
---@diagnostic disable-next-line: undefined-doc-param
|
||||
---@param command string|table Command(s) to execute.
|
||||
---@param cmd string|table Command(s) to execute.
|
||||
--- - The string form supports multiline Vimscript (alias to |nvim_exec2()|, behaves
|
||||
--- like |:source|).
|
||||
--- - The table form executes a single command (alias to |nvim_cmd()|).
|
||||
---@see |ex-cmd-index|
|
||||
vim.cmd = setmetatable({}, {
|
||||
__call = function(_, command)
|
||||
if type(command) == 'table' then
|
||||
return vim.api.nvim_cmd(command, {})
|
||||
__call = function(_, cmd)
|
||||
if type(cmd) == 'table' then
|
||||
return vim.api.nvim_cmd(cmd, {})
|
||||
else
|
||||
vim.api.nvim_exec2(command, {})
|
||||
vim.api.nvim_exec2(cmd, {})
|
||||
return ''
|
||||
end
|
||||
end,
|
||||
--- @param t table<string,function>
|
||||
__index = function(t, command)
|
||||
t[command] = function(...)
|
||||
__index = function(t, cmd)
|
||||
t[cmd] = function(...)
|
||||
local opts --- @type vim.api.keyset.cmd
|
||||
if select('#', ...) == 1 and type(select(1, ...)) == 'table' then
|
||||
--- @type vim.api.keyset.cmd
|
||||
@@ -379,10 +379,10 @@ vim.cmd = setmetatable({}, {
|
||||
else
|
||||
opts = { args = { ... } }
|
||||
end
|
||||
opts.cmd = command
|
||||
opts.cmd = cmd
|
||||
return vim.api.nvim_cmd(opts, {})
|
||||
end
|
||||
return t[command]
|
||||
return t[cmd]
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
16
runtime/lua/vim/_meta/api.gen.lua
generated
16
runtime/lua/vim/_meta/api.gen.lua
generated
@@ -302,9 +302,9 @@ function vim.api.nvim_buf_clear_namespace(buf, ns_id, line_start, line_end) end
|
||||
--- @see vim.api.nvim_create_user_command
|
||||
--- @param buf integer Buffer id, or 0 for current buffer.
|
||||
--- @param name string
|
||||
--- @param command any
|
||||
--- @param cmd any
|
||||
--- @param opts vim.api.keyset.user_command
|
||||
function vim.api.nvim_buf_create_user_command(buf, name, command, opts) end
|
||||
function vim.api.nvim_buf_create_user_command(buf, name, cmd, opts) end
|
||||
|
||||
--- Removes an `extmark`.
|
||||
---
|
||||
@@ -914,8 +914,8 @@ function vim.api.nvim_cmd(cmd, opts) end
|
||||
--- Prefer `nvim_cmd()` or `nvim_exec2()` instead. To modify an Ex command in a structured way
|
||||
--- before executing it, modify the result of `nvim_parse_cmd()` then pass it to `nvim_cmd()`.
|
||||
---
|
||||
--- @param command string Ex command string
|
||||
function vim.api.nvim_command(command) end
|
||||
--- @param cmd string Ex command string
|
||||
function vim.api.nvim_command(cmd) end
|
||||
|
||||
--- @deprecated
|
||||
--- @see vim.api.nvim_exec2
|
||||
@@ -1031,7 +1031,7 @@ function vim.api.nvim_create_namespace(name) end
|
||||
--- ```
|
||||
---
|
||||
--- @param name string Name of the new user command. Must begin with an uppercase letter.
|
||||
--- @param command string|fun(args: vim.api.keyset.create_user_command.command_args) Replacement command to execute when this user command is executed. When called
|
||||
--- @param cmd string|fun(args: vim.api.keyset.create_user_command.command_args) Replacement command to execute when this user command is executed. When called
|
||||
--- from Lua, the command can also be a Lua function. The function is called with a
|
||||
--- single table argument that contains the following keys:
|
||||
--- - name: (string) Command name
|
||||
@@ -1055,7 +1055,7 @@ function vim.api.nvim_create_namespace(name) end
|
||||
--- - `preview` (function) Preview handler for 'inccommand' `:command-preview`
|
||||
--- - Set boolean `command-attributes` such as `:command-bang` or `:command-bar` to
|
||||
--- true (but not `:command-buffer`, use `nvim_buf_create_user_command()` instead).
|
||||
function vim.api.nvim_create_user_command(name, command, opts) end
|
||||
function vim.api.nvim_create_user_command(name, cmd, opts) end
|
||||
|
||||
--- Delete an autocommand group by id.
|
||||
---
|
||||
@@ -1971,7 +1971,7 @@ function vim.api.nvim_parse_cmd(str, opts) end
|
||||
--- - "E" to parse like for `"<C-r>="`.
|
||||
--- - empty string for ":call".
|
||||
--- - "lm" to parse for ":let".
|
||||
--- @param highlight boolean If true, return value will also include "highlight"
|
||||
--- @param hl boolean If true, return value will also include "highlight"
|
||||
--- key containing array of 4-tuples (arrays) (Integer,
|
||||
--- Integer, Integer, String), where first three numbers
|
||||
--- define the highlighted region and represent line,
|
||||
@@ -2027,7 +2027,7 @@ function vim.api.nvim_parse_cmd(str, opts) end
|
||||
--- - "fvalue": Float, floating-point value for "Float" nodes.
|
||||
--- - "svalue": String, value for "SingleQuotedString" and
|
||||
--- "DoubleQuotedString" nodes.
|
||||
function vim.api.nvim_parse_expression(expr, flags, highlight) end
|
||||
function vim.api.nvim_parse_expression(expr, flags, hl) end
|
||||
|
||||
--- Pastes at cursor (in any mode), and sets "redo" so dot (`.`) will repeat the input. UIs call
|
||||
--- this to implement "paste", but it's also intended for use by scripts to input large,
|
||||
|
||||
@@ -1071,17 +1071,17 @@ end
|
||||
--- Execute a lsp command, either via client command function (if available)
|
||||
--- or via workspace/executeCommand (if supported by the server)
|
||||
---
|
||||
--- @param command lsp.Command
|
||||
--- @param cmd lsp.Command
|
||||
--- @param context? {bufnr?: integer}
|
||||
--- @param handler? lsp.Handler only called if a server command
|
||||
function Client:exec_cmd(command, context, handler)
|
||||
function Client:exec_cmd(cmd, context, handler)
|
||||
context = vim.deepcopy(context or {}, true) --[[@as lsp.HandlerContext]]
|
||||
context.bufnr = vim._resolve_bufnr(context.bufnr)
|
||||
context.client_id = self.id
|
||||
local cmdname = command.command
|
||||
local cmdname = cmd.command
|
||||
local fn = self.commands[cmdname] or lsp.commands[cmdname]
|
||||
if fn then
|
||||
fn(command, context)
|
||||
fn(cmd, context)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1099,12 +1099,12 @@ function Client:exec_cmd(command, context, handler)
|
||||
)
|
||||
return
|
||||
end
|
||||
-- Not using command directly to exclude extra properties,
|
||||
-- Not using cmd directly to exclude extra properties,
|
||||
-- see https://github.com/python-lsp/python-lsp-server/issues/146
|
||||
--- @type lsp.ExecuteCommandParams
|
||||
local params = {
|
||||
command = cmdname,
|
||||
arguments = command.arguments,
|
||||
arguments = cmd.arguments,
|
||||
}
|
||||
self:request('workspace/executeCommand', params, handler, context.bufnr)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user