summaryrefslogtreecommitdiff
path: root/script/core/diagnostics
diff options
context:
space:
mode:
authoruhziel <uhziel@gmail.com>2020-12-10 15:04:47 +0800
committerGitHub <noreply@github.com>2020-12-10 15:04:47 +0800
commit64e62cfefbeff094b2d168ed5d0d31d48736c89b (patch)
treeb16966b896e9bc77ec82b3b3038968193396d19b /script/core/diagnostics
parentc06cda864aff2e9c17a5e71c8b48c98b8a0c7e4e (diff)
parente818b4bd52458bed6842555ce7f9b8d874968b07 (diff)
downloadlua-language-server-64e62cfefbeff094b2d168ed5d0d31d48736c89b.zip
Merge branch 'master' into diagnostic-undefined-field
Diffstat (limited to 'script/core/diagnostics')
-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 75a43d0f..5d647993 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(key) == 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,