The Visual Studio Code CodeChat extension

This extension provides CodeChat’s capabilities within the Visual Studio Code editor, as illustrated in the CodeChat System for Visual Studio Code page.

Installation

First, install Visual Studio Code. Next:

  1. Install the CodeChat Server, which performs all the back-end work and is required for the extension to work.

  2. Run CodeChat_Server vscode_install to install and configure the Visual Studio Code CodeChat extension.

  3. (Recommended) switch to a light theme, since the CodeChat System only provides a light theme.

Use

  1. Open a file that CodeChat can render (most source files, along with .rst, .md, and .html files).

  2. Open the Visual Studio Code command palette by pressing Ctrl+Shift+P. Type CodeChat, then press enter to run the extension. After a moment, the rendered file should load. If it doesn’t:

    1. Determine the location of the CodeChat_Server by entering which CodeChat_Server (Linux/OS X) or where CodeChat_Server (Windows) at the terminal/command line.

    2. Open the Visual Studio Code settings for CodeChat by navigating to File > Preferences > Settings then typing CodeChat in the search box. Enter this path for the Code Chat.Code Chat Server: Command. Important: in Windows, replace \ in the location you determined with either \\ or /.

    3. Run the extension again (Ctrl+Shift+P then select CodeChat).

At any time, run the CodeChat extension again (Ctrl+Shift+P, then CodeChat) to show the CodeChat panel, re-start the CodeChat Server if it’s not running, then reconnect with the server. Close the CodeChat panel then run the extension for a more complete reset.

See the CodeChat tutorial for step-by-step instructions on authoring literate programming documents using Sphinx. For other documentation systems, create a project configuration file then place it in the root directory of your project.

Usage tips

Documentation using CodeChat often involves long lines. To wrap lines, enable word wrap.

Remote Development

The VS Code Remote Development toolset allows the CodeChat System to run on another computer. To set this up:

  1. Create an OpenSSH configuration file which forwards the HTTP and websocket ports from the client (where VSCode runs) to the server (where the CodeChat Server and the VSCode extension run). To do this, in VSCode press ctrl+shift+p, then type “Remote-SSH: Open SSH Configuration File…” The contents should include:

    # Replace ``Development_Ubuntu`` with a a user-friendly name for your
    # host here.
    Host Development_Ubuntu
        # Replace this IP with the IP or address of the server to connect
        # to.
        HostName 1.2.3.4
        # Provide the username used to log in to the server.
        User bob
        # Don't change this.
        LocalForward 27377 127.0.0.1:27377
        LocalForward 27378 127.0.0.1:27378
    
  2. Install the CodeChat Server on the server.

  3. (Optional, but highly recommended – it saves a lot of time) Set up SSH key-based authentication.

  4. Connect to the remote host.

Remote containers

This is preliminary. It’s slow to attach this way. I’d prefer to SSH directly to the running container – perhaps this SO post? Even better – find a way to run docker-tools shell before VSCode runs its stuff. Things that don’t work:

  • Adding the following to my SSH config:

    # Taken from `SO <https://unix.stackexchange.com/a/417373>`__. VSCode ignores this, unfortunately.
    RemoteCommand /home/ubuntu/.local/bin/docker-tools shell
    # To avoid the error ``the input device is not a TTY``.
    RequestTTY force
    

    It works as expected from a command prompt, but VSCode seems to ignore it.

  1. Install the Docker for Visual Studio Code extension.

  2. In the setting for that plugin, set docker.host to username@address of the server running Docker.

  3. Set up SSH key-based authentication and make sure the SSH agent is running locally.

Helpful links:

Developer docs

See also the developer docs.