Geany Copilot is an AI-powered assistant integrated into the Geany IDE. Inspired by GitHub Copilot, it leverages advanced language models to provide context-aware code completions and creative copywriting assistance, enhancing your productivity and creativity directly within the Geany editor.
- Features
- Installation
- Configuration
- Usage
- Dependencies
- Contributing
- License
- Acknowledgements
- Contact
- AI-Powered Code Completions: Intelligent code suggestions based on your current context within the Geany editor.
- Creative Copywriting Assistance: Generate and refine creative content, offering constructive feedback and suggestions.
- Customizable Settings: Easily configure API endpoints, remote API keys, system prompts, and behavior preferences to tailor the assistant to your needs.
- Seamless Integration: Works directly within Geany, maintaining your workflow without the need to switch between tools.
- Error Handling: Provides informative error dialogs to help troubleshoot issues with API interactions.
- Selection Replacement: Option to replace selected text with AI-generated suggestions, streamlining the editing process.
- Geany IDE: Ensure you have Geany installed on your system.
- Lua Support: Geany should be configured to support Lua scripting.
- Dependencies: The plugin relies on the
lunajson
library for JSON handling andcURL
for HTTP requests.
-
Clone the Repository:
git clone https://github.com/DevElCuy/geany-copilot.git
-
Navigate to the Plugin Directory:
cd geany-copilot
-
Install Dependencies:
Ensure that the
lunajson
library is available. You can install it using LuaRocks:luarocks install lunajson
Additionally, ensure that
cURL
is installed on your system:# For Debian/Ubuntu sudo apt-get install curl # For macOS using Homebrew brew install curl
-
Place the Plugins in Geany's Plugin Directory:
Copy the Lua scripts (
copilot.lua
andcopywriter.lua
) to Geany's plugin or script directory, typically located at~/.config/geany/plugins/
or a similar path depending on your operating system.mkdir -p ~/.config/geany/plugins/geanylua/geany-copilot/ cp copilot.lua copywriter.lua ~/.config/geany/plugins/geanylua/geany-copilot/
-
Restart Geany:
After placing the plugins, restart Geany in case the lua scripts didn't load automatically.
Geany Copilot uses JSON settings files to manage its configurations for both code assistance and copywriting assistance. The settings include the OpenAI API base URL, API key, system prompts, and behavior preferences.
-
Code Assistance Settings:
~/.config/geany/plugins/geanylua/geany-copilot/copilot.json
-
Copywriting Assistance Settings:
~/.config/geany/plugins/geanylua/geany-copilot/copywriter.json
-
(Optional): Setup shortcuts Open the Keybindings section under Geany Preferences. Scroll down to "Lua Script" sub-section and set the shortcut for both "Copilot" and "Copywriter". For example: backslash and Return respectively.
-
Open Geany Copilot Settings Dialog:
In Geany, you can access the settings dialog through either a plugin menu or a keyboard shortcut. The initial dialog will feature a "Settings" button. Alternatively, you can directly invoke the settings dialog by typing and selecting ".gc conf" anywhere within the editor, followed by activating the keyboard shortcut.
-
Configure API Settings:
- Base URL: Enter your OpenAI API base URL (e.g.,
https://api.openai.com
). - API Key: Enter your OpenAI API key. This key is required to authenticate requests to the API.
Note: Any compatible OpenAI API (OAI) is supported (i.e: ollama, llama-server, etc.)
- Base URL: Enter your OpenAI API base URL (e.g.,
-
Customize System Prompt:
- Code Assistance: Defines the behavior of the AI assistant for coding tasks.
- Copywriting Assistance: Defines the behavior of the AI assistant for copywriting tasks.
-
Behavior Preferences:
- Replace Selection: Choose whether the AI-generated suggestion should replace the currently selected text.
-
Save Settings:
Click the Save button to apply your configurations.
Once installed and configured, Geany Copilot is ready to assist you with both code completions and copywriting tasks.
Geany Copilot for code assistance operates similarly to GitHub Copilot, providing intelligent code suggestions based on your current context within the Geany editor.
-
Select Code Context:
Highlight the code snippet you want the AI to analyze and complete. If no text is selected, Geany Copilot will automatically determine a context around the current caret position.
-
Invoke Geany Copilot:
- Use a designated keyboard shortcut.
- Access via the plugin menu.
-
Review Suggestions:
Geany Copilot will display a dialog with AI-generated code completion options (usually 1). Review the suggestions, select the one that best fits your needs and click Accept.
-
Apply Completion:
Upon selection, the chosen code snippet will replace the original selection.
Geany Copilot also offers creative copywriting assistance, helping you generate and refine written content directly within the Geany editor.
-
Select Text or Position Caret:
- To generate new content, place the caret where you want the text to be inserted.
- To review or refine existing text, highlight the text you wish to work on.
-
Invoke Copywriting Assistant:
- Use a designated keyboard shortcut.
- Access via the plugin menu.
-
Choose an Action:
- Generate Content: Create new text based on the provided context.
- Review Text: Get constructive feedback and suggestions for improvement.
-
Review and Apply Suggestions:
The assistant will display a dialog with AI-generated suggestions. Choose the appropriate option to insert or replace text, depending on your configuration..
-
Lua: Ensure that Lua is installed and properly configured with Geany.
-
lunajson: A Lua library for JSON encoding and decoding. Install via LuaRocks:
luarocks install lunajson
-
cURL: The plugin uses
cURL
to make HTTP requests to the OpenAI API. Ensure thatcURL
is installed on your system.# For Debian/Ubuntu sudo apt-get install curl # For macOS using Homebrew brew install curl
Contributions are welcome! If you'd like to contribute to Geany Copilot, please follow these guidelines:
-
Fork the Repository:
Click the Fork button at the top of this page to create a personal copy of the repository.
-
Create a Feature Branch:
git checkout -b feature/your-feature-name
-
Commit Your Changes:
git commit -m "Add your detailed description of the changes"
-
Push to Your Fork:
git push origin feature/your-feature-name
-
Open a Pull Request:
Navigate to the original repository and click New Pull Request. Provide a clear description of your changes and submit the pull request.
If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.
This project is licensed under the MIT License. You are free to use, modify, and distribute this software in accordance with the terms of the license.
Disclaimer: Geany Copilot interacts with external APIs to provide code completions and copywriting assistance. Ensure that you handle your API keys securely and be aware of any costs associated with API usage.
- Inspired by Geany IDE and GitHub Copilot.
- Utilizes the lunajson library for JSON handling.
- Powered by OpenAI's language models.
For any queries or support, please reach out to DevElCuy.
Happy Coding and Writing! 🚀