Skip to content

Integrate lua-language-server (LuaLS) with Monaco editor in Electron app#1451

Draft
Copilot wants to merge 3 commits intostablefrom
copilot/integrate-lua-ls-with-monaco
Draft

Integrate lua-language-server (LuaLS) with Monaco editor in Electron app#1451
Copilot wants to merge 3 commits intostablefrom
copilot/integrate-lua-ls-with-monaco

Conversation

Copy link

Copilot AI commented Mar 6, 2026

Wires LuaLS into the Monaco editor so Grid firmware scripts get proper LSP-backed completions, hover docs, and diagnostics — including the full Grid API surface — without adding heavy client-side LSP framework dependencies.

Architecture

Renderer (Monaco)
    │  native WebSocket  ws://127.0.0.1:<dynamic-port>
    ▼
WebSocket proxy  (Electron main)
    │  JSON-RPC over stdio  (LSP wire format)
    ▼
lua-language-server binary
  • No new npm dependencies — proxy uses the existing ws package; renderer uses native WebSocket.
  • Graceful degradation — port 0 disables all LSP features silently (web build, CI without binary download).
  • LuaLS always receives languageId: "lua" regardless of whether the Monaco model is intech_lua or lua.

New files

  • build-scripts/download-lua-ls.js — downloads the platform-appropriate LuaLS binary from GitHub Releases into resources/lua-language-server/. Called automatically before every export:* script.
  • src/electron/src/lua-language-server.ts — spawns LuaLS with --stdio, frames/deframes LSP Content-Length headers, proxies each WS client to its own LuaLS process in an isolated temp workspace.
  • src/renderer/lib/lua-ls-client.ts — lightweight LSP client: initialize handshake, textDocument/did* sync, Monaco provider registration for completions, hover, and diagnostics.
  • src/renderer/assets/lua/annotations/grid.lua — EmmyLua annotation file covering the full Grid API: GridElement class with all element-type methods, all global functions (midi_send, page_load, led_color, …), and self/element[] pre-declarations.

Modified files

  • src/electron/main.ts — starts LuaLS proxy on app.whenReady, stops on before-quit, exposes port via synchronous IPC.
  • src/electron/preload.ts — surfaces window.electron.luaLanguageServer.getPort().
  • src/renderer/lib/monaco.ts — calls initLuaLsClient(port) at module init.
  • electron-builder-config.js — bundles resources/lua-language-server/ as extraResources.
  • package.json — adds download-lua-ls script; prepends it to all export:* pipelines.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 6, 2026 12:50
Co-authored-by: kkerti <47832952+kkerti@users.noreply.github.com>
…iscrimination

Co-authored-by: kkerti <47832952+kkerti@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Lua Language Server integration with Monaco editor Integrate lua-language-server (LuaLS) with Monaco editor in Electron app Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants