chore: run stylua [generated] (#460)

* chore: add stylua

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: running stylua

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-09-03 04:19:54 -04:00
committed by GitHub
parent 4ad913435c
commit e8c71d931e
28 changed files with 608 additions and 1181 deletions

View File

@@ -1,7 +1,7 @@
local api = vim.api
local Config = require("avante.config")
local bit = require("bit")
local Config = require "avante.config"
local bit = require "bit"
local rshift, band = bit.rshift, bit.band
local Highlights = {
@@ -29,8 +29,8 @@ local H = {}
local M = {}
M.input_ns = api.nvim_create_namespace("avante_input")
M.hint_ns = api.nvim_create_namespace("avante_hint")
M.input_ns = api.nvim_create_namespace "avante_input"
M.hint_ns = api.nvim_create_namespace "avante_hint"
local function has_set_colors(hl_group)
local hl = api.nvim_get_hl(0, { name = hl_group })
@@ -46,7 +46,7 @@ M.setup = function()
.iter(Highlights)
:filter(function(k, _)
-- return all uppercase key with underscore or fully uppercase key
return k:match("^%u+_") or k:match("^%u+$")
return k:match "^%u+_" or k:match "^%u+$"
end)
:each(function(_, hl)
if not has_set_colors(hl.name) then
@@ -114,7 +114,7 @@ setmetatable(M, {
---@param rgb_24bit number 24-bit RGB value
---@return {r: integer, g: integer, b: integer} with keys 'r', 'g', 'b' in [0,255]
H.decode_24bit_rgb = function(rgb_24bit)
vim.validate({ rgb_24bit = { rgb_24bit, "n", true } })
vim.validate { rgb_24bit = { rgb_24bit, "n", true } }
local r = band(rshift(rgb_24bit, 16), 255)
local g = band(rshift(rgb_24bit, 8), 255)
local b = band(rgb_24bit, 255)
@@ -123,9 +123,7 @@ end
---@param attr integer
---@param percent integer
H.alter = function(attr, percent)
return math.floor(attr * (100 + percent) / 100)
end
H.alter = function(attr, percent) return math.floor(attr * (100 + percent) / 100) end
---@source https://stackoverflow.com/q/5560248
---@see https://stackoverflow.com/a/37797380
@@ -135,9 +133,7 @@ end
---@return string
H.shade_color = function(color, percent)
local rgb = H.decode_24bit_rgb(color)
if not rgb.r or not rgb.g or not rgb.b then
return "NONE"
end
if not rgb.r or not rgb.g or not rgb.b then return "NONE" end
local r, g, b = H.alter(rgb.r, percent), H.alter(rgb.g, percent), H.alter(rgb.b, percent)
r, g, b = math.min(r, 255), math.min(g, 255), math.min(b, 255)
return string.format("#%02x%02x%02x", r, g, b)