From a0f3867e8536b187647f22e32e8e95aa4d69a508 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 5 Jan 2023 23:28:29 +0800 Subject: improve lua complete --- xmake/plugins/lua/xmake.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'xmake/plugins/lua/xmake.lua') diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index 792299651..60a12fe54 100644 --- a/xmake/plugins/lua/xmake.lua +++ b/xmake/plugins/lua/xmake.lua @@ -56,8 +56,20 @@ task("lua") if not complete or opt.command or opt.list then return end - - return import("main.scripts")() + local list = import("main.scripts")() + if list and complete then + local result = {} + for _, item in ipairs(list) do + if item:startswith(complete) then + table.insert(result, item) + end + end + if #result > 0 then + return result + end + end + -- we just return nil and fallback to system autocomplete + -- it will complete file path, e.g. `xmake l scripts/test.lua` end } , {nil, "arguments" , "vs" , nil , "The script arguments, use '--deserialize' option to enable deserializing.", "e.g.", -- cgit v1.3.1