Add vim.cmd as an alias for nvim_command (#11446)

This commit is contained in:
Ashkan Kiani
2019-12-01 05:28:53 -08:00
committed by GitHub
parent edca84cfc9
commit e6da21d128
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -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)