mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Add vim.cmd as an alias for nvim_command (#11446)
This commit is contained in:
@@ -277,6 +277,10 @@ setmetatable(vim, {
|
||||
__index = __index
|
||||
})
|
||||
|
||||
-- An easier alias for commands.
|
||||
vim.cmd = vim.api.nvim_command
|
||||
|
||||
-- These are the vim.env/v/g/o/bo/wo variable magic accessors.
|
||||
do
|
||||
local a = vim.api
|
||||
local validate = vim.validate
|
||||
|
@@ -618,4 +618,13 @@ describe('lua stdlib', function()
|
||||
matches("^Error executing lua: .*: Expected lua string$",
|
||||
pcall_err(exec_lua, 'return vim.wo[0][0].list'))
|
||||
end)
|
||||
|
||||
it('vim.cmd', function()
|
||||
exec_lua [[
|
||||
vim.cmd "autocmd BufNew * ++once lua BUF = vim.fn.expand('<abuf>')"
|
||||
vim.cmd "new"
|
||||
]]
|
||||
eq('2', funcs.luaeval "BUF")
|
||||
eq(2, funcs.luaeval "#vim.api.nvim_list_bufs()")
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user