From fc32c1b69ccd5741d3a8d2e57b4b23d4ca2b9e67 Mon Sep 17 00:00:00 2001 From: "asep.komarudin" Date: Fri, 28 Jun 2024 08:49:33 +0700 Subject: [PATCH] add: global variable unique_list --- lua/plugins/themes/_globalvar.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/plugins/themes/_globalvar.lua b/lua/plugins/themes/_globalvar.lua index 9773d8b..be69a19 100644 --- a/lua/plugins/themes/_globalvar.lua +++ b/lua/plugins/themes/_globalvar.lua @@ -37,6 +37,20 @@ _G.idxOf = function(array, value) return nil end +_G.unique_list = function(list) + local seen = {} + local result = {} + + for _, val in ipairs(list) do + if not seen[val] then + table.insert(result, val) + seen[val] = true + end + end + + return result +end + -- run if rust config true if pcode.active_rust_config then table.insert(pcode.mason_ensure_installed, "rust_analyzer")