Skip to content

Commit 8369aa1

Browse files
style!: format to indent-size 4
1 parent 7604c36 commit 8369aa1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3157
-3047
lines changed

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ end_of_line = lf
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.lua]
12-
indent_size = 2
13-
1411
[*.{scm,nix}]
1512
indent_size = 2
1613

doc/rest-nvim.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ rest.nvim commands *rest-nvim.commands*
6060
copying command to clipboard, directly insert curl
6161
command as a comment.
6262

63-
NOTE: All `:Rest` commands opening new window support |command-modifiers|.
64-
For example, you can run `:hor Rest open` to open result pane in horizontal
65-
split
63+
NOTE: All `:Rest` commands opening new window support |command-modifiers|.
64+
For example, you can run `:hor Rest open` to open result pane in horizontal
65+
split or run `:tab Rest logs` to open logs file in a new tab.
6666

6767

6868
==============================================================================

ftdetect/http.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
vim.filetype.add({
2-
extension = {
3-
http = "http",
4-
},
2+
extension = {
3+
http = "http",
4+
},
55
})

lua/lualine/components/rest.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ local lualine_require = require("lualine_require")
22
local M = lualine_require.require("lualine.component"):extend()
33

44
local default_options = {
5-
fg = "#428890",
6-
icon = "",
5+
fg = "#428890",
6+
icon = "",
77
}
88

99
function M:init(options)
10-
M.super.init(self, options)
11-
self.options = vim.tbl_deep_extend("keep", self.options or {}, default_options)
12-
self.icon = self.options.icon
10+
M.super.init(self, options)
11+
self.options = vim.tbl_deep_extend("keep", self.options or {}, default_options)
12+
self.icon = self.options.icon
1313

14-
self.highlight_color = self:create_hl({ fg = self.options.fg }, "Rest")
14+
self.highlight_color = self:create_hl({ fg = self.options.fg }, "Rest")
1515
end
1616

1717
function M:apply_icon()
18-
local default_highlight = self:get_default_hl()
19-
self.status = self:format_hl(self.highlight_color) .. self.icon .. " " .. default_highlight .. self.status
18+
local default_highlight = self:get_default_hl()
19+
self.status = self:format_hl(self.highlight_color) .. self.icon .. " " .. default_highlight .. self.status
2020
end
2121

2222
function M.update_status()
23-
local current_filetype = vim.bo.filetype
24-
if current_filetype == "http" then
25-
return vim.b._rest_nvim_env_file
26-
end
27-
return ""
23+
local current_filetype = vim.bo.filetype
24+
if current_filetype == "http" then
25+
return vim.b._rest_nvim_env_file
26+
end
27+
return ""
2828
end
2929

3030
return M

lua/rest-nvim/api.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ api.namespace = vim.api.nvim_create_namespace("rest-nvim")
3131
---@param cb string|fun(args: table) Autocommand lua callback, runs a Vimscript command instead if it is a `string`
3232
---@param description string Autocommand description
3333
function api.register_rest_autocmd(events, cb, description)
34-
---@diagnostic disable-next-line: invisible
35-
autocmds.register_autocmd(events, cb, description)
34+
---@diagnostic disable-next-line: invisible
35+
autocmds.register_autocmd(events, cb, description)
3636
end
3737

3838
---Register a new `:Rest` subcommand
3939
---@param name string The name of the subcommand to register
4040
---@param cmd RestCmd
4141
function api.register_rest_subcommand(name, cmd)
42-
---@diagnostic disable-next-line: invisible
43-
commands.register_subcommand(name, cmd)
42+
---@diagnostic disable-next-line: invisible
43+
commands.register_subcommand(name, cmd)
4444
end
4545

4646
function api.register_rest_client(c)
47-
client.register_client(c)
47+
client.register_client(c)
4848
end
4949

5050
return api

