Skip to content

Commit

Permalink
refactor: remove compressed option in curl
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py committed Aug 31, 2024
1 parent 861e220 commit 3881e5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lua/luau-lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ function M.aliases(paths)
return
end

local ok, contents = pcall(json.decode, luaurc:read "a")
local ok, content = pcall(json.decode, luaurc:read "a")
if not ok then
log.error("Failed to read '.luaurc': %s", contents)
log.error("Failed to read '.luaurc': %s", content)
return
end

local aliases = vim.empty_dict()
for alias, value in pairs(contents.aliases or {}) do
for alias, value in pairs(content.aliases or {}) do
aliases["@" .. alias] = value
end
return aliases
Expand Down
2 changes: 0 additions & 2 deletions lua/luau-lsp/roblox/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ local download_api = async.wrap(function(callback)
output = global_types_file(),
callback = on_success,
on_error = on_error,
compressed = false,
})

curl.get(API_DOCS_URL, {
output = api_docs_file(),
callback = on_success,
on_error = on_error,
compressed = false,
})
end, 1)

Expand Down
9 changes: 3 additions & 6 deletions lua/luau-lsp/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ local fetch_fflags = async.wrap(function(callback)
callback {}
end

curl.get {
url = CURRENT_FFLAGS_URL,
accept = "application/json",
curl.get(CURRENT_FFLAGS_URL, {
callback = function(result)
local ok, content = pcall(vim.json.decode, result.body)
if ok then
Expand All @@ -28,10 +26,9 @@ local fetch_fflags = async.wrap(function(callback)
end
end,
on_error = function(result)
on_error(result.stderr)
on_error(table.concat(result.stderr, "\n"))
end,
compressed = false,
}
})
end, 1)

---@async
Expand Down
12 changes: 6 additions & 6 deletions spec/json_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local json = require "luau-lsp.json"

describe("json5 decoder", function()
it("should decode with comments", function()
local ok, contents = pcall(
local ok, content = pcall(
json.decode,
[[
// .luaurc
Expand All @@ -18,11 +18,11 @@ describe("json5 decoder", function()
assert.same({
foo = "foo",
bar = "bar",
}, contents)
}, content)
end)

it("should decode with trailing commas", function()
local ok, contents = pcall(
local ok, content = pcall(
json.decode,
[[
{
Expand All @@ -36,11 +36,11 @@ describe("json5 decoder", function()
assert.same({
foo = "foo",
bar = "bar",
}, contents)
}, content)
end)

it("should decode nesting fields", function()
local ok, contents = pcall(
local ok, content = pcall(
json.decode,
[[
{
Expand All @@ -57,6 +57,6 @@ describe("json5 decoder", function()
foo = {
bar = "baz",
},
}, contents)
}, content)
end)
end)

0 comments on commit 3881e5f

Please sign in to comment.