Skip to content

Commit

Permalink
fix(lint): stylua (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe authored Aug 12, 2024
1 parent 1949b75 commit 6905f47
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lua/kulala/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ M.defaults = {
["text/html"] = {
ft = "html",
formatter = FS.command_exists("xmllint") and { "xmllint", "--format", "--html", "-" } or nil,
pathresolver = nil,
pathresolver = nil,
},
},
-- default icons
Expand Down Expand Up @@ -53,7 +53,7 @@ M.defaults = {
"}",
},
-- enable winbar
winbar = false;
winbar = false,
}

M.default_contenttype = {
Expand Down
4 changes: 2 additions & 2 deletions lua/kulala/inlay/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local NS = vim.api.nvim_create_namespace('jest.nvim')
local NS = vim.api.nvim_create_namespace("jest.nvim")
local CONFIG = require("kulala.config")

local M = {}
Expand Down Expand Up @@ -32,7 +32,7 @@ M.show = function(t, linenr)
M.clear()
local bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_extmark(bufnr, NS, linenr - 1, 0, {
virt_text = { { t } }
virt_text = { { t } },
})
end

Expand Down
4 changes: 2 additions & 2 deletions lua/kulala/jumps/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ M.jump_next = function()
local _, reqs = PARSER.get_document()
local next = PARSER.get_next_request(reqs)
if next then
vim.api.nvim_win_set_cursor(0, {next.start_line + 1, 0})
vim.api.nvim_win_set_cursor(0, { next.start_line + 1, 0 })
end
end

Expand All @@ -16,7 +16,7 @@ M.jump_prev = function()
local _, reqs = PARSER.get_document()
local prev = PARSER.get_previous_request(reqs)
if prev then
vim.api.nvim_win_set_cursor(0, {prev.start_line + 1, 0})
vim.api.nvim_win_set_cursor(0, { prev.start_line + 1, 0 })
end
end

Expand Down
4 changes: 2 additions & 2 deletions lua/kulala/parser/request_variables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ local function get_body_value_from_path(name, method, subpath)
if subpath == "*" then
return base_table[method].body
end

if not base_table[method].headers then
return nil
end
Expand All @@ -66,7 +66,7 @@ local function get_body_value_from_path(name, method, subpath)
return contenttype.pathresolver(base_table[method].body, subpath)
elseif type(contenttype.pathresolver) == "table" then
local cmd = {}
for k,v in pairs(contenttype.pathresolver) do
for k, v in pairs(contenttype.pathresolver) do
if type(v) == "string" then
v = string.gsub(v, "{{path}}", subpath)
end
Expand Down
4 changes: 2 additions & 2 deletions lua/kulala/ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ M.show_body = function()
local body = FS.read_file(GLOBALS.BODY_FILE)
local contenttype = INT_PROCESSING.get_config_contenttype()
if contenttype.formatter then
body = FORMATTER.format(contenttype.formatter, body)
body = FORMATTER.format(contenttype.formatter, body)
end
set_buffer_contents(body, contenttype.ft)
else
Expand Down Expand Up @@ -207,7 +207,7 @@ M.show_headers_body = function()
local body = FS.read_file(GLOBALS.BODY_FILE)
local contenttype = INT_PROCESSING.get_config_contenttype()
if contenttype.formatter then
body = FORMATTER.format(contenttype.formatter, body)
body = FORMATTER.format(contenttype.formatter, body)
end
set_buffer_contents(h .. "\n" .. body, contenttype.ft)
else
Expand Down
24 changes: 16 additions & 8 deletions lua/kulala/ui/winbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@ local CONFIG = require("kulala.config")
local M = {}

---set winbar highlight
M.winbar_sethl = function ()
M.winbar_sethl = function()
vim.api.nvim_set_hl(0, "KulalaTab", { link = "TabLine" })
vim.api.nvim_set_hl(0, "KulalaTabSel", { link = "TabLineSel"})
vim.api.nvim_set_hl(0, "KulalaTabSel", { link = "TabLineSel" })
end

---set local key mapping
---@param buf integer|nil Buffer
M.winbar_set_key_mapping = function (buf)
M.winbar_set_key_mapping = function(buf)
if buf then
vim.keymap.set('n', 'B', function ()
vim.keymap.set("n", "B", function()
require("kulala.ui").toggle_headers()
end, { silent = true, buffer = buf })
vim.keymap.set('n', 'H', function ()
vim.keymap.set("n", "H", function()
require("kulala.ui").toggle_headers()
end, { silent = true, buffer = buf })
end
end

---@param win_id integer|nil Window id
---@param view string Body or headers
M.toggle_winbar_tab = function (win_id, view)
M.toggle_winbar_tab = function(win_id, view)
if win_id then
if view == "body" then
vim.api.nvim_set_option_value("winbar", "%#KulalaTabSel# Body (B) %* %#KulalaTab# Headers (H) %* ", { win = win_id })
vim.api.nvim_set_option_value(
"winbar",
"%#KulalaTabSel# Body (B) %* %#KulalaTab# Headers (H) %* ",
{ win = win_id }
)
elseif view == "headers" then
vim.api.nvim_set_option_value("winbar", "%#KulalaTab# Body (B) %* %#KulalaTabSel# Headers (H) %* ", { win = win_id })
vim.api.nvim_set_option_value(
"winbar",
"%#KulalaTab# Body (B) %* %#KulalaTabSel# Headers (H) %* ",
{ win = win_id }
)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/kulala/utils/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ M.remove_newline = function(str)
end

M.url_encode = function(str)
if (str) then
if str then
str = string.gsub(str, "\n", "\r\n")
str = string.gsub(str, "([^%w._~-])", function(c)
return string.format("%%%02X", string.byte(c))
Expand All @@ -30,7 +30,7 @@ M.url_encode = function(str)
end

M.url_decode = function(str)
if (str) then
if str then
str = string.gsub(str, "%%(%x%x)", function(h)
return string.char(tonumber(h, 16))
end)
Expand Down
9 changes: 6 additions & 3 deletions lua/kulala/utils/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ M.slice = function(tbl, first, last)
-- Adjust for out-of-bound indices
first = first or 1
last = last or #tbl
if first < 1 then first = 1 end
if last > #tbl then last = #tbl end
if first < 1 then
first = 1
end
if last > #tbl then
last = #tbl
end

-- Extract the slice
for i = first, last do
Expand All @@ -17,5 +21,4 @@ M.slice = function(tbl, first, last)
return sliced
end


return M

0 comments on commit 6905f47

Please sign in to comment.