diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-08 16:40:00 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-08 16:40:00 +0800 |
commit | f4e4cc0114adba8d199f9f81298a7c15c9576d5c (patch) | |
tree | 2d60c501909fa1b3ff458318c843f25b1ecad132 | |
parent | 97d0a4dda6556944c3dd47f2ebd78100a313ae44 (diff) | |
download | lua-language-server-f4e4cc0114adba8d199f9f81298a7c15c9576d5c.zip |
#409 cocos
-rw-r--r-- | meta/3rd/Cocos4.0/config.lua | 8 | ||||
-rw-r--r-- | meta/3rd/OpenResty/config.lua | 2 | ||||
-rw-r--r-- | script/library.lua | 28 |
3 files changed, 33 insertions, 5 deletions
diff --git a/meta/3rd/Cocos4.0/config.lua b/meta/3rd/Cocos4.0/config.lua new file mode 100644 index 00000000..99de2da2 --- /dev/null +++ b/meta/3rd/Cocos4.0/config.lua @@ -0,0 +1,8 @@ +files = {'cocos'} +configs = { + { + key = 'Lua.runtime.version', + action = 'set', + value = 'LuaJIT', + }, +} diff --git a/meta/3rd/OpenResty/config.lua b/meta/3rd/OpenResty/config.lua index 8bee2d10..07331691 100644 --- a/meta/3rd/OpenResty/config.lua +++ b/meta/3rd/OpenResty/config.lua @@ -1,6 +1,4 @@ --- list or matched file names files = {'resty/redis%.lua'} --- lsit of settings to be changed configs = { { key = 'Lua.runtime.version', diff --git a/script/library.lua b/script/library.lua index 3d52baea..516a4dd3 100644 --- a/script/library.lua +++ b/script/library.lua @@ -259,6 +259,11 @@ local function loadSingle3rdConfig(libraryDir) cfg[k] = v end + if cfg.words then + for i, word in ipairs(cfg.words) do + cfg.words[i] = '()' .. word .. '()' + end + end if cfg.files then for i, filename in ipairs(cfg.files) do if plat.OS == 'Windows' then @@ -266,7 +271,7 @@ local function loadSingle3rdConfig(libraryDir) else filename = filename:gsub('\\', '/') end - cfg.files[i] = filename + cfg.files[i] = '()' .. filename .. '()' end end @@ -336,6 +341,23 @@ local function askFor3rd(cfg) end end +---@param a string +---@param b string +---@return boolean +local function wholeMatch(a, b) + local pos1, pos2 = a:match(b) + if not pos1 then + return false + end + local left = a:sub(pos1 - 1, pos1-1) + local right = a:sub(pos2, pos2) + if left:match '[%w_]' + or right:match '[%w_]' then + return false + end + return true +end + local function check3rdByWords(text, configs) if hasAsked then return @@ -345,7 +367,7 @@ local function check3rdByWords(text, configs) if cfg.words then for _, word in ipairs(cfg.words) do await.delay() - if text:match(word) then + if wholeMatch(text, word) then askFor3rd(cfg) return end @@ -372,7 +394,7 @@ local function check3rdByFileName(uri, configs) if cfg.files then for _, filename in ipairs(cfg.files) do await.delay() - if path:match(filename) then + if wholeMatch(path, filename) then askFor3rd(cfg) return end |