A modern web-based code editor with Language Server Protocol (LSP) support for Go, JavaScript, and TypeScript.
- 🚀 Real-time code editing with Monaco Editor
- 🔍 Intelligent code completion, hover information, and go-to-definition
- 🐛 Real-time error diagnostics
- 🌐 WebSocket-based communication
- 📁 Real file system integration (directly maps to workspace directory)
- 🎨 Modern dark theme UI
- 🔧 Support for Go, TypeScript, and JavaScript
Before running the application, make sure you have the following installed:
- Node.js 18+
- npm or yarn
- gopls (Go language server):
go install golang.org/x/tools/gopls@latest - typescript-language-server:
npm install -g typescript-language-server typescript
-
Clone the repository and navigate to the online-editor directory
-
Install dependencies:
npm installThis will install dependencies for both the server and web client.
After installing dependencies, you can quickly start the application:
# Development mode (with hot reload)
npm run dev
# Production mode
npm run build
npm start
# or
./start.shTo run the application in development mode with hot reload:
npm run devThis will start:
- Backend server on
http://localhost:3000 - Frontend dev server on
http://localhost:5173
Open your browser and navigate to http://localhost:5173
To build the application for production:
npm run buildThis will:
- Compile TypeScript code for the backend
- Bundle the frontend application
To start the production server:
npm startThe server will serve the built frontend and handle LSP requests on http://localhost:3000
The server automatically loads environment variables from a .env file in the root directory (see .env.example):
# Server Configuration
PORT=3000
WS_PORT=3000
# Language Server Paths
GOPLS_PATH=gopls
TS_SERVER_PATH=typescript-language-server
# Workspace Configuration
# This is the root directory where all code files will be stored
# The server will directly map to this directory instead of using virtual files
WORKSPACE_ROOT=/tmp/online-editor
# Logging
LOG_LEVEL=infoImportant: Make sure the WORKSPACE_ROOT directory exists and has proper read/write permissions before starting the server.
online-editor/
├── server/ # Backend code
│ ├── src/
│ │ ├── index.ts # Server entry point
│ │ ├── lsp/ # LSP proxy and manager
│ │ ├── fs/ # File system (real and virtual implementations)
│ │ └── transport/ # WebSocket transport
│ └── tests/ # Backend tests
├── web/ # Frontend code
│ ├── src/
│ │ ├── main.ts # Frontend entry point
│ │ ├── editor/ # Monaco Editor integration
│ │ ├── lsp/ # LSP client
│ │ ├── transport/ # WebSocket transport
│ │ └── ui/ # UI components
│ └── tests/ # Frontend tests
└── package.json # Root package.json
Run all tests:
npm testRun unit tests only:
npm run test:unitRun property-based tests only:
npm run test:propertyThe application uses a client-server architecture:
-
Frontend (Browser):
- Monaco Editor for code editing
- LSP Client using
@lewin671/lsp-client - WebSocket Transport for communication
-
Backend (Node.js):
- Express server for HTTP
- WebSocket server for LSP communication
- LSP Proxy to route requests to Language Servers
- Real File System for managing code files directly on disk
- Language Server Manager for lifecycle management
-
Language Servers:
- gopls for Go
- typescript-language-server for TypeScript/JavaScript
Make sure the language servers are installed and in your PATH:
# Check gopls
which gopls
# Check typescript-language-server
which typescript-language-serverIf you see "Disconnected" in the status bar:
- Check that the backend server is running
- Check browser console for WebSocket errors
- Verify the WebSocket URL in the frontend code
If port 3000 or 5173 is already in use, you can change them:
- Backend: Set
PORTin.env - Frontend: Modify
server.portinweb/vite.config.ts
MIT