2025-02-19 10:22:27 +00:00
< div align = "center" >
2025-02-19 05:55:33 +00:00
# monaco-editor-lsp-next
2025-02-19 01:00:15 +00:00
2025-03-02 03:39:08 +00:00
✨ A seamless Next.js integration of the Monaco Editor with robust LSP support – all without SSR hassles.
2025-02-19 10:22:27 +00:00
2025-02-20 17:48:34 +00:00

2025-02-20 16:56:03 +00:00
2025-02-19 10:22:27 +00:00
< / div >
2025-03-02 04:20:04 +00:00
## ⚠️ WSL Users: Critical Configuration
2025-02-21 03:25:58 +00:00
2025-03-02 04:20:04 +00:00
### 🐧 Network Mode Requirement
2025-02-21 03:25:58 +00:00
2025-03-02 04:20:04 +00:00
When using Windows Subsystem for Linux (WSL), you **must** configure your network mode as **Mirrored** to ensure proper LSP server connectivity. Standard WSL network configurations may create IPv6 conflicts that block Monaco-LSP communication.
2025-02-21 03:25:58 +00:00
2025-03-02 04:20:04 +00:00
#### 🔧 Mirror Mode Setup:
1. Open WSL settings ⚙️
2. Navigate to **Network** section 🌐
3. Select **Mirrored** mode 🔄
4. Restart WSL instance 💻
2025-02-21 03:25:58 +00:00
2025-03-02 04:20:04 +00:00
Complete these steps before launching the editor for seamless LSP integration! 🎉
2025-02-21 03:25:58 +00:00
2025-03-02 04:20:04 +00:00
## 🚀 Getting Started
2025-02-19 10:22:27 +00:00
2025-03-02 04:20:04 +00:00
### 🐳 Docker Deployment (Recommended)
2025-02-19 01:00:15 +00:00
2025-03-05 08:19:02 +00:00
Deploy the project quickly using pre-built Docker images:
2025-02-19 10:22:27 +00:00
```sh
2025-03-05 08:19:02 +00:00
# Clone the repository
2025-02-19 10:22:27 +00:00
git clone https://github.com/cfngc4594/monaco-editor-lsp-next
cd monaco-editor-lsp-next
2025-02-19 01:00:15 +00:00
2025-03-05 08:19:02 +00:00
# Start the application with pre-built images
docker compose up -d
2025-02-19 10:22:27 +00:00
```
2025-02-19 01:00:15 +00:00
2025-03-05 08:19:02 +00:00
### 🔨 Local Manual Build
Build the images locally and start the containers:
2025-02-19 01:00:15 +00:00
2025-02-19 10:22:27 +00:00
```sh
2025-03-05 08:19:02 +00:00
# Clone the repository
2025-02-19 10:22:27 +00:00
git clone https://github.com/cfngc4594/monaco-editor-lsp-next
cd monaco-editor-lsp-next
2025-02-19 10:29:04 +00:00
2025-03-05 08:19:02 +00:00
# Build and start containers using the local configuration
docker compose -f compose.local.yml up -d --build
```
2025-02-19 10:29:04 +00:00
2025-03-05 08:19:02 +00:00
### 🛠 Development Mode
2025-02-19 10:29:04 +00:00
2025-03-05 08:19:02 +00:00
Set up a development environment with hot-reloading:
```sh
# Clone the repository
git clone https://github.com/cfngc4594/monaco-editor-lsp-next
cd monaco-editor-lsp-next
# Start only the LSP containers
docker compose up -d lsp-c lsp-cpp
# Or use the local configuration
# docker compose -f compose.local.yml up -d --build lsp-c lsp-cpp
# Install dependencies and start the development server
bun install
2025-02-19 10:22:27 +00:00
bun run dev
```
2025-02-19 01:00:15 +00:00
2025-03-02 04:20:04 +00:00
## ⚙️ Technical Configuration
2025-02-19 01:00:15 +00:00
2025-03-02 04:20:04 +00:00
### LSP Server Mapping
2025-02-19 01:00:15 +00:00
2025-03-02 03:39:08 +00:00
| **Language** | **LSP Server** | **Port** |
|--------------|----------------|----------|
| `C` | `clangd` | `4594` |
| `C++` | `clangd` | `4595` |
2025-03-02 04:20:04 +00:00
## 📦 Dependency Management
2025-03-02 03:39:08 +00:00
2025-03-02 04:20:04 +00:00
### 🔒 Version Lock Requirements
2025-03-02 03:39:08 +00:00
2025-03-02 04:20:04 +00:00
**Critical Pairing**:
| Package | Max Version | Reference |
|-------------------------|-------------|-----------|
| `monaco-editor` | ≤0.36.1 | [Compatibility Matrix ](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table ) |
| `monaco-languageclient` | ≤5.0.1 | |
2025-03-02 03:39:08 +00:00
2025-03-02 04:20:04 +00:00
**Version Lock Rationale**:
1. **API Stability**
- Newer `monaco-editor` (≥0.40.0) breaks `monaco-languageclient` integration
- v0.36.1 matches `@codingame/monaco-vscode-api@1.76.9` requirements
2. **LSP Feature Breakdown**
- Version mismatches disable:
- Auto `textDocument/didOpen` events
- `textDocument/inlayHint` resolution
- `textDocument/documentLink` functionality
3. **Version Conflict**
- `@codingame` package versioning (e.g., `11.1.2` ) ≠ `monaco-editor` versions (e.g., `0.36.1` )
- `@monaco-editor/react` depends on `monaco-editor` versioning scheme
**Failure Indicators**:
- ✔️ WebSocket connection established
- ❌ Missing syntax highlighting
- ❌ No autocomplete suggestions
- ❌ Silent LSP initialization failures
### 🎨 Shiki Compatibility Notice
Syntax highlighting depends on `rehype-pretty-code` 's deprecated `getHighlighter` API from `shiki@legacy` .
**Key Points**:
2025-03-05 08:19:02 +00:00
2025-03-02 04:20:04 +00:00
- **Affected File:** `src/components/mdx-preview.tsx`
2025-03-02 03:39:08 +00:00
- **Dependency Chain:** `rehype-pretty-code` → `shiki@legacy`
2025-03-02 04:20:04 +00:00
- **Version Constraints**:
2025-03-05 08:19:02 +00:00
```sh
2025-03-02 03:39:08 +00:00
"shiki": "< =2.5.0"
"@shikijs/monaco": "< =2.5.0"
```
2025-03-02 04:20:04 +00:00
**Maintenance Note**:
While `shiki@3.0.0+` introduces modern APIs (`createHighlighter`/`getSingletonHighlighter`), upgrading requires `rehype-pretty-code` updates. Track progress [here ](https://github.com/atomiks/rehype-pretty-code ).