2022-05-09 03:44:39 +00:00
|
|
|
--- @class libmodal.globals
|
2023-03-12 23:26:38 +00:00
|
|
|
--- @field ESC_NR integer the key-code for the escape character.
|
|
|
|
--- @field VIM_FALSE integer the value of Vimscript's `v:false`
|
|
|
|
--- @field VIM_TRUE integer the value of Vimscript's `v:true`
|
2023-02-20 19:16:35 +00:00
|
|
|
local globals =
|
2022-05-09 03:44:39 +00:00
|
|
|
{
|
2023-03-12 23:26:38 +00:00
|
|
|
ESC_NR = vim.api.nvim_replace_termcodes('<Esc>', true, true, true):byte(),
|
2023-02-20 19:16:35 +00:00
|
|
|
VIM_FALSE = 0,
|
|
|
|
VIM_TRUE = 1,
|
2020-05-26 03:25:16 +00:00
|
|
|
}
|
2023-02-20 19:16:35 +00:00
|
|
|
|
|
|
|
--- assert some value is either `false` or `v:false`.
|
2023-03-12 23:26:38 +00:00
|
|
|
--- @param val boolean|integer
|
2023-02-20 19:16:35 +00:00
|
|
|
--- @return boolean
|
|
|
|
function globals.is_false(val)
|
|
|
|
return val == false or val == globals.VIM_FALSE
|
|
|
|
end
|
|
|
|
|
|
|
|
--- assert some value is either `true` or `v:true`.
|
2023-03-12 23:26:38 +00:00
|
|
|
--- @param val boolean|integer
|
2023-02-20 19:16:35 +00:00
|
|
|
--- @return boolean
|
|
|
|
function globals.is_true(val)
|
|
|
|
return val == true or val == globals.VIM_TRUE
|
|
|
|
end
|
|
|
|
|
|
|
|
return globals
|