From 741d06ba4e9341b11d1db2757b8d492c1faca242 Mon Sep 17 00:00:00 2001 From: luozhiya Date: Fri, 27 Sep 2024 23:39:46 +0800 Subject: [PATCH] Server URLs --- lua/fittencode/client.lua | 16 +++++++++++++++- lua/fittencode/config.lua | 9 +++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/fittencode/client.lua b/lua/fittencode/client.lua index 4ef075b..73c6ee8 100644 --- a/lua/fittencode/client.lua +++ b/lua/fittencode/client.lua @@ -27,9 +27,23 @@ local urls = { add_files_and_directories = '/codeapi/rag/add_files_and_directories', } +local server_urls = { + ['+0800'] = 'https://fc.fittenlab.cn', +} + +setmetatable(server_urls, { + __index = function() + return 'https://fc.fittenlab.com' + end +}) + +if Config.fitten.server_url == '' then + Config.fitten.server_url = server_urls[os.date('%z')] +end + for k, v in pairs(urls) do if not v:match('^https?://') then - urls[k] = Config.fitten.api_endpoint .. v + urls[k] = Config.fitten.server_url .. v end end diff --git a/lua/fittencode/config.lua b/lua/fittencode/config.lua index 536c540..f4ba9b9 100644 --- a/lua/fittencode/config.lua +++ b/lua/fittencode/config.lua @@ -11,8 +11,13 @@ local defaults = { -- * 'default' -- * 'enterprise' version = 'default', - api_endpoint = 'https://fc.fittenlab.cn', - api_key = '', + -- The server URL for Fitten Code. + -- Fitten Code will detect the server URL based on your timezone automatically if it's not set. + -- You can also change it to your own server URL if you have a private server. + -- Default server URL for different regions: + -- * China: 'https://fc.fittenlab.cn' + -- * International: 'https://fc.fittenlab.com' + server_url = '', }, action = { document_code = {