From 2ca160e852d55eb549f6f78ca7e09cab2b13a0e6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 12 Jun 2018 13:52:40 +0100 Subject: [PATCH] [Feature] Allow to add symbols using settings directly --- src/plugins/lua/settings.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 8e4009162..468ab6583 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -55,6 +55,24 @@ local function apply_settings(task, to_apply) task:set_flag(fl) end end + + if to_apply.symbols then + -- Add symbols, specified in the settings + if #to_apply.symbols > 0 then + fun.each(function(val) + task:insert_result(val, 1.0) + end, + fun.filter(function(elt) return type(elt) == 'string' end, + to_apply.symbols)) + else + -- Object like symbols + fun.each(function(k, val) + task:insert_result(k, val.score or 1.0, val.options or {}) + end, + fun.filter(function(_, elt) return type(elt) == 'table' end, + to_apply.symbols)) + end + end end -- Checks for overridden settings within query params and returns 'true' if -- 2.39.5