diff --git a/python_binding_and_cmdline/refact/__init__.py b/python_binding_and_cmdline/refact/__init__.py index e69de29bb..725f6dd80 100644 --- a/python_binding_and_cmdline/refact/__init__.py +++ b/python_binding_and_cmdline/refact/__init__.py @@ -0,0 +1,29 @@ +-- init.lua +-- Ensure you have toggleterm installed +require('toggleterm').setup{} + +local Terminal = require('toggleterm.terminal').Terminal + +-- Create a terminal instance for refact +local refact = Terminal:new({ cmd = "refact .", direction = "float", hidden = true }) + +-- Function to toggle refact terminal +function _refact_toggle() + refact:toggle() +end + +-- Key mappings for toggling the refact terminal +vim.api.nvim_set_keymap("n", "", "lua _refact_toggle()", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("t", "", "lua _refact_toggle()", { noremap = true, silent = true }) + +-- Create a terminal instance for chat +local chat = Terminal:new({ cmd = "python3 chat_with_at_command.py", direction = "float", hidden = true }) + +-- Function to toggle chat terminal +function _chat_toggle() + chat:toggle() +end + +-- Key mapping for toggling the chat terminal +vim.api.nvim_set_keymap("n", "", "lua _chat_toggle()", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("t", "", "lua _chat_toggle()", { noremap = true, silent = true }) diff --git a/python_binding_and_cmdline/refact/chat_with_at_command.py b/python_binding_and_cmdline/refact/chat_with_at_command.py new file mode 100644 index 000000000..799e3281d --- /dev/null +++ b/python_binding_and_cmdline/refact/chat_with_at_command.py @@ -0,0 +1,21 @@ +# chat_with_at_command.py +import sys + +def chat(): + print("Chat started. Type 'exit' to quit.") + while True: + user_input = input("You: ") + if user_input.lower() == 'exit': + print("Chat ended.") + break + # Add your chat logic here + response = generate_response(user_input) # Call function to generate a response + print(f"Bot: {response}") + +def generate_response(user_input): + # Simple echo response logic; you can customize this for your application + # Here, you can add more sophisticated logic or connect to a chatbot API + return f"Echo: {user_input}" + +if __name__ == "__main__": + chat()