Skip to content

Commit 7d1058f

Browse files
fix: use title field instead of manual prefix
1 parent 6ab4cb0 commit 7d1058f

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

lua/rest-nvim/commands.lua

+13-13
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ local rest_command_tbl = {
8686
run = {
8787
impl = function(args, _)
8888
if vim.bo.filetype ~= "http" or vim.b.__rest_no_http_file then
89-
vim.notify("`:Rest run` can be only called from http file", vim.log.levels.ERROR)
89+
vim.notify("`:Rest run` can be only called from http file", vim.log.levels.ERROR, { title = "rest.nvim" })
9090
return
9191
end
9292
if #args > 1 then
93-
vim.notify("Running multiple request isn't supported yet", vim.log.levels.WARN)
93+
vim.notify("Running multiple request isn't supported yet", vim.log.levels.WARN, { title = "rest.nvim" })
9494
return
9595
elseif #args == 1 then
9696
request().run_by_name(args[1])
@@ -145,14 +145,14 @@ local rest_command_tbl = {
145145
return
146146
elseif args[1] == "set" then
147147
if #args < 2 then
148-
vim.notify("Not enough arguments were passed to the 'env' command: 2 argument were expected, 1 was passed", vim.log.levels.ERROR)
148+
vim.notify("Not enough arguments were passed to the 'env' command: 2 argument were expected, 1 was passed", vim.log.levels.ERROR, { title = "rest.nvim" })
149149
return
150150
end
151151
dotenv().register_file(args[2])
152152
elseif args[1] == "select" then
153153
dotenv().select_file()
154154
else
155-
vim.notify("Invalid action '" .. args[1] .. "' provided to 'env' command", vim.log.levels.ERROR)
155+
vim.notify("Invalid action '" .. args[1] .. "' provided to 'env' command", vim.log.levels.ERROR, { title = "rest.nvim" })
156156
end
157157
end,
158158
---@return string[]
@@ -191,47 +191,47 @@ local rest_command_tbl = {
191191
req_node = parser().get_cursor_request_node()
192192
if not req_node then
193193
logger().error("failed to find request at cursor position")
194-
vim.notify("[rest.nvim] failed to find request at cursor position", vim.log.levels.ERROR)
194+
vim.notify("failed to find request at cursor position", vim.log.levels.ERROR, { title = "rest.nvim" })
195195
return
196196
end
197197
else
198198
req_node = parser().get_request_node_by_name(args[2])
199199
if not req_node then
200200
logger().error("failed to find request with name:" .. args[2])
201-
vim.notify("[rest.nvim] failed to find request with name:" .. args[2], vim.log.levels.ERROR)
201+
vim.notify("failed to find request with name:" .. args[2], vim.log.levels.ERROR, { title = "rest.nvim" })
202202
return
203203
end
204204
end
205205
local req = parser().parse(req_node, 0)
206206
if not req then
207207
logger().error("failed to parse request")
208-
vim.notify("[rest.nvim] failed to parse request. See `:Rest logs` for more info", vim.log.levels.ERROR)
208+
vim.notify("failed to parse request. See `:Rest logs` for more info", vim.log.levels.ERROR, { title = "rest.nvim" })
209209
return
210210
end
211211
local curl_command = require("rest-nvim.client.curl.cli").builder.build_command(req)
212212
vim.fn.setreg("+", curl_command)
213-
vim.notify("[rest.nvim] Copied curl command to clipboard", vim.log.levels.INFO)
213+
vim.notify("Copied curl command to clipboard", vim.log.levels.INFO, { title = "rest.nvim" })
214214
elseif args[1] == "comment" then
215215
local req_node
216216
if not args[2] then
217217
req_node = parser().get_cursor_request_node()
218218
if not req_node then
219219
logger().error("failed to find request at cursor position")
220-
vim.notify("[rest.nvim] failed to find request at cursor position", vim.log.levels.ERROR)
220+
vim.notify("failed to find request at cursor position", vim.log.levels.ERROR, { title = "rest.nvim" })
221221
return
222222
end
223223
else
224224
req_node = parser().get_request_node_by_name(args[2])
225225
if not req_node then
226226
logger().error("failed to find request with name:" .. args[2])
227-
vim.notify("[rest.nvim] failed to find request with name:" .. args[2], vim.log.levels.ERROR)
227+
vim.notify("failed to find request with name:" .. args[2], vim.log.levels.ERROR, { title = "rest.nvim" })
228228
return
229229
end
230230
end
231231
local req = parser().parse(req_node, 0)
232232
if not req then
233233
logger().error("failed to parse request")
234-
vim.notify("[rest.nvim] failed to parse request. See `:Rest logs` for more info", vim.log.levels.ERROR)
234+
vim.notify("failed to parse request. See `:Rest logs` for more info", vim.log.levels.ERROR, { title = "rest.nvim" })
235235
return
236236
end
237237
local curl_command = require("rest-nvim.client.curl.cli").builder.build_command(req)
@@ -241,7 +241,7 @@ local rest_command_tbl = {
241241
-- elseif args[1] == "to-http" then
242242
-- -- TODO: convert comment with curl to http request and insert it below
243243
else
244-
vim.notify("Invalid action '" .. args[1] .. "' provided to 'curl' command", vim.log.levels.ERROR)
244+
vim.notify("Invalid action '" .. args[1] .. "' provided to 'curl' command", vim.log.levels.ERROR, { title = "rest.nvim" })
245245
end
246246
end,
247247
complete = function (_args)
@@ -262,7 +262,7 @@ local function rest(opts)
262262

263263
if not command then
264264
logger().error("Unknown command: " .. cmd)
265-
vim.notify("Unknown command: " .. cmd)
265+
vim.notify("Unknown command: " .. cmd, vim.log.levels.WARN, { title = "rest.nvim" })
266266
return
267267
end
268268

lua/rest-nvim/config/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ config = vim.tbl_deep_extend("force", {
193193
local ok, err = check.validate(config)
194194

195195
if not ok then
196-
vim.notify("[rest.nvim] " .. err, vim.log.levels.ERROR)
196+
vim.notify(err, vim.log.levels.ERROR, { title = "rest.nvim" })
197197
end
198198

199199
if #config._debug_info.unrecognized_configs > 0 then

lua/rest-nvim/cookie_jar.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function M.load_jar()
2929
local file, openerr = io.open(config.cookies.path, "r")
3030
if not file then
3131
local err_msg = string.format("Failed to open rest.nvim cookies file: %s", openerr)
32-
vim.notify(err_msg, vim.log.levels.ERROR)
32+
vim.notify(err_msg, vim.log.levels.ERROR, { title = "rest.nvim" })
3333
logger.error(err_msg)
3434
return
3535
end
@@ -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("[rest.nvim] " .. err_msg, vim.log.levels.ERROR)
41+
vim.notify(err_msg, vim.log.levels.ERROR, { title = "rest.nvim" })
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("[rest.nvim] " ..err_msg, vim.log.levels.ERROR)
164+
vim.notify(err_msg, vim.log.levels.ERROR, { title = "rest.nvim" })
165165
logger.error(err_msg)
166166
return
167167
end

lua/rest-nvim/dotenv.lua

+4-4
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("[rest.nvim] failed to load file '" .. path .. "'", vim.log.levels.WARN)
25+
vim.notify("failed to load file '" .. path .. "'", vim.log.levels.WARN, { title = "rest.nvim" })
2626
end
2727
end
2828

@@ -43,17 +43,17 @@ function M.register_file(path, bufnr)
4343
})
4444
bufnr = bufnr or 0
4545
vim.b[bufnr]._rest_nvim_env_file = path
46-
vim.notify("[rest.nvim] Env file '" .. path .. "' has been registered")
46+
vim.notify("Env file '" .. path .. "' has been registered", vim.log.levels.INFO, { title = "rest.nvim" })
4747
end
4848

4949
---show registered dotenv file for current buffer
5050
---@param bufnr number? buffer identifier, default to current buffer
5151
function M.show_registered_file(bufnr)
5252
bufnr = bufnr or 0
5353
if not vim.b[bufnr]._rest_nvim_env_file then
54-
vim.notify("[rest.nvim] No env file is used in current buffer", vim.log.levels.WARN)
54+
vim.notify("No env file is used in current buffer", vim.log.levels.WARN, { title = "rest.nvim" })
5555
else
56-
vim.notify("[rest.nvim] Current env file in use: " .. vim.b._rest_nvim_env_file, vim.log.levels.INFO)
56+
vim.notify("Current env file in use: " .. vim.b._rest_nvim_env_file, vim.log.levels.INFO, { title = "rest.nvim" })
5757
end
5858
end
5959

lua/rest-nvim/logger.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ local function open_logfile()
5050
logfile, openerr = io.open(logger.get_logfile(), "w+")
5151
if not logfile then
5252
local err_msg = string.format("Failed to open rest.nvim log file: %s", openerr)
53-
vim.notify(err_msg, vim.log.levels.ERROR)
53+
vim.notify(err_msg, vim.log.levels.ERROR, { title = "rest.nvim" })
5454
return false
5555
end
5656

5757
local log_info = vim.uv.fs_stat(logger.get_logfile())
5858
if log_info and log_info.size > LARGE then
5959
local warn_msg =
6060
string.format("rest.nvim log is large (%d MB): %s", log_info.size / (1000 * 1000), logger.get_logfile())
61-
vim.notify(warn_msg, vim.log.levels.WARN)
61+
vim.notify(warn_msg, vim.log.levels.WARN, { title = "rest.nvim" })
6262
end
6363

6464
-- Start message for logging

lua/rest-nvim/parser/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ function parser.parse(node, source, ctx)
384384
body = parser.parse_body(content_type, body_node, source, ctx)
385385
if not body then
386386
logger.error("parsing body failed")
387-
vim.notify("[rest.nvim] parsing request body failed. See `:Rest logs` for more info.", vim.log.levels.ERROR)
387+
vim.notify("parsing request body failed. See `:Rest logs` for more info.", vim.log.levels.ERROR, { title = "rest.nvim" })
388388
return nil
389389
end
390390
end

lua/rest-nvim/request.lua

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ local function run_request(req)
3434
local client = clients.get_available_clients(req)[1]
3535
if not client then
3636
logger.error("can't find registered client available for request:\n" .. vim.inspect(req))
37-
vim.notify("[rest.nvim] Can't find registered client available for request", vim.log.levels.ERROR)
37+
vim.notify("Can't find registered client available for request", vim.log.levels.ERROR, { title = "rest.nvim" })
3838
end
3939
rest_nvim_last_request = req
4040

@@ -50,7 +50,7 @@ local function run_request(req)
5050
local ok, res = pcall(client.request(req).wait)
5151
if not ok then
5252
logger.error("request failed")
53-
vim.notify("[rest.nvim] request failed", vim.log.levels.ERROR)
53+
vim.notify("request failed", vim.log.levels.ERROR, { title = "rest.nvim" })
5454
return
5555
end
5656
---@cast res rest.Response
@@ -87,7 +87,7 @@ function M.run()
8787
local req_node = parser.get_cursor_request_node()
8888
if not req_node then
8989
logger.error("failed to find request at cursor position")
90-
vim.notify("[rest.nvim] failed to find request at cursor position", vim.log.levels.ERROR)
90+
vim.notify("failed to find request at cursor position", vim.log.levels.ERROR, { title = "rest.nvim" })
9191
return
9292
end
9393
local ctx = parser.create_context(0)
@@ -97,7 +97,7 @@ function M.run()
9797
local req = parser.parse(req_node, 0, ctx)
9898
if not req then
9999
logger.error("failed to parse request")
100-
vim.notify("[rest.nvim] failed to parse request", vim.log.levels.ERROR)
100+
vim.notify("failed to parse request", vim.log.levels.ERROR, { title = "rest.nvim" })
101101
return
102102
end
103103
local highlight = config.highlight
@@ -112,7 +112,7 @@ function M.run_by_name(name)
112112
local req_node = parser.get_request_node_by_name(name)
113113
if not req_node then
114114
logger.error("failed to find request by name: " .. name)
115-
vim.notify("[rest.nvim] failed to find request by name: " .. name, vim.log.levels.ERROR)
115+
vim.notify("failed to find request by name: " .. name, vim.log.levels.ERROR, { title = "rest.nvim" })
116116
return
117117
end
118118
local ctx = parser.create_context(0)
@@ -122,7 +122,7 @@ function M.run_by_name(name)
122122
local req = parser.parse(req_node, 0, ctx)
123123
if not req then
124124
logger.error("failed to parse request")
125-
vim.notify("[rest.nvim] failed to parse request", vim.log.levels.ERROR)
125+
vim.notify("failed to parse request", vim.log.levels.ERROR, { title = "rest.nvim" })
126126
return
127127
end
128128
local highlight = config.highlight
@@ -136,7 +136,7 @@ end
136136
function M.run_last()
137137
local req = rest_nvim_last_request
138138
if not req then
139-
vim.notify("[rest.nvim] No last request found", vim.log.levels.WARN)
139+
vim.notify("No last request found", vim.log.levels.WARN, { title = "rest.nvim" })
140140
return false
141141
end
142142
run_request(req)
@@ -149,13 +149,13 @@ function M.run_all()
149149
for _, req_node in ipairs(reqs) do
150150
local req = parser.parse(req_node, 0, ctx)
151151
if not req then
152-
vim.notify("[rest.nvim] Parsing request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
152+
vim.notify("Parsing request failed. See `:Rest logs` for more info", vim.log.levels.ERROR, { title = "rest.nvim" })
153153
return false
154154
end
155155
-- FIXME: wait for previous request ends
156156
local ok = run_request(req)
157157
if not ok then
158-
vim.notify("[rest.nvim] Running request failed. See `:Rest logs` for more info", vim.log.levels.ERROR)
158+
vim.notify("Running request failed. See `:Rest logs` for more info", vim.log.levels.ERROR, { title = "rest.nvim" })
159159
return
160160
end
161161
end

lua/rest-nvim/ui/panes.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function RestUIPaneGroup:cycle(direction)
2424
return
2525
end
2626
end
27-
vim.notify("`cycle()` can only be called inside the pane buffer", vim.log.levels.WARN)
27+
vim.notify("`cycle()` can only be called inside the pane buffer", vim.log.levels.WARN, { title = "rest.nvim" })
2828
end
2929
function RestUIPaneGroup:render()
3030
for _, pane in ipairs(self.panes) do

plugin/rest-nvim.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ for dep, err in pairs(dependencies) do
4949
error = err,
5050
}
5151
if not found_dep2 then
52-
vim.notify("[rest.nvim] WARN: Dependency '" .. dep .. "' was not found. " .. err, vim.log.levels.ERROR)
52+
vim.notify("WARN: Dependency '" .. dep .. "' was not found. " .. err, vim.log.levels.ERROR, { title = "rest.nvim" })
5353
else
5454
rest_nvim_deps[dep] = {
5555
found = true,

0 commit comments

Comments
 (0)