Skip to content

FlossWare/netbeans-python

Repository files navigation

NetBeans Python Plugin

Python language support for Apache NetBeans IDE using Language Server Protocol (LSP).

Features

✅ Phase 1: Core Language Support (LSP-based)

  • Syntax Highlighting - Automatic Python syntax recognition
  • Code Completion ✅ - Intelligent code suggestions via LSP
    • Auto-triggers on . (object.method)
    • Context-aware completions
    • Imports, functions, classes, variables
    • Powered by pyright or pylsp
  • Error Detection - Real-time syntax and semantic errors
  • Go to Definition - Navigate to function/class definitions
  • Find Usages - Find all references to symbols
  • Hover Documentation - View docstrings on hover
  • Code Formatting - Format with Black, autopep8, etc. (via LSP)

✅ Phase 1: Project & Execution

  • Python Project Recognition - Automatically detects Python projects
    • setup.py (setuptools)
    • pyproject.toml (PEP 518)
    • requirements.txt (pip)
    • Pipfile (pipenv)
    • poetry.lock (poetry)
    • .py files in directory
  • Run Python Scripts - Execute .py files directly from NetBeans
  • Python Console/REPL - Interactive Python shell within NetBeans
  • Output Window Integration - View script output in NetBeans

🚧 Phase 2: Advanced Features (Future)

  • Debugger integration (pdb, debugpy)
  • Testing support (pytest, unittest)
  • Package management (pip)
  • Virtual environment support
  • Jupyter notebook support
  • Type checking (mypy)
  • Linting (pylint, flake8)

Requirements

NetBeans

  • Apache NetBeans 22.0 or later
  • Java 11 or later

Python

  • Python 3.7+ installed and on PATH
  • One of the following language servers:

Pyright (Recommended)

npm install -g pyright

OR

Python LSP Server

pip install python-lsp-server

Installation

From NBM File

  1. Download netbeans-python-1.0.nbm
  2. In NetBeans: Tools → Plugins → Downloaded
  3. Click "Add Plugins..." and select the NBM file
  4. Click "Install" and follow prompts
  5. Restart NetBeans

From Source

git clone https://github.com/FlossWare/netbeans-python.git
cd netbeans-python
mvn clean package

NBM file will be in: python/target/netbeans-python-1.0.nbm

Usage

Opening a Python Project

Method 1: File → Open Project

  • Navigate to any directory containing Python files
  • If it has setup.py, pyproject.toml, or requirements.txt, it's auto-recognized

Method 2: Create New Project

  • Create a directory with Python files
  • Open it in NetBeans

Running Python Scripts

Method 1: Right-click on .py file

  • Right-click any .py file in Projects or Files view
  • Select "Run Python Script"

Method 2: From Editor

  • Open a .py file
  • Right-click in editor
  • Select "Run Python Script"

Output appears in NetBeans Output window.

Python Console/REPL

Open the console:

  • Menu: Window → Python Console
  • Type Python commands interactively

Code Completion

With a language server installed (pyright or pylsp):

Auto-Trigger:

  • Type . after an object → automatic completion
  • Type import → module suggestions
  • Type from → package suggestions

Manual Trigger:

  • Press Ctrl+Space → trigger completion anywhere

Features:

  • Function/method names
  • Class attributes
  • Module imports
  • Built-in functions
  • Local variables
  • Type-aware suggestions (with type hints)

Example:

import os

os.  # ← Auto-complete shows: getcwd(), path, environ, etc.

class MyClass:
    def my_method(self):
        self.  # ← Auto-complete shows class attributes

my_obj = MyClass()
my_obj.  # ← Auto-complete shows: my_method()

Navigation:

  • Hover over symbols for documentation
  • Ctrl+Click (or F12) to go to definition
  • See function signatures and docstrings

Configuration

Python Interpreter Path

If Python is not on your PATH:

  1. Tools → Options → Python (future feature)
  2. Set Python interpreter path

Language Server Selection

By default, the plugin auto-detects pyright or pylsp.

To prefer a specific server: (future feature)

  1. Tools → Options → Python → Language Server
  2. Select "pyright" or "pylsp"

Project Structure

netbeans-python/
├── pom.xml                         # Parent POM
└── python/
    ├── pom.xml                     # Module POM
    └── src/
        ├── main/
        │   ├── java/org/flossware/netbeans/python/
        │   │   ├── lsp/
        │   │   │   └── PythonLspServerLauncher.java      # LSP server launcher
        │   │   ├── completion/
        │   │   │   ├── PythonLspCompletionProvider.java  # Code completion
        │   │   │   ├── PythonLspCompletionQuery.java     # LSP query
        │   │   │   └── PythonLspCompletionItem.java      # Completion item
        │   │   ├── project/
        │   │   │   ├── PythonProject.java                # Project representation
        │   │   │   └── PythonProjectFactory.java         # Project recognition
        │   │   ├── execution/
        │   │   │   └── RunPythonAction.java              # Run script action
        │   │   ├── ui/
        │   │   │   └── PythonConsoleTopComponent.java    # Python REPL
        │   │   └── settings/
        │   │       └── PythonSettings.java               # User settings
        │   └── resources/org/flossware/netbeans/python/
        │       ├── layer.xml                             # NetBeans registration
        │       ├── Bundle.properties                     # I18N strings
        │       └── PythonResolver.xml                    # MIME type resolver
        ├── test/java/                                     # Unit tests
        └── integration-test/java/                         # Integration tests

