diff --git a/package.json b/package.json index fc44f57..91c9a3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "overture-vscode", - "version": "1.5.1", + "version": "1.5.2-alpha.1", "repository": { "type": "git", "url": "https://github.com/devSparkle/overture-vscode.git" diff --git a/src/luau-lsp-plugin.luau b/src/luau-lsp-plugin.luau index 6087d39..1a61ffd 100644 --- a/src/luau-lsp-plugin.luau +++ b/src/luau-lsp-plugin.luau @@ -16,6 +16,8 @@ local function GetLibraries(RelativeTo: string, _Libraries, _Uri: Uri?) local Libraries = (_Libraries or {}) local Uri = (_Uri or lsp.workspace.getRootUri()) + RelativeTo = string.gsub(RelativeTo, "[/\\]", "/") + for _, Entry in lsp.fs.listDirectory(Uri) do local Name = string.sub(Entry:toString(), #Uri:toString() + 2) local Library = string.match(Name, "(.*)%.meta%.json$") @@ -23,6 +25,12 @@ local function GetLibraries(RelativeTo: string, _Libraries, _Uri: Uri?) if Library and IsLibrary(Entry) then local FixedPath = Entry.path + FixedPath = string.gsub(FixedPath, "[/\\]", "/") + + if string.find(FixedPath, "^/?%a:") then + FixedPath = string.sub(FixedPath, 2) + end + for _, Directory in ipairs(string.split(RelativeTo, "/")) do if string.find(FixedPath, `{Directory}/`, 1, true) == 1 then FixedPath = string.sub(FixedPath, #Directory + 2) @@ -48,10 +56,10 @@ return { local Changes = {} local Line, LineStart = 1, 1 - local Libraries = GetLibraries((string.gsub(Context.filePath, "/[^/]-$", ""))) + local Libraries = GetLibraries((string.gsub(Context.filePath, "[/\\][^/\\]-$", ""))) for Index = 1, #Source do - if Source[Index] == "\n" then + if string.sub(Source, Index, Index) == "\n" then Line += 1 LineStart = (Index + 1) end @@ -70,7 +78,7 @@ return { Success, LoadData = pcall(lsp.json.deserialize, LoadData) if not Success then - lsp.client.sendLogMessage("info", `Failed to process match: "{Match}"`) + lsp.client.sendLogMessage("warning", `Failed to process match: "{Match}" in {Context.filePath}.`) continue end @@ -78,6 +86,14 @@ return { local Column = (Index - LineStart + 1) local Library, NamedImports = unpack(LoadData) + lsp.client.sendLogMessage("log", `Setup require path {Libraries[Library]} in {Context.filePath}:{Line}:{Column} for {Library}`) + + if not Libraries[Library] then + lsp.client.sendLogMessage("warning", `No path for "{Library}" in {Context.filePath}.`) + + continue + end + if NamedImports then local NewText = ""