diff --git a/lua/custom/plugins/configs/chat-gpt.lua b/lua/custom/plugins/configs/chat-gpt.lua new file mode 100644 index 0000000..6b21b16 --- /dev/null +++ b/lua/custom/plugins/configs/chat-gpt.lua @@ -0,0 +1,91 @@ +local M = {} + +M.load_api_key = function() + local openai_api_key_path = vim.fn.expand('$XDG_CONFIG_HOME') .. '/openai/token' + local openai_api_key = vim.fn.readfile(openai_api_key_path, '', 1) + vim.fn.setenv('OPENAI_API_KEY', openai_api_key[1]) +end + + + +local config = { + -- welcome_message = WELCOME_MESSAGE, -- set to "" if you don't like the fancy godot robot + loading_text = "loading", + question_sign = "", -- you can use emoji if you want e.g. 🙂 + answer_sign = "ﮧ", -- 🤖 + max_line_length = 120, + yank_register = "+", + chat_layout = { + relative = "editor", + position = "50%", + size = { + height = "80%", + width = "80%", + }, + }, + settings_window = { + border = { + style = "rounded", + text = { + top = " Settings ", + }, + }, + }, + chat_window = { + filetype = "chatgpt", + border = { + highlight = "FloatBorder", + style = "rounded", + text = { + top = " ChatGPT ", + }, + }, + }, + chat_input = { + prompt = "  ", + border = { + highlight = "FloatBorder", + style = "rounded", + text = { + top_align = "center", + top = " Prompt ", + }, + }, + }, + openai_params = { + model = "text-davinci-003", + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 300, + temperature = 0, + top_p = 1, + n = 1, + }, + openai_edit_params = { + model = "code-davinci-edit-001", + temperature = 0, + top_p = 1, + n = 1, + }, + keymaps = { + close = { "", "" }, + yank_last = "", + scroll_up = "", + scroll_down = "", + toggle_settings = "", + new_session = "", + cycle_windows = "", + }, +} + +M.setup = function() + local ok, chatgpt = pcall(require, 'chatgpt') + if not ok then + vim.notify("missing module chatgpt", vim.log.levels.WARN) + return + end + chatgpt.setup(config) +end + + +return M diff --git a/lua/custom/plugins/configs/chatgpt.lua b/lua/custom/plugins/configs/chatgpt.lua deleted file mode 100644 index 5103da6..0000000 --- a/lua/custom/plugins/configs/chatgpt.lua +++ /dev/null @@ -1,18 +0,0 @@ -local ok, chatgpt = pcall(require, 'chatgpt') -if not ok then - vim.notify("missing module chatgpt", vim.log.levels.WARN) - return -end - -local M = {} - -local config = { - loading_text = "loading", -} - -M.setup = function() - chatgpt.setup({}) -end - - -return M diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 64b455c..cdfa8fa 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -143,14 +143,21 @@ return { require("core.utils").load_mappings "copilot" end }, + ["MunifTanjim/nui.nvim"] = { + module = {"nui.layout", "nui.popup"}, + module_pattern = {"nui.*"} + }, ["jackMort/ChatGPT.nvim"] = { opt = true, + keys = {"gpt"}, + module_pattern = {"chatgpt*"}, + after = {"nui.nvim", "telescope.nvim"}, + setup = function() + require("custom.plugins.configs.chat-gpt").load_api_key() + end, config = function() - -- require("custom.plugins.configs.chatgpt").setup() - require("chatgpt").setup({ - -- optional configuration - }) + require("custom.plugins.configs.chat-gpt").setup() end, requires = { "MunifTanjim/nui.nvim",