summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-12-07 16:33:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-12-07 16:33:30 +0800
commitc7d8504c2b76b7d68359ca10409a69967086223e (patch)
treebefc8f9a6afd27293e3ffa5d1456756b68b8b23b /script/core
parent65b56557d79637135ce59ff6ceda44c35d8518e4 (diff)
downloadlua-language-server-c7d8504c2b76b7d68359ca10409a69967086223e.zip
add tip of `Lua.runtime.special`
Diffstat (limited to 'script/core')
-rw-r--r--script/core/diagnostics/undefined-global.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index eb225169..2efd75f8 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -5,6 +5,13 @@ local config = require 'config'
local guide = require 'parser.guide'
local define = require 'proto.define'
+local requireLike = {
+ ['include'] = true,
+ ['import'] = true,
+ ['require'] = true,
+ ['load'] = true,
+}
+
return function (uri, callback)
local ast = files.getAst(uri)
if not ast then
@@ -20,8 +27,14 @@ return function (uri, callback)
if config.config.diagnostics.globals[key] then
return
end
+ if config.config.runtime.special[key] then
+ return
+ end
if #vm.getGlobalSets(guide.getKeyName(src)) == 0 then
local message = lang.script('DIAG_UNDEF_GLOBAL', key)
+ if requireLike[key:lower()] then
+ message = ('%s(%s)'):format(message, lang.script('DIAG_REQUIRE_LIKE', key))
+ end
callback {
start = src.start,
finish = src.finish,