Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions python_binding_and_cmdline/refact/__init__.py
Original file line number Diff line number Diff line change
@@ -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", "<A-e>", "<cmd>lua _refact_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("t", "<A-e>", "<cmd>lua _refact_toggle()<CR>", { 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", "<A-c>", "<cmd>lua _chat_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("t", "<A-c>", "<cmd>lua _chat_toggle()<CR>", { noremap = true, silent = true })
21 changes: 21 additions & 0 deletions python_binding_and_cmdline/refact/chat_with_at_command.py
Original file line number Diff line number Diff line change
@@ -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()