Skip to content

Proposal: Language Service Implementation (LSP) #1104

Closed

Description

@bummoblizard

Background

Language Service Protocol is a protocol between code editor and a language server that provides code analysis features like autocompletion. Now with the mature local languages and app extension support in Code App, it is time to design and build the architecture necessary to implement LSP features.

Architecture

Server

We would run the language server implementation in an iOS app extension because:

  • Language servers are prone to crashes, especially in a patched, non supported environment, we do not want the whole app to crash when they encountered errors
  • Language runtime interferes with each other in a single process

This implies the language server must keep its memory usage low (~120MB). Careful configuration and crash recovery are necessary.

Websocket endpoints:

  • lsp/{language_identifier}: Request to start language server
  • execution/: Request to start code execution

Requests are then accepted / rejected subject to resources availability. If accepted, stream stdio over web socket.

Client

Use monaco-languageclient to connect monaco editor to LSP using WebSocket.

async function connectMonacoToLanguageServer(languageIdentifier, serverURL) {}

async function disconnectLanguageServer(languageIdentifier?) {}

function languageServerConnectionDidDrop(languageIdentifier) {}

(To be added..)

TODOs:

  • Design the editor-server communication protocol
    • WebSocket or Posix socket?
    • When to start or stop a language server?
    • What to do when user requests code execution when there can only be one runtime instance? (Java, Node.js)
    • What to do with multiple scene? A language server serves one editor at a time.
  • Build the client using monaco-languageclient
  • Build the server
    • A web socket server that redirects stdio/stdin in ios_system / main thread
    • Implementation of any crash recovery protocol
    • Integration of the actual language servers

Some candidates of language server to integrate:

Activity

  1. pinned this issue on Jul 1, 2024
  2. added a commit that references this issue on Aug 16, 2024
  3. bummoblizard commented on Aug 17, 2024

    @bummoblizard
    MemberAuthor

    Python / Java Intellisense is now available in our latest TestFlight build.

  4. valdo404 commented on Aug 28, 2024

    @valdo404

    Hi, I would like to share my thoughts on this task.

    currently the ipad does not have a real good capability to support many languages and their tools.

    I guess combining codeapp with cloud launched lsp servers for indexing, crawling, compiling, and debugging large software projects would be quite interesting.

    as such I think the lsp server shouldn't be local but launched on the cloud.

    I'm about to clone this project to test the idea of launching actions on a cloud based project (with a local mirror that is using file synchronisation)

    best

  5. KagaJiankui commented on Sep 26, 2024

    @KagaJiankui

    Hope to see markdown and clangd language server integrated with the CodeApp, and a outline sidebar like that in VSCode.

    By the way, cloud-based language server may suffer from lagging and disconnection problems under many edge scenarios, for example on mobile traveling and in less connected areas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions