Skip to content

Instantly share code, notes, and snippets.

@bigbes
Created November 17, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigbes/a9dec3ed1f6ed30ad4bb30315a2dd49c to your computer and use it in GitHub Desktop.
Save bigbes/a9dec3ed1f6ed30ad4bb30315a2dd49c to your computer and use it in GitHub Desktop.
local lcstd = require('luacheck.standards')
local empty = {}
local debug_defs = lcstd.def_fields(
"traceback", "setlocal", "getupvalue", "setupvalue", "upvalueid",
"getlocal", "getregistry", "getinfo", "sethook", "setmetatable",
"upvaluejoin", "gethook", "debug", "getmetatable", "setfenv",
"getfenv"
)
local string_defs = lcstd.def_fields(
"byte", "char", "dump", "find", "format", "gmatch", "gsub", "len", "lower",
"match", "rep", "reverse", "sub", "upper", "startswith", "endswith",
"split", "ljust", "rjust", "center", "startswith", "endswith", "hex",
"strip", "lstrip", "rstrip"
)
local table_defs = lcstd.def_fields(
"maxn", "copy", "new", "clear", "move", "foreach", "sort", "remove",
"foreachi", "deepcopy", "getn", "concat", "insert"
)
local coroutine_defs = lcstd.def_fields(
"wrap", "yield", "resume", "status", "isyieldable", "running", "create"
)
local io_file_defs = lcstd.def_fields(
"__gc", "__index", "__tostring", "write", "read", "close", "flush", "seek",
"lines", "setvbuf"
)
--[[
local io_defs = {
"input", "stdin", "tmpfile", "read", "output", "open", "close", "write",
"popen", "flush", "type", "lines", "stdout", "stderr"
}
]]--
local io_defs = {}
io_defs.fields = {
close = empty,
flush = empty,
input = empty,
lines = empty,
open = empty,
output = empty,
popen = empty,
read = empty,
stderr = io_file_defs,
stdin = io_file_defs,
stdout = io_file_defs,
tmpfile = empty,
type = empty,
write = empty,
}
local jit_defs = lcstd.def_fields(
"arch", "version", "version_num", "status", "on", "os", "off", "flush",
"attach", "opt"
)
local math_defs = lcstd.def_fields(
"ceil", "tan", "log10", "randomseed", "cos", "sinh", "random", "huge",
"pi", "max", "atan2", "ldexp", "floor", "sqrt", "deg", "atan", "fmod",
"acos", "pow", "abs", "min", "sin", "frexp", "log", "tanh", "exp",
"modf", "cosh", "asin", "rad"
)
local os_defs = lcstd.def_fields(
"execute", "rename", "environ", "setenv", "setlocale", "getenv",
"difftime", "remove", "date", "exit", "time", "clock", "tmpname"
)
--[[
local package_defs = lcstd.def_fields(
"preload", "search", "path", "loaded", "seeall", "loadlib", "cpath",
"searchpath", "loaders", "config"
)
]]--
local box_defs = lcstd.def_fields(
"schema", "tuple", "error", "sequence", "commit", "once", "space",
"backup", "info", "session", "cfg", "snapshot", "slab", "atomic",
"rollback_to_savepoint", "savepoint", "begin", "rollback",
"runtime", "index", "stat"
)
local package_defs = {}
package_defs.fields = {
config = string_defs,
cpath = { fields = string_defs.fields, read_only = false },
loaded = { other_fields = true, read_only = false },
loadlib = empty,
path = { fields = string_defs.fields, read_only = false },
preload = { other_fields = true, read_only = false },
loaders = { other_fields = true, read_only = false },
searchpath = empty,
seeall = empty,
search = empty,
}
local bit_defs = lcstd.def_fields(
"rol", "rshift", "ror", "bswap", "bxor", "bor", "arshift", "bnot", "tobit",
"lshift", "tohex", "band"
)
local globals = {
-- module
coroutine = coroutine_defs,
debug = debug_defs,
io = io_defs,
jit = jit_defs,
math = math_defs,
os = os_defs,
package = package_defs,
string = string_defs,
table = table_defs,
bit = bit_defs,
-- variables
_G = { other_fields = true, read_only = false },
_VERSION = string_defs,
arg = { other_fields = true },
-- functions
assert = empty, collectgarbage = empty, dofile = empty,
error = empty, getfenv = empty, getmetatable = empty,
ipairs = empty, help = empty, load = empty,
loadfile = empty, loadstring = empty, module = empty,
next = empty, pairs = empty, pcall = empty,
print = empty, rawget = empty, rawset = empty,
require = empty, select = empty, setfenv = empty,
setmetatable = empty, tonumber = empty, tostring = empty,
type = empty, unpack = empty, xpcall = empty,
gcinfo = empty, newproxy = empty,
-- tarantool
box = box_defs,
_TARANTOOL = string_defs,
dostring = empty,
tutorial = empty,
tonumber64 = empty,
}
std = { read_globals = globals }
-- vim: syntax=lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment