From 9e0b5bf8f13fa7f260932d350685bc379dc4098c Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Dec 2024 23:24:29 +0800 Subject: [PATCH] fix(ci): lua style (#948) --- lua/avante/path.lua | 8 ++------ lua/avante/repo_map.lua | 12 +++--------- lua/avante/tokenizers.lua | 12 +++--------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/lua/avante/path.lua b/lua/avante/path.lua index 09c2718..25ab88c 100644 --- a/lua/avante/path.lua +++ b/lua/avante/path.lua @@ -180,15 +180,11 @@ P.repo_map = RepoMap ---@return AvanteTemplates|nil P._init_templates_lib = function() - if templates ~= nil then - return templates - end + if templates ~= nil then return templates end local ok, module = pcall(require, "avante_templates") ---@cast module AvanteTemplates ---@cast ok boolean - if not ok then - return nil - end + if not ok then return nil end templates = module return templates diff --git a/lua/avante/repo_map.lua b/lua/avante/repo_map.lua index fd974ed..9a1e6b5 100644 --- a/lua/avante/repo_map.lua +++ b/lua/avante/repo_map.lua @@ -17,22 +17,16 @@ local RepoMap = {} ---@return AvanteRepoMap|nil function RepoMap._init_repo_map_lib() - if repo_map_lib ~= nil then - return repo_map_lib - end + if repo_map_lib ~= nil then return repo_map_lib end local ok, core = pcall(require, "avante_repo_map") - if not ok then - return nil - end + if not ok then return nil end repo_map_lib = core return repo_map_lib end -function RepoMap.setup() - vim.defer_fn(RepoMap._init_repo_map_lib, 1000) -end +function RepoMap.setup() vim.defer_fn(RepoMap._init_repo_map_lib, 1000) end function RepoMap.get_ts_lang(filepath) local filetype = RepoMap.get_filetype(filepath) diff --git a/lua/avante/tokenizers.lua b/lua/avante/tokenizers.lua index 2e41d5a..9368c2c 100644 --- a/lua/avante/tokenizers.lua +++ b/lua/avante/tokenizers.lua @@ -13,14 +13,10 @@ local M = {} ---@param model "gpt-4o" | string ---@return AvanteTokenizer|nil M._init_tokenizers_lib = function(model) - if tokenizers ~= nil then - return tokenizers - end + if tokenizers ~= nil then return tokenizers end local ok, core = pcall(require, "avante_tokenizers") - if not ok then - return nil - end + if not ok then return nil end ---@cast core AvanteTokenizer tokenizers = core @@ -35,9 +31,7 @@ end M.setup = function(model, warning) current_model = model warning = warning or true - vim.defer_fn(function() - M._init_tokenizers_lib(model) - end, 1000) + vim.defer_fn(function() M._init_tokenizers_lib(model) end, 1000) if warning then local HF_TOKEN = os.getenv("HF_TOKEN")