Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lua/flutter-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ local function validate_prefs(prefs)
end
)
end
vim.validate({
outline = { prefs.outline, "table", true },
dev_log = { prefs.dev_log, "table", true },
closing_tags = { prefs.closing_tags, "table", true },
})
vim.validate("outline", prefs.outline, "table", true)
vim.validate("dev_log", prefs.dev_log, "table", true)
vim.validate("closing_tags", prefs.closing_tags, "table", true)
end

---Create a proportional split using a percentage specified as a float
Expand Down
38 changes: 17 additions & 21 deletions lua/flutter-tools/lsp/color/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,16 @@ end
---@return RGB rgb_table
--- FIXME: this currently does not support transparent backgrounds. Need a replacement for bg_rgb
function M.rgba_to_rgb(rgba, bg_rgb)
validate({
rgba = { rgba, "t", true },
bg_rgb = { bg_rgb, "t", false },
r = { rgba.r, "n", true },
g = { rgba.g, "n", true },
b = { rgba.b, "n", true },
a = { rgba.a, "n", true },
})
validate("rgba", rgba, "t", true)
validate("bg_rgb", bg_rgb, "t", false)
validate("r", rgba.r, "n", true)
validate("g", rgba.g, "n", true)
validate("b", rgba.b, "n", true)
validate("a", rgba.a, "n", true)

validate({
bg_r = { bg_rgb.r, "n", true },
bg_g = { bg_rgb.g, "n", true },
bg_b = { bg_rgb.b, "n", true },
})
validate("bg_r", bg_rgb.r, "n", true)
validate("bg_g", bg_rgb.g, "n", true)
validate("bg_b", bg_rgb.b, "n", true)

local r = rgba.r * rgba.a + bg_rgb.r * (1 - rgba.a)
local g = rgba.g * rgba.a + bg_rgb.g * (1 - rgba.a)
Expand All @@ -58,11 +54,9 @@ end
---@param rgb RGB with keys 'r', 'g', 'b' in [0,255]
---@return number 6 digit hex representing the rgb params
local function rgb_to_hex(rgb)
validate({
r = { rgb.r, "n", false },
g = { rgb.g, "n", false },
b = { rgb.b, "n", false },
})
validate("r", rgb.r, "n", false)
validate("g", rgb.g, "n", false)
validate("b", rgb.b, "n", false)
return tohex(bor(lshift(rgb.r, 16), lshift(rgb.g, 8), rgb.b), 6)
end

Expand All @@ -78,7 +72,7 @@ function M.rgba_to_hex(rgba, bg_rgb) return rgb_to_hex(M.rgba_to_rgb(rgba, bg_rg
---@param rgb_24bit number 24-bit RGB value
---@return RGB
function M.decode_24bit_rgb(rgb_24bit)
validate({ rgb_24bit = { rgb_24bit, "n", true } })
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)
Expand Down Expand Up @@ -195,7 +189,8 @@ end
---@param color_infos table of `ColorInformation` objects to highlight.
-- See https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor
function M.buf_color(client_id, bufnr, color_infos, _)
validate({ bufnr = { bufnr, "n", false }, color_infos = { color_infos, "t", false } })
validate("bufnr", bufnr, "n", false)
validate("color_infos", color_infos, "t", false)
if not color_infos or not bufnr then return end
local c = config.lsp.color

Expand All @@ -218,7 +213,8 @@ end
---@param client_id number client id
---@param bufnr number buffer id
function M.buf_clear_color(client_id, bufnr)
validate({ client_id = { client_id, "n", true }, bufnr = { bufnr, "n", true } })
validate("client_id", client_id, "n", true)
validate("bufnr", bufnr, "n", true)
if api.nvim_buf_is_valid(bufnr) then api.nvim_buf_clear_namespace(bufnr, CLIENT_NS, 0, -1) end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/flutter-tools/utils/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function M.is_descendant(root, path)
end

function M.search_ancestors(startpath, func)
vim.validate({ func = { func, "f" } })
vim.validate("func", func, "f")
if func(startpath) then return startpath end
for path in M.iterate_parents(startpath) do
if func(path) then return path end
Expand Down