Skip to content

Commit ac24e72

Browse files
chore: minor cleanup
1 parent 3af7b3e commit ac24e72

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

lua/rest-nvim/config/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,12 @@ config = vim.tbl_deep_extend("force", {
219219
local ok, err = check.validate(config)
220220

221221
if not ok then
222-
vim.notify("Rest.nvim: " .. err, vim.log.levels.ERROR)
222+
vim.notify("[rest.nvim] " .. err, vim.log.levels.ERROR)
223223
end
224224

225225
if #config._debug_info.unrecognized_configs > 0 then
226226
vim.notify(
227-
"Unrecognized configs found in setup: " .. vim.inspect(config._debug_info.unrecognized_configs),
227+
"[rest.nvim] Unrecognized configs found in setup: " .. vim.inspect(config._debug_info.unrecognized_configs),
228228
vim.log.levels.WARN
229229
)
230230
end

lua/rest-nvim/cookie_jar.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function M.load_jar()
3838
if seps[1] ~= "" and not vim.startswith(seps[1], "#") then
3939
if #seps ~= 5 then
4040
local err_msg = "error while parsing cookies file at line:\n" .. line .. "\n"
41-
vim.notify(err_msg, vim.log.levels.ERROR)
41+
vim.notify("[rest.nvim] " .. err_msg, vim.log.levels.ERROR)
4242
logger.error(err_msg)
4343
return
4444
end
@@ -161,7 +161,7 @@ function M.save_jar()
161161
local file, openerr = io.open(config.cookies.path, "w")
162162
if not file then
163163
local err_msg = string.format("Failed to open rest.nvim cookies file: %s", openerr)
164-
vim.notify(err_msg, vim.log.levels.ERROR)
164+
vim.notify("[rest.nvim] " ..err_msg, vim.log.levels.ERROR)
165165
logger.error(err_msg)
166166
return
167167
end

lua/rest-nvim/dotenv.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function M.load_file(path, setter)
2222
end
2323
local ok = dotenv_parser.parse(path, setter)
2424
if not ok then
25-
vim.notify("failed to load file '" .. path .. "'", vim.log.levels.WARN)
25+
vim.notify("[rest.nvim] failed to load file '" .. path .. "'", vim.log.levels.WARN)
2626
end
2727
end
2828

@@ -35,17 +35,17 @@ function M.register_file(path, bufnr)
3535
-- TODO: validate file extension
3636
bufnr = bufnr or 0
3737
vim.b[bufnr]._rest_nvim_env_file = path
38-
vim.notify("Env file '" .. path .. "' has been registered")
38+
vim.notify("[rest.nvim] Env file '" .. path .. "' has been registered")
3939
end
4040

4141
---show registered dotenv file for current buffer
4242
---@param bufnr number? buffer identifier, default to current buffer
4343
function M.show_registered_file(bufnr)
4444
bufnr = bufnr or 0
4545
if not vim.b[bufnr]._rest_nvim_env_file then
46-
vim.notify("No env file is used in current buffer", vim.log.levels.WARN)
46+
vim.notify("[rest.nvim] No env file is used in current buffer", vim.log.levels.WARN)
4747
else
48-
vim.notify("Current env file in use: " .. vim.b._rest_nvim_env_file, vim.log.levels.INFO)
48+
vim.notify("[rest.nvim] Current env file in use: " .. vim.b._rest_nvim_env_file, vim.log.levels.INFO)
4949
end
5050
end
5151

lua/rest-nvim/health.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local function install_health()
1919
local found_luarocks_nvim = package.searchpath("luarocks", package.path)
2020

2121
if vim.fn.executable("luarocks") ~= 1 and not vim.g.rocks_nvim_loaded and not found_luarocks_nvim then
22-
vim.health.error("`Luarocks` is not installed in your system")
22+
vim.health.warn("`Luarocks` is not installed in your system", "Are you sure you installed all needed dependencies properly?")
2323
else
2424
vim.health.ok("Found `luarocks` installed in your system")
2525
end
@@ -66,7 +66,7 @@ local function configuration_health()
6666
end
6767

6868
-- Formatters
69-
local formatters = config.result.behavior.formatters
69+
local formatters = config.response.formatters
7070
for ft, formatter in pairs(formatters) do
7171
if type(formatter) == "string" then
7272
if vim.fn.executable(formatter) ~= 1 then
@@ -83,7 +83,7 @@ local function configuration_health()
8383
)
8484
end
8585
elseif type(formatter) == "function" then
86-
local _, fmt_meta = formatter()
86+
local _, fmt_meta = formatter("")
8787
if not fmt_meta.found then
8888
vim.health.warn(
8989
"Formatter for `"

lua/rest-nvim/request.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local function run_request(req)
4646
local ok, res = pcall(client.request(req).wait)
4747
if not ok then
4848
logger.error("request failed")
49-
vim.notify("request failed", vim.log.levels.ERROR)
49+
vim.notify("[rest.nvim] request failed", vim.log.levels.ERROR)
5050
return
5151
end
5252
---@cast res rest.Response
@@ -83,7 +83,7 @@ function M.run()
8383
local req_node = parser.get_cursor_request_node()
8484
if not req_node then
8585
logger.error("failed to find request at cursor position")
86-
vim.notify("failed to find request at cursor position", vim.log.levels.ERROR)
86+
vim.notify("[rest.nvim] failed to find request at cursor position", vim.log.levels.ERROR)
8787
return
8888
end
8989
local ctx = parser.create_context(0)
@@ -93,7 +93,7 @@ function M.run()
9393
local req = parser.parse(req_node, 0, ctx)
9494
if not req then
9595
logger.error("failed to parse request")
96-
vim.notify("failed to parse request", vim.log.levels.ERROR)
96+
vim.notify("[rest.nvim] failed to parse request", vim.log.levels.ERROR)
9797
return
9898
end
9999
local highlight = config.highlight
@@ -108,7 +108,7 @@ function M.run_by_name(name)
108108
local req_node = parser.get_request_node_by_name(name)
109109
if not req_node then
110110
logger.error("failed to find request by name: " .. name)
111-
vim.notify("failed to find request by name: " .. name, vim.log.levels.ERROR)
111+
vim.notify("[rest.nvim] failed to find request by name: " .. name, vim.log.levels.ERROR)
112112
return
113113
end
114114
local ctx = parser.create_context(0)
@@ -118,7 +118,7 @@ function M.run_by_name(name)
118118
local req = parser.parse(req_node, 0, ctx)
119119
if not req then
120120
logger.error("failed to parse request")
121-
vim.notify("failed to parse request", vim.log.levels.ERROR)
121+
vim.notify("[rest.nvim] failed to parse request", vim.log.levels.ERROR)
122122
return
123123
end
124124
local highlight = config.highlight
@@ -132,7 +132,7 @@ end
132132
function M.run_last()
133133
local req = rest_nvim_last_request
134134
if not req then
135-
vim.notify("No last request found", vim.log.levels.WARN)
135+
vim.notify("[rest.nvim] No last request found", vim.log.levels.WARN)
136136
return false
137137
end
138138
run_request(req)
@@ -145,13 +145,13 @@ function M.run_all()
145145
for _, req_node in ipairs(reqs) do
146146
local req = parser.parse(req_node, 0, ctx)
147147
if not req then
148-
vim.notify("Parsing request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
148+
vim.notify("[rest.nvim] Parsing request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
149149
return false
150150
end
151151
-- FIXME: wait for previous request ends
152152
local ok = run_request(req)
153153
if not ok then
154-
vim.notify("Running request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
154+
vim.notify("[rest.nvim] Running request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
155155
return
156156
end
157157
end

lua/rest-nvim/response.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function response.try_format_body(content_type, body)
4545
body = sc.stdout --[[@as string]]
4646
else
4747
logger.error("Error running formatter '" .. fmt .. "' on response body:\n" .. sc.stderr)
48-
vim.notify("Formatting response body failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
48+
vim.notify("[rest.nvim] Formatting response body failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
4949
end
5050
end
5151
elseif res_type ~= nil then

lua/rest-nvim/ui/help.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ local function get_or_create_buf()
3131
if not existing_buf then
3232
-- Create a new buffer
3333
local new_bufnr = vim.api.nvim_create_buf(false, true)
34-
local keybinds = config.result.keybinds
34+
local keybinds = config.ui.keybinds
3535
vim.api.nvim_buf_set_name(new_bufnr, tmp_name)
3636
vim.api.nvim_set_option_value("ft", "markdown", { buf = new_bufnr })
3737
vim.api.nvim_set_option_value("buftype", "nofile", { buf = new_bufnr })

plugin/rest-nvim.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ local rest_nvim_deps = {}
1616
-- Locate dependencies
1717
local dependencies = {
1818
["nvim-nio"] = "rest.nvim will not work asynchronously",
19-
["lua-curl"] = "Default HTTP client won't work",
2019
xml2lua = "rest.nvim will be completely unable to use XML bodies in your requests",
2120
mimetypes = "rest.nvim will be completely unable to recognize the file type of external body files",
21+
["fidget.nvim"] = "rest.nvim will be completely unable to show request progress messages",
2222
}
2323
for dep, err in pairs(dependencies) do
2424
local found_dep
2525
-- Both nvim-nio and lua-curl has a different Lua module name
2626
if dep == "nvim-nio" then
2727
found_dep = package.searchpath("nio", package.path)
28-
elseif dep == "lua-curl" then
29-
found_dep = package.searchpath("cURL.safe", package.path)
28+
elseif dep == "fidget.nvim" then
29+
found_dep = package.searchpath("fidget", package.path)
3030
else
3131
found_dep = package.searchpath(dep, package.path)
3232
end
@@ -38,8 +38,8 @@ for dep, err in pairs(dependencies) do
3838
-- Both nvim-nio and lua-curl has a different Lua module name
3939
if dep == "nvim-nio" then
4040
found_dep2 = pcall(require, "nio")
41-
elseif dep == "lua-curl" then
42-
found_dep2 = pcall(require, "cURL.safe")
41+
elseif dep == "fidget.nvim" then
42+
found_dep2 = pcall(require, "fidget")
4343
else
4444
found_dep2 = pcall(require, dep)
4545
end

0 commit comments

Comments
 (0)