From ebed523ba714d28c004f54e3f8d4695781115e1a Mon Sep 17 00:00:00 2001 From: Max <4990534+unix-system@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:28:51 +0000 Subject: [PATCH] Fix roblox-lsp-plugin.lua to support Windows --- src/roblox-lsp-plugin.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/roblox-lsp-plugin.lua b/src/roblox-lsp-plugin.lua index 309cf60..4121cc5 100644 --- a/src/roblox-lsp-plugin.lua +++ b/src/roblox-lsp-plugin.lua @@ -5,7 +5,12 @@ local json = require("json") local log = require("log") local function _IsoLibrary(FilePath) - local MetaFilePath = string.gsub(FilePath, "/([^/]*)%.[^/]*$", "/%1.meta.json") + local RawPath = string.gsub(FilePath, "([^/]*)%.[^/]*$", "%1.meta.json") + + local MetaFilePath = fs.path(RawPath) + if tostring(MetaFilePath):find(tostring(fs.current_path())) then + MetaFilePath = fs.relative(MetaFilePath, fs.current_path()) + end if not fs.exists(fs.current_path() / MetaFilePath) then return false end local DecodeSuccess, Meta = pcall(json.decode, util.loadFile(MetaFilePath)) @@ -26,7 +31,6 @@ end local function _GetMatchingModule(MatchName) for FullName, FilePath in next, rojo.SourceMap do local Success, Match = pcall(string.find, FullName, "%." .. MatchName .. "$") - if (Success and Match) and _IsoLibrary(FilePath) then return string.gsub(string.gsub(FullName, "%.([^%.]-[@]%d+%.%d+%.%d+-?%w*)", "[\"%1\"]"), "%.(%a-[ ][^%.]*)", "[\"%1\"]") end @@ -37,6 +41,7 @@ function OnSetText(uri, text) local diffs = {} for start, content, finish in text:gmatch('()Overture:LoadLibrary(%b())()') do + local NamedImports = {} local Name @@ -47,7 +52,6 @@ function OnSetText(uri, text) table.insert(NamedImports, Match:sub(2, -2)) end end - local FullName = (Name and _GetMatchingModule(Name)) or nil if FullName then @@ -92,4 +96,4 @@ function OnCompletion(uri, text, offset) end return items -end \ No newline at end of file +end