Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18b0947

Browse files
authored
fixed deprecated syntax for vim.validate (#458)
1 parent 8edcdab commit 18b0947

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

lua/flutter-tools/config.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ local function validate_prefs(prefs)
3636
end
3737
)
3838
end
39-
vim.validate({
40-
outline = { prefs.outline, "table", true },
41-
dev_log = { prefs.dev_log, "table", true },
42-
closing_tags = { prefs.closing_tags, "table", true },
43-
})
39+
vim.validate("outline", prefs.outline, "table", true)
40+
vim.validate("dev_log", prefs.dev_log, "table", true)
41+
vim.validate("closing_tags", prefs.closing_tags, "table", true)
4442
end
4543

4644
---Create a proportional split using a percentage specified as a float

lua/flutter-tools/lsp/color/utils.lua

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,16 @@ end
3232
---@return RGB rgb_table
3333
--- FIXME: this currently does not support transparent backgrounds. Need a replacement for bg_rgb
3434
function M.rgba_to_rgb(rgba, bg_rgb)
35-
validate({
36-
rgba = { rgba, "t", true },
37-
bg_rgb = { bg_rgb, "t", false },
38-
r = { rgba.r, "n", true },
39-
g = { rgba.g, "n", true },
40-
b = { rgba.b, "n", true },
41-
a = { rgba.a, "n", true },
42-
})
35+
validate("rgba", rgba, "t", true)
36+
validate("bg_rgb", bg_rgb, "t", false)
37+
validate("r", rgba.r, "n", true)
38+
validate("g", rgba.g, "n", true)
39+
validate("b", rgba.b, "n", true)
40+
validate("a", rgba.a, "n", true)
4341

44-
validate({
45-
bg_r = { bg_rgb.r, "n", true },
46-
bg_g = { bg_rgb.g, "n", true },
47-
bg_b = { bg_rgb.b, "n", true },
48-
})
42+
validate("bg_r", bg_rgb.r, "n", true)
43+
validate("bg_g", bg_rgb.g, "n", true)
44+
validate("bg_b", bg_rgb.b, "n", true)
4945

5046
local r = rgba.r * rgba.a + bg_rgb.r * (1 - rgba.a)
5147
local g = rgba.g * rgba.a + bg_rgb.g * (1 - rgba.a)
@@ -58,11 +54,9 @@ end
5854
---@param rgb RGB with keys 'r', 'g', 'b' in [0,255]
5955
---@return number 6 digit hex representing the rgb params
6056
local function rgb_to_hex(rgb)
61-
validate({
62-
r = { rgb.r, "n", false },
63-
g = { rgb.g, "n", false },
64-
b = { rgb.b, "n", false },
65-
})
57+
validate("r", rgb.r, "n", false)
58+
validate("g", rgb.g, "n", false)
59+
validate("b", rgb.b, "n", false)
6660
return tohex(bor(lshift(rgb.r, 16), lshift(rgb.g, 8), rgb.b), 6)
6761
end
6862

@@ -78,7 +72,7 @@ function M.rgba_to_hex(rgba, bg_rgb) return rgb_to_hex(M.rgba_to_rgb(rgba, bg_rg
7872
---@param rgb_24bit number 24-bit RGB value
7973
---@return RGB
8074
function M.decode_24bit_rgb(rgb_24bit)
81-
validate({ rgb_24bit = { rgb_24bit, "n", true } })
75+
validate("rgb_24bit", rgb_24bit, "n", true)
8276
local r = band(rshift(rgb_24bit, 16), 255)
8377
local g = band(rshift(rgb_24bit, 8), 255)
8478
local b = band(rgb_24bit, 255)
@@ -195,7 +189,8 @@ end
195189
---@param color_infos table of `ColorInformation` objects to highlight.
196190
-- See https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor
197191
function M.buf_color(client_id, bufnr, color_infos, _)
198-
validate({ bufnr = { bufnr, "n", false }, color_infos = { color_infos, "t", false } })
192+
validate("bufnr", bufnr, "n", false)
193+
validate("color_infos", color_infos, "t", false)
199194
if not color_infos or not bufnr then return end
200195
local c = config.lsp.color
201196

@@ -218,7 +213,8 @@ end
218213
---@param client_id number client id
219214
---@param bufnr number buffer id
220215
function M.buf_clear_color(client_id, bufnr)
221-
validate({ client_id = { client_id, "n", true }, bufnr = { bufnr, "n", true } })
216+
validate("client_id", client_id, "n", true)
217+
validate("bufnr", bufnr, "n", true)
222218
if api.nvim_buf_is_valid(bufnr) then api.nvim_buf_clear_namespace(bufnr, CLIENT_NS, 0, -1) end
223219
end
224220

lua/flutter-tools/utils/path.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function M.is_descendant(root, path)
9393
end
9494

9595
function M.search_ancestors(startpath, func)
96-
vim.validate({ func = { func, "f" } })
96+
vim.validate("func", func, "f")
9797
if func(startpath) then return startpath end
9898
for path in M.iterate_parents(startpath) do
9999
if func(path) then return path end

0 commit comments

Comments
 (0)