lua/rest-nvim/autocmds.lua

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
---@mod rest-nvim.autocmds rest.nvim autocommands
2-
---
3-
---@mod rest-nvim.autocmds rest.nvim autocommands
1+
---@mod rest-nvim.events rest.nvim user events
42
---
53
---@brief [[
64
---
@@ -48,51 +46,51 @@ local autocmds = {}
4846
---Set up Rest autocommands group
4947
---@package
5048
function autocmds.setup()
51-
vim.api.nvim_create_augroup("Rest", { clear = true })
49+
vim.api.nvim_create_augroup("Rest", { clear = true })
5250

53-
vim.api.nvim_create_autocmd("User", {
54-
pattern = "RestRequestPre",
55-
callback = function (_ev)
56-
local config = require("rest-nvim.config")
57-
local utils = require("rest-nvim.utils")
58-
local req = _G.rest_request
59-
local hooks = config.request.hooks
60-
if hooks.encode_url then
61-
req.url = utils.escape(req.url, true)
62-
end
63-
if hooks.user_agent ~= "" then
64-
local header_empty = not req.headers["user-agent"] or #req.headers["user-agent"] < 1
65-
if header_empty then
66-
local user_agent = type(hooks.user_agent) == "function" and hooks.user_agent() or hooks.user_agent
67-
---@cast user_agent string
68-
req.headers["user-agent"] = { user_agent }
69-
end
70-
end
71-
if hooks.set_content_type then
72-
local header_empty = not req.headers["content-type"] or #req.headers["content-type"] < 1
73-
if header_empty and req.body then
74-
if req.body.__TYPE == "json" then
75-
req.headers["content-type"] = { "application/json" }
76-
elseif req.body.__TYPE == "xml" then
77-
req.headers["content-type"] = { "application/xml" }
78-
-- TODO: auto-set content-type header for external body
79-
end
80-
end
81-
end
82-
end
83-
})
84-
vim.api.nvim_create_autocmd("User", {
85-
pattern = "RestResponsePre",
86-
callback = function (_ev)
87-
local config = require("rest-nvim.config")
88-
local utils = require("rest-nvim.utils")
89-
local req = _G.rest_request
90-
local _res = _G.rest_response
91-
if config.response.hooks.decode_url then
92-
req.url = utils.url_decode(req.url)
93-
end
94-
end
95-
})
51+
vim.api.nvim_create_autocmd("User", {
52+
pattern = "RestRequestPre",
53+
callback = function(_ev)
54+
local config = require("rest-nvim.config")
55+
local utils = require("rest-nvim.utils")
56+
local req = _G.rest_request
57+
local hooks = config.request.hooks
58+
if hooks.encode_url then
59+
req.url = utils.escape(req.url, true)
60+
end
61+
if hooks.user_agent ~= "" then
62+
local header_empty = not req.headers["user-agent"] or #req.headers["user-agent"] < 1
63+
if header_empty then
64+
local user_agent = type(hooks.user_agent) == "function" and hooks.user_agent() or hooks.user_agent
65+
---@cast user_agent string
66+
req.headers["user-agent"] = { user_agent }
67+
end
68+
end
69+
if hooks.set_content_type then
70+
local header_empty = not req.headers["content-type"] or #req.headers["content-type"] < 1
71+
if header_empty and req.body then
72+
if req.body.__TYPE == "json" then
73+
req.headers["content-type"] = { "application/json" }
74+
elseif req.body.__TYPE == "xml" then
75+
req.headers["content-type"] = { "application/xml" }
76+
-- TODO: auto-set content-type header for external body
77+
end
78+
end
79+
end
80+
end,
81+
})
82+
vim.api.nvim_create_autocmd("User", {
83+
pattern = "RestResponsePre",
84+
callback = function(_ev)
85+
local config = require("rest-nvim.config")
86+
local utils = require("rest-nvim.utils")
87+
local req = _G.rest_request
88+
local _res = _G.rest_response
89+
if config.response.hooks.decode_url then
90+
req.url = utils.url_decode(req.url)
91+
end
92+
end,
93+
})
9694
end
9795

9896
---Register a new autocommand in the `Rest` augroup
@@ -104,28 +102,28 @@ end
104102
---@param description string Autocommand description
105103
---@package
106104
function autocmds.register_autocmd(events, cb, description)
107-
vim.validate({
108-
events = { events, "table" },
109-
cb = { cb, { "function", "string" } },
110-
description = { description, "string" },
111-
})
105+
vim.validate({
106+
events = { events, "table" },
107+
cb = { cb, { "function", "string" } },
108+
description = { description, "string" },
109+
})
112110

113-
local autocmd_opts = {
114-
group = vim.api.nvim_create_augroup("Rest", { clear = false }),
115-
desc = description,
116-
}
111+
local autocmd_opts = {
112+
group = vim.api.nvim_create_augroup("Rest", { clear = false }),
113+
desc = description,
114+
}
117115

118-
if type(cb) == "function" then
119-
autocmd_opts = vim.tbl_deep_extend("force", autocmd_opts, {
120-
callback = cb,
121-
})
122-
elseif type(cb) == "string" then
123-
autocmd_opts = vim.tbl_deep_extend("force", autocmd_opts, {
124-
command = cb,
125-
})
126-
end
116+
if type(cb) == "function" then
117+
autocmd_opts = vim.tbl_deep_extend("force", autocmd_opts, {
118+
callback = cb,
119+
})
120+
elseif type(cb) == "string" then
121+
autocmd_opts = vim.tbl_deep_extend("force", autocmd_opts, {
122+
command = cb,
123+
})
124+
end
127125

128-
vim.api.nvim_create_autocmd(events, autocmd_opts)
126+
vim.api.nvim_create_autocmd(events, autocmd_opts)
129127
end
130128

131129
return autocmds

0 commit comments

Comments
 (0)