Skip to content

Commit

Permalink
Separated the function using ~ operator of Lua 5.3 into other file.…
Browse files Browse the repository at this point in the history
… So using Lua 5.1 or 5.2 is OK.
  • Loading branch information
katono committed Nov 19, 2021
1 parent 0999f5b commit 830767e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 8 additions & 0 deletions autoload/rogue/lua53.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local g = Rogue -- alias

-- This file is loaded only when Lua 5.3 or later,
-- because using new features.

function g.lua53_bxor(x, y)
return x ~ y
end
24 changes: 12 additions & 12 deletions autoload/rogue/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ else
g.loadstring = loadstring
end

function g.get_vim_variable(var)
if vim then
if vim.eval("exists('" .. var .. "')") ~= 0 then
return vim.eval(var)
end
end
return ''
end

g.bxor = nil

local bit_exists, bit = pcall(require, "bit")
if bit_exists then
g.bxor = bit.bxor
elseif _VERSION >= 'Lua 5.3' then
g.bxor = function(x, y)
return x ~ y
end
local file_dir = g.get_vim_variable("s:FILE_DIR")
dofile(file_dir .. "lua53.lua")
g.bxor = g.lua53_bxor
elseif _VERSION >= 'Lua 5.2' then
g.bxor = bit32.bxor
else
Expand All @@ -37,15 +46,6 @@ else
end
end

function g.get_vim_variable(var)
if vim then
if vim.eval("exists('" .. var .. "')") ~= 0 then
return vim.eval(var)
end
end
return ''
end

function g.set_vim_variable(var, value)
if vim then
if type(value) == 'number' then
Expand Down

0 comments on commit 830767e

Please sign in to comment.