diff options
author | NeOzay <colpaert.benoit@gmail.com> | 2024-07-12 20:42:02 +0200 |
---|---|---|
committer | NeOzay <colpaert.benoit@gmail.com> | 2024-07-12 20:42:02 +0200 |
commit | 41316bc8a5731a90c1dd5d9d05ee8a0b96cd6449 (patch) | |
tree | 0b9de38dc7a83346259bbda8a99a8b5ef930d50a /script | |
parent | 46707395df3255808682fdac883f7d86c1ac9a78 (diff) | |
download | lua-language-server-41316bc8a5731a90c1dd5d9d05ee8a0b96cd6449.zip |
added lua regular expression support for Lua.doc.<scope>Name
Diffstat (limited to 'script')
-rw-r--r-- | script/config/template.lua | 5 | ||||
-rw-r--r-- | script/vm/visible.lua | 22 |
2 files changed, 21 insertions, 6 deletions
diff --git a/script/config/template.lua b/script/config/template.lua index e74a9f9c..7b044d7a 100644 --- a/script/config/template.lua +++ b/script/config/template.lua @@ -402,7 +402,10 @@ local template = { ['Lua.doc.privateName'] = Type.Array(Type.String), ['Lua.doc.protectedName'] = Type.Array(Type.String), ['Lua.doc.packageName'] = Type.Array(Type.String), - + ['Lua.doc.regengine'] = Type.String >> 'glob' << { + 'glob', + 'lua', + }, -- VSCode ["Lua.addonManager.enable"] = Type.Boolean >> true, ['files.associations'] = Type.Hash(Type.String, Type.String), diff --git a/script/vm/visible.lua b/script/vm/visible.lua index 0f486d6b..11b6c8d6 100644 --- a/script/vm/visible.lua +++ b/script/vm/visible.lua @@ -42,21 +42,33 @@ local function getVisibleType(source) if type(fieldName) == 'string' then local uri = guide.getUri(source) + local regengine = config.get(uri, 'Lua.doc.regengine') + local function match(patterns) + if regengine == "glob" then + return glob.glob(patterns)(fieldName) + else + for i = 1, #patterns do + if string.find(fieldName, patterns[i]) then + return true + end + end + end + end local privateNames = config.get(uri, 'Lua.doc.privateName') - if #privateNames > 0 and glob.glob(privateNames)(fieldName) then + if #privateNames > 0 and match(privateNames) then source._visibleType = 'private' return 'private' end - + local protectedNames = config.get(uri, 'Lua.doc.protectedName') - if #protectedNames > 0 and glob.glob(protectedNames)(fieldName) then + if #protectedNames > 0 and match(protectedNames) then source._visibleType = 'protected' return 'protected' end - + local packageNames = config.get(uri, 'Lua.doc.packageName') - if #packageNames > 0 and glob.glob(packageNames)(fieldName) then + if #packageNames > 0 and match(packageNames) then source._visibleType = 'package' return 'package' end |