From 91430d2026ab77c7c0d306bdcb4e0944e41ddc3f Mon Sep 17 00:00:00 2001 From: luozhiya Date: Wed, 5 Jun 2024 08:50:07 +0800 Subject: [PATCH] Code Clean --- lua/fittencode/commands.lua | 2 +- lua/fittencode/engines/actions/init.lua | 24 ++++++++++++------------ lua/fittencode/engines/inline/init.lua | 3 +-- lua/fittencode/views/chat.lua | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lua/fittencode/commands.lua b/lua/fittencode/commands.lua index 8417cf6..5837d53 100644 --- a/lua/fittencode/commands.lua +++ b/lua/fittencode/commands.lua @@ -176,7 +176,7 @@ function M.setup() table.remove(actions, 1) return cmd(unpack(actions)) end - Log.debug('Invalid command; fargs: {}', line.fargs) + Log.debug('Invalid command fargs: {}', line.fargs) end, { complete = function(_, line) local args = vim.split(vim.trim(line), '%s+') diff --git a/lua/fittencode/engines/actions/init.lua b/lua/fittencode/engines/actions/init.lua index bfa099e..207c912 100644 --- a/lua/fittencode/engines/actions/init.lua +++ b/lua/fittencode/engines/actions/init.lua @@ -667,18 +667,6 @@ local chat_callbacks = { end, } -function ActionsEngine.setup() - chat = Chat:new(chat_callbacks) - content = Content:new(chat) - tasks = TaskScheduler:new() - tasks:setup() - status = Status:new({ - tag = 'ActionsEngine', - ready_idle = true, - }) - setup_actions_menu() -end - ---@return integer function ActionsEngine.get_status() return status:get_current() @@ -700,4 +688,16 @@ function ActionsEngine.toggle_chat() end end +function ActionsEngine.setup() + chat = Chat:new(chat_callbacks) + content = Content:new(chat) + tasks = TaskScheduler:new() + tasks:setup() + status = Status:new({ + tag = 'ActionsEngine', + ready_idle = true, + }) + setup_actions_menu() +end + return ActionsEngine diff --git a/lua/fittencode/engines/inline/init.lua b/lua/fittencode/engines/inline/init.lua index 7f080c3..c14804e 100644 --- a/lua/fittencode/engines/inline/init.lua +++ b/lua/fittencode/engines/inline/init.lua @@ -523,10 +523,9 @@ local function setup_keymaps() Base.map('i', key, function() local v = KEYS[value] if v == nil then - Log.warn('Invalid keymap value: ', value) return end - if v then + if v[1] then if M.has_suggestions() then M[value]() else diff --git a/lua/fittencode/views/chat.lua b/lua/fittencode/views/chat.lua index f3d4718..1c17a31 100644 --- a/lua/fittencode/views/chat.lua +++ b/lua/fittencode/views/chat.lua @@ -93,7 +93,7 @@ function M:create(opts) for key, value in pairs(opts.keymaps or {}) do Base.map('n', key, function() - if vim.tbl_contains(vim.tbl_keys(FX), value) then + if FX[value] then FX[value]() end end, { buffer = self.buffer })