Skip to content

Commit b854024

Browse files
committed
🦊 Initial support for C/C++ languages
0 parents  commit b854024

8 files changed

Lines changed: 269 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 C/C++ support for Lumide IDE.
6+
- Integrated `clangd` 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_cpp
2+
3+
[![pub package](https://img.shields.io/pub/v/lumide_cpp.svg)](https://pub.dev/packages/lumide_cpp) [![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 C/C++ extension for [Lumide IDE](https://lumide.dev).
6+
7+
`lumide_cpp` provides comprehensive C and C++ language support for Lumide using the `clangd` language server.
8+
9+
## Features
10+
11+
### 🛠 Language Support
12+
- **IntelliSense**: Intelligent code completions and suggestions.
13+
- **Diagnostics**: Real-time error and warning highlighting.
14+
- **Navigation**: Go-to-definition, find-references, and symbol search.
15+
- **Formatting**: Automated code formatting via `clangd`.
16+
17+
### ⚡ Performance
18+
- **Low Latency**: Directly interacts with the `clangd` binary for maximum responsiveness.
19+
- **Resource Efficient**: Only spawns the language server when C/C++ files are active.
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_cpp.restartLsp` | **C/C++: Restart Language Server** | Restart the `clangd` process |
28+
29+
## Requirements
30+
31+
- **Clangd**: Part of LLVM/Clang. Must be installed and available in your system `PATH`.
32+
- **macOS**: `xcode-select --install`
33+
- **Linux**: `sudo apt install clangd`
34+
- **Windows**: Install via LLVM or Visual Studio Installer.
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: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/// C/C++ language support plugin for Lumide IDE.
2+
///
3+
/// Registers clangd as the language server for C and C++ files.
4+
library;
5+
6+
import 'package:lumide_api/lumide_api.dart';
7+
8+
void main() => CppPlugin().run();
9+
10+
class CppPlugin extends LumidePlugin {
11+
static const _logPrefix = '⚙️';
12+
static const _defaultLspCommand = 'clangd';
13+
static const _pluginId = 'cpp-lsp';
14+
static const _languageId = 'cpp';
15+
static const _fileExtensions = [
16+
'.c', '.cpp', '.cc', '.cxx',
17+
'.h', '.hpp', '.hxx',
18+
'.m', '.mm',
19+
];
20+
static const _restartCommandId = 'lumide_cpp.restartLsp';
21+
static const _pluginName = 'C/C++';
22+
23+
String _lspCommand = _defaultLspCommand;
24+
25+
@override
26+
Future<void> onActivate(LumideContext context) async {
27+
log('$_logPrefix $_pluginName plugin activated');
28+
29+
final customPath = await context.workspace.getConfiguration('$_pluginId.path') as String?;
30+
if (customPath != null && customPath.trim().isNotEmpty) {
31+
_lspCommand = customPath.trim();
32+
}
33+
34+
try {
35+
final res = await context.shell.run(_lspCommand, ['--version']);
36+
if (res.exitCode != 0) throw Exception('Non-zero exit code');
37+
} catch (e) {
38+
await context.window.showMessage(
39+
'$_lspCommand is not installed. Please install it to enable $_pluginName language support.',
40+
title: _pluginName,
41+
type: MessageType.warning,
42+
);
43+
log('$_logPrefix $_lspCommand not found, aborting');
44+
return;
45+
}
46+
47+
await context.languages.registerLanguageServer(
48+
id: _pluginId,
49+
languageId: _languageId,
50+
fileExtensions: _fileExtensions,
51+
command: _lspCommand,
52+
);
53+
54+
await context.commands.registerCommand(
55+
id: _restartCommandId,
56+
title: '$_pluginName: Restart Language Server',
57+
category: _pluginName,
58+
callback: ([args]) async {
59+
await context.languages.registerLanguageServer(
60+
id: _pluginId,
61+
languageId: _languageId,
62+
fileExtensions: _fileExtensions,
63+
command: _lspCommand,
64+
);
65+
await context.window.showMessage(
66+
'$_pluginName language server restarted',
67+
title: _pluginName,
68+
);
69+
},
70+
);
71+
72+
log('$_logPrefix $_lspCommand registered for $_pluginName files');
73+
}
74+
75+
@override
76+
Future<void> onDeactivate() async {
77+
log('$_logPrefix $_pluginName plugin deactivated');
78+
}
79+
}

plugin.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
id: lumide_cpp
2+
name: 'C/C++'
3+
description: 'C and C++ language support for Lumide IDE via clangd.'
4+
entry_point: 'bin/main.dart'
5+
6+
activation_events:
7+
- 'workspaceContains:CMakeLists.txt'
8+
- 'workspaceContains:*.cpp'
9+
- 'workspaceContains:*.c'
10+
- 'workspaceContains:*.h'
11+
12+
permissions:
13+
- shell:
14+
- clangd
15+
- cmake
16+
- make
17+
18+
configuration:
19+
- key: cpp-lsp.path
20+
type: filePath
21+
title: 'Clangd Executable Path'
22+
description: 'Path to the clangd 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_cpp
2+
description: "C/C++ extension for Lumide"
3+
version: 1.0.0
4+
homepage: https://lumide.dev
5+
repository: https://github.com/SoFluffyOS/lumide_cpp
6+
7+
executables:
8+
lumide_cpp: 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)