Return nil instead of NIL for vim.env (#11486)

This commit is contained in:
Ashkan Kiani 2019-12-01 05:04:57 -08:00 committed by GitHub
parent a17ccb0d24
commit edca84cfc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -315,7 +315,14 @@ do
vim.g = make_meta_accessor(nil_wrap(a.nvim_get_var), a.nvim_set_var, a.nvim_del_var)
vim.v = make_meta_accessor(nil_wrap(a.nvim_get_vvar), a.nvim_set_vvar)
vim.o = make_meta_accessor(a.nvim_get_option, a.nvim_set_option)
vim.env = make_meta_accessor(vim.fn.getenv, vim.fn.setenv)
local function getenv(k)
local v = vim.fn.getenv(k)
if v == vim.NIL then
return nil
end
return v
end
vim.env = make_meta_accessor(getenv, vim.fn.setenv)
-- TODO(ashkan) if/when these are available from an API, generate them
-- instead of hardcoding.
local window_options = {

View File

@ -569,7 +569,7 @@ describe('lua stdlib', function()
vim.fn.setenv("A", 123)
]]
eq('123', funcs.luaeval "vim.env.A")
eq(NIL, funcs.luaeval "vim.env.B")
eq(true, funcs.luaeval "vim.env.B == nil")
end)
it('vim.v', function()