Skip to content

Gvo87/NotepadPlusPlus-LLM-Plugin

Repository files navigation

Notepad++ LLM Assistant Plugin

A powerful Notepad++ plugin that integrates Large Language Model (LLM) capabilities using the OpenAI API, bringing AI-powered text processing directly into your favorite text editor.

πŸš€ Features

Core LLM Functions

  • 🎯 Custom Prompt: Enter any custom prompt for flexible AI interactions
  • ✨ Enhance Text: Improve and refine your text while maintaining its original meaning
  • πŸ’» Generate Code: Generate code based on descriptions or comments
  • πŸ“ Complete Text: Complete partial text naturally and contextually
  • πŸ“– Check Grammar: Check and correct grammar in your text
  • 🌍 Translate Text: Translate text to English or other appropriate languages
  • πŸ“‹ Summarize Text: Create concise summaries of longer text

Smart Text Selection

  • Auto-Select All: If no text is selected, automatically processes the entire document
  • Selection-Aware: Works with any selected text portion
  • Unicode Support: Full support for international characters and languages

User-Friendly Interface

  • Settings Dialog: Easy configuration of OpenAI API key with connection testing
  • Input Dialog: Custom prompt feature with multi-line text input
  • Error Handling: Clear error messages and robust operation

πŸ“‹ Requirements

  • Notepad++: Version 7.0 or later (64-bit recommended)
  • OpenAI API Key: Get one from OpenAI Platform
  • Operating System: Windows 10 or later
  • Architecture: 64-bit Windows (plugin compiled for x64)

πŸ“¦ Installation

Via Plugins Admin (recommended)

Once the plugin is accepted into the official nppPluginList, you can install it directly from Notepad++:

  1. Open Plugins β†’ Plugins Admin…
  2. On the Available tab, search for LLM Assistant
  3. Check the box and click Install β€” Notepad++ handles the download and future updates automatically

Maintainers: see packaging/PLUGINS_ADMIN_SUBMISSION.md for how releases and the Plugins Admin listing are produced.

Quick Installation (manual)

  1. Download the plugin: LLMAssistant.dll
  2. Create directory: C:\Program Files\Notepad++\plugins\LLMAssistant\
  3. Copy file: Place LLMAssistant.dll in the created directory
  4. Restart Notepad++
  5. Configure: Go to Plugins > LLM Assistant > Settings and enter your OpenAI API key

Verification

After installation, you should see "LLM Assistant" in the Plugins menu with 8 options:

  1. Custom Prompt
  2. Enhance Text
  3. Generate Code
  4. Complete Text
  5. Check Grammar
  6. Translate Text
  7. Summarize Text
  8. Settings

🎯 Usage Guide

Basic Usage

  1. Open a document in Notepad++
  2. Select text you want to process (optional - if nothing is selected, the entire document will be processed)
  3. Choose a function from Plugins > LLM Assistant
  4. Wait for the AI to process your request
  5. Review the result that replaces your original text

Custom Prompt Feature

The Custom Prompt option allows maximum flexibility:

  1. Select Plugins > LLM Assistant > Custom Prompt
  2. Enter any prompt in the dialog (e.g., "Explain this code", "Make this more formal", "Fix any bugs")
  3. Your prompt will be combined with the selected text and sent to the AI
  4. The result replaces the original text

Example Prompts

  • "Refactor this code for better performance"
  • "Convert this to Python"
  • "Make this email more professional"
  • "Explain what this function does"
  • "Add error handling to this code"
  • "Translate this to Spanish"

πŸ”§ Building from Source

Prerequisites

  • Visual Studio 2022 with C++ development tools
  • Windows 10 SDK (latest version)
  • Git (for cloning the repository)

Build Steps

# Clone the repository
git clone <repository-url>
cd NotepadPlusPlus-LLM-Plugin

# Build the plugin
.\build.bat

# The compiled DLL will be in:
# x64\Release\LLMAssistant.dll

Development Environment

The build script automatically:

  • Detects Visual Studio 2022 installation
  • Sets up the build environment
  • Compiles with platform toolset v143
  • Links required Windows libraries

Automated Tests

The portable request, JSON, and UTF-8 regression tests use Catch2. Configure them with CMake:

cmake -S . -B CMakeBuild
cmake --build CMakeBuild
ctest --test-dir CMakeBuild --output-on-failure

The first configure downloads the pinned Catch2 release. The tests do not require Notepad++ or an OpenAI API key.

πŸ—οΈ Technical Architecture

Core Components

  • Language: C++ using official Notepad++ plugin template
  • API Integration: OpenAI GPT models via REST API
  • HTTP Client: WinINet for native Windows compatibility
  • JSON Processing: Custom lightweight JSON parser/builder (no external dependencies)
  • Text Encoding: Full UTF-8 support for international text
  • Memory Management: RAII principles with robust error handling
  • Threading: Thread-safe singleton pattern for LLM service

Plugin Architecture

LLMAssistant.dll
β”œβ”€β”€ PluginDefinition.cpp    # Main plugin logic and menu handlers
β”œβ”€β”€ LLMService.cpp          # OpenAI API integration
β”œβ”€β”€ SettingsDialog.cpp      # Configuration UI
β”œβ”€β”€ SimpleJson.cpp          # JSON parsing/building
β”œβ”€β”€ NppPlugin.cpp           # Notepad++ plugin interface
└── Resources               # Dialog templates and constants

Security Features

  • Secure Storage: API keys stored in Windows registry with user-specific access
  • HTTPS Only: All API communications use TLS encryption
  • No Data Persistence: No text data stored locally by the plugin
  • Memory Safety: Proper buffer management and cleanup
  • Error Isolation: Exceptions contained within plugin boundaries

βš™οΈ Configuration

API Key Setup

  1. Get an OpenAI API key from OpenAI Platform
  2. Open Notepad++
  3. Go to Plugins > LLM Assistant > Settings
  4. Enter your API key
  5. Click "Test Connection" to verify
  6. Click "OK" to save

Registry Storage

API keys are stored in: HKEY_CURRENT_USER\Software\LLMAssistant\APIKey

πŸ› Troubleshooting

Common Issues

Plugin doesn't appear in menu

  • Ensure DLL is in correct directory: C:\Program Files\Notepad++\plugins\LLMAssistant\
  • Restart Notepad++ completely
  • Check if you have 64-bit Notepad++ (plugin is compiled for x64)

"API key not configured" error

  • Go to Settings and enter your OpenAI API key
  • Use "Test Connection" to verify the key works

"No text available" error

  • Open a document with text content
  • The plugin needs text to process

Connection errors

  • Check your internet connection
  • Verify your OpenAI API key is valid and has credits
  • Ensure firewall allows Notepad++ to make HTTP requests

Debug Information

If you encounter issues, check:

  1. Notepad++ version (should be 7.0+)
  2. Windows architecture (plugin requires 64-bit)
  3. API key validity on OpenAI platform
  4. Available API credits/quota

πŸ“„ License

This project is open source. See the source code for implementation details and licensing information.

🀝 Contributing

Contributions are welcome! Areas for improvement:

  • Additional LLM providers (Anthropic, Google, etc.)
  • More predefined prompts
  • Batch processing capabilities
  • Plugin settings persistence
  • Internationalization

πŸ“ž Support

For issues, questions, or feature requests:

  1. Check this README for common solutions
  2. Review the source code for technical details
  3. Create an issue in the project repository
  4. Include your Notepad++ version, Windows version, and error details

Made with ❀️ for the Notepad++ community

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors