Skip to content

Commit f453a7e

Browse files
committed
🦊 Initial support for Python languages
0 parents  commit f453a7e

8 files changed

Lines changed: 277 additions & 0 deletions

File tree

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
.sofluffy/
20+
21+
# Flutter/Dart/Pub related
22+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
23+
/pubspec.lock
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins-dependencies
27+
/build/
28+
/coverage/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 1.0.0
4+
5+
- Initial release of Python support for Lumide IDE.
6+
- Integrated `pyright` LSP for diagnostics, completions, and navigation.
7+
- Added command to restart the language server.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 SoFluffy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# lumide_python
2+
3+
[![pub package](https://img.shields.io/pub/v/lumide_python.svg)](https://pub.dev/packages/lumide_python) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Powered by SoFluffy](https://img.shields.io/badge/Powered%20by-SoFluffy-orange)](https://sofluffy.io)
4+
5+
The official Python extension for [Lumide IDE](https://lumide.dev).
6+
7+
`lumide_python` provides first-class Python support in Lumide using the `Pyright` language server.
8+
9+
## Features
10+
11+
### 🛠 Language Support
12+
- **IntelliSense**: High-accuracy code completions and type-checking suggestions.
13+
- **Diagnostics**: Real-time linting, errors, and warnings highlighting.
14+
- **Navigation**: Instant go-to-definition, find references, and symbol search.
15+
- **Type Information**: Detailed hover information with documentation links.
16+
17+
### ⚡ Performance
18+
- **Background Analysis**: Runs deep code analysis asynchronously to keep the UI snappy.
19+
- **Project Awareness**: Understands `requirements.txt`, `pyproject.toml`, and virtual environments.
20+
21+
## Commands
22+
23+
Access these via the Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`):
24+
25+
| Command ID | Title | Description |
26+
|---|---|---|
27+
| `lumide_python.restartLsp` | **Python: Restart Language Server** | Restart the `pyright-langserver` process |
28+
29+
## Requirements
30+
31+
- **Python**: A Python environment must be installed.
32+
- **Pyright**: The Microsoft Python language server.
33+
- **Installation**: `npm install -g pyright`
34+
- Ensure `pyright-langserver` is in your system `PATH`.
35+
36+
## License
37+
38+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
39+
40+
---
41+
42+
Built with ❤️ by [SoFluffy](https://sofluffy.io).
43+
44+
## Happy Coding 🦊

analysis_options.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
include: package:lints/recommended.yaml
2+
3+
linter:
4+
rules:
5+
# STYLE: true
6+
camel_case_types: true
7+
camel_case_extensions: true
8+
library_names: true
9+
file_names: true
10+
library_prefixes: true
11+
curly_braces_in_flow_control_structures: true
12+
avoid_field_initializers_in_const_classes: true
13+
prefer_const_constructors: true
14+
prefer_const_declarations: true
15+
directives_ordering: true
16+
unawaited_futures: true
17+
prefer_single_quotes: true
18+
prefer_relative_imports: false
19+
always_use_package_imports: true
20+
21+
# DOCUMENTATION: true
22+
slash_for_doc_comments: true
23+
24+
25+
# USAGE: true
26+
implementation_imports: true
27+
prefer_adjacent_string_concatenation: true
28+
prefer_iterable_whereType: true
29+
unnecessary_lambdas: false
30+
avoid_init_to_null: true
31+
unnecessary_getters_setters: true
32+
prefer_initializing_formals: false
33+
type_init_formals: true
34+
empty_constructor_bodies: true
35+
unnecessary_new: true
36+
unnecessary_const: true
37+
use_rethrow_when_possible: true
38+
avoid_print: true
39+
library_private_types_in_public_api: false
40+
use_build_context_synchronously: false
41+
42+
# DESIGN: true
43+
use_to_and_as_if_applicable: true # prefer
44+
prefer_final_fields: true # prefer
45+
avoid_setters_without_getters: true
46+
avoid_private_typedef_functions: true # prefer
47+
hash_and_equals: true
48+
avoid_null_checks_in_equality_operators: true
49+
50+
formatter:
51+
trailing_commas: preserve

bin/main.dart

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/// Python language support plugin for Lumide IDE.
2+
///
3+
/// Registers Pyright as the language server for Python files.
4+
library;
5+
6+
import 'package:lumide_api/lumide_api.dart';
7+
8+
void main() => PythonPlugin().run();
9+
10+
class PythonPlugin extends LumidePlugin {
11+
static const _logPrefix = '🐍';
12+
static const _defaultLspCommand = 'pyright-langserver';
13+
static const _pluginId = 'python-lsp';
14+
static const _languageId = 'python';
15+
static const _fileExtensions = ['.py', '.pyi'];
16+
static const _restartCommandId = 'lumide_python.restartLsp';
17+
static const _pluginName = 'Python';
18+
static const _lspArgs = ['--stdio'];
19+
20+
String _lspCommand = _defaultLspCommand;
21+
22+
@override
23+
Future<void> onActivate(LumideContext context) async {
24+
log('$_logPrefix $_pluginName plugin activated');
25+
26+
final customPath =
27+
await context.workspace.getConfiguration('$_pluginId.path') as String?;
28+
if (customPath != null && customPath.trim().isNotEmpty) {
29+
_lspCommand = customPath.trim();
30+
}
31+
32+
try {
33+
final checkCommand =
34+
_lspCommand == _defaultLspCommand ? 'pyright' : _lspCommand;
35+
final res = await context.shell.run(checkCommand, ['--version']);
36+
37+
if (res.exitCode != 0) {
38+
if (!res.stderr.contains('Connection input stream is not set')) {
39+
throw Exception('Command not found or failed');
40+
}
41+
}
42+
} catch (e) {
43+
await context.window.showMessage(
44+
'$e',
45+
// '$_lspCommand is not installed. Please install it to enable $_pluginName language support.',
46+
title: _pluginName,
47+
type: MessageType.warning,
48+
);
49+
log('$_logPrefix $_lspCommand not found, aborting');
50+
return;
51+
}
52+
53+
await context.languages.registerLanguageServer(
54+
id: _pluginId,
55+
languageId: _languageId,
56+
fileExtensions: _fileExtensions,
57+
command: _lspCommand,
58+
args: _lspArgs,
59+
);
60+
61+
await context.commands.registerCommand(
62+
id: _restartCommandId,
63+
title: '$_pluginName: Restart Language Server',
64+
category: _pluginName,
65+
callback: ([args]) async {
66+
await context.languages.registerLanguageServer(
67+
id: _pluginId,
68+
languageId: _languageId,
69+
fileExtensions: _fileExtensions,
70+
command: _lspCommand,
71+
args: _lspArgs,
72+
);
73+
await context.window.showMessage(
74+
'$_pluginName language server restarted',
75+
title: _pluginName,
76+
);
77+
},
78+
);
79+
80+
log('$_logPrefix $_pluginName registered for $_languageId files');
81+
}
82+
83+
@override
84+
Future<void> onDeactivate() async {
85+
log('$_logPrefix $_pluginName plugin deactivated');
86+
}
87+
}

plugin.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
id: lumide_python
2+
name: 'Python'
3+
description: 'Python language support for Lumide IDE via Pyright.'
4+
entry_point: 'bin/main.dart'
5+
6+
activation_events:
7+
- 'workspaceContains:*.py'
8+
- 'workspaceContains:requirements.txt'
9+
- 'workspaceContains:pyproject.toml'
10+
11+
permissions:
12+
- shell:
13+
- pyright
14+
- pyright-langserver
15+
- python3
16+
- pip
17+
18+
configuration:
19+
- key: python-lsp.path
20+
type: filePath
21+
title: 'Pyright Executable Path'
22+
description: 'Path to the pyright-langserver executable. If empty, the system PATH will be used.'

pubspec.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: lumide_python
2+
description: "Python extension for Lumide"
3+
version: 1.0.0
4+
homepage: https://lumide.dev
5+
repository: https://github.com/SoFluffyOS/lumide_python
6+
7+
executables:
8+
lumide_python: main
9+
10+
environment:
11+
sdk: '>=3.0.0 <4.0.0'
12+
13+
dependencies:
14+
lumide_api: 1.0.0
15+
16+
dev_dependencies:
17+
lints: ^6.0.0

0 commit comments

Comments
 (0)