Technical Details

Language Server Protocol (LSP)

This plugin uses LSP for language features:

  • NetBeans LSP client communicates with Python language server
  • Language server provides: completion, diagnostics, hover, goto-def, etc.
  • Server runs as separate process

Architecture:

┌─────────────────────────┐
│   NetBeans IDE          │
│  ┌──────────────────┐   │
│  │  Python Plugin   │   │
│  │  (LSP Client)    │   │
│  └────────┬─────────┘   │
└───────────┼─────────────┘
            │ LSP/JSON-RPC
            ▼
┌─────────────────────────┐
│  Python Language Server │
│  (pyright or pylsp)     │
└─────────────────────────┘

Project Recognition

A directory is recognized as a Python project if it contains:

  • setup.py - setuptools configuration
  • pyproject.toml - PEP 518 build system
  • requirements.txt - pip dependencies
  • Pipfile - pipenv configuration
  • poetry.lock - poetry configuration
  • Any .py files in root directory

Script Execution

Python scripts are executed using:

python /path/to/script.py

Uses system Python from PATH (or configured interpreter).

Troubleshooting

No code completion / Language features not working

Problem: Language server not installed

Solution:

# Install pyright
npm install -g pyright

# OR install pylsp
pip install python-lsp-server

Verify installation:

# Check pyright
pyright --version

# OR check pylsp
pylsp --version

"Python not found" when running scripts

Problem: Python not on PATH

Solutions:

  1. Add Python to system PATH
  2. Configure Python path in plugin settings (future)
  3. Create shell wrapper

Console/REPL not working

Problem: Python interactive mode not starting

Solution:

  • Ensure Python is on PATH
  • Try running python -i manually to verify
  • Check NetBeans output window for errors

Projects not recognized

Problem: Directory not detected as Python project

Solutions:

  1. Add one of these files to directory:
    • requirements.txt (can be empty)
    • setup.py
    • pyproject.toml
  2. Or create a .py file in root

Development

Building from Source

# Clone repository
git clone https://github.com/FlossWare/netbeans-python.git
cd netbeans-python

# Build
mvn clean package

# NBM file location
ls python/target/netbeans-python-*.nbm

Testing

# Run tests
mvn test

# With coverage
mvn test jacoco:report
open python/target/site/jacoco/index.html

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes
  4. Add tests
  5. Submit pull request

Comparison to Other Editors

Feature PyCharm VS Code + Python This Plugin
Code completion ✅ Native ✅ LSP (Pylance) ✅ LSP (pyright/pylsp)
Debugging ✅ Excellent ✅ Good 🚧 Planned
Refactoring ✅ Excellent ✅ Good ✅ LSP-based
Project management ✅ Native ✅ Extensions ✅ Native
REPL ✅ Yes ✅ Yes ✅ Yes
Run scripts ✅ Yes ✅ Yes ✅ Yes
Virtual env ✅ Excellent ✅ Good 🚧 Planned
Testing ✅ pytest, unittest ✅ pytest, unittest 🚧 Planned
Cost 💰 Paid ✅ Free ✅ Free

Roadmap

Version 1.0 (Current) ✅

  • LSP integration (pyright/pylsp)
  • Project recognition
  • Run Python scripts
  • Python REPL console
  • Basic configuration

Version 1.1 (Next) 🚧

  • Debugger integration (debugpy)
  • Virtual environment auto-detection
  • pip package management UI
  • pytest/unittest integration
  • Enhanced settings panel

Version 2.0 (Future) 📋

  • Jupyter notebook support
  • Django/Flask project templates
  • Code formatting UI (Black, autopep8)
  • Linting integration (pylint, flake8, mypy)
  • Advanced refactoring tools

License

Apache License 2.0

Credits

  • Built by FlossWare
  • Uses Language Server Protocol
  • Supports pyright (Microsoft) and pylsp (Python community)
  • Inspired by the original nbpython project

Links

FAQ

Q: Do I need to install both pyright AND pylsp?
A: No, install either one. Pyright is recommended (faster, more accurate).

Q: Will this work with Python 2?
A: Python 2 is end-of-life. This plugin targets Python 3.7+.

Q: Can I use this with Anaconda?
A: Yes, as long as Python is on your PATH or configured in settings.

Q: Does this support type checking?
A: Yes, via the language server (pyright has built-in type checking).

Q: Can I debug Python code?
A: Not yet - debugger support is planned for version 1.1.

Q: How does this compare to PyDev (Eclipse)?
A: Both provide Python IDE features. This plugin uses LSP for modern language support.


Version: 1.0
Last Updated: 2026-05-24
Status: Initial Release

About

Python language support for Apache NetBeans IDE using LSP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages