Skip to content

Quick start: Guile (socket)

Ekaitz Zárraga edited this page Jul 6, 2022 · 5 revisions

Guile is designed to help programmers create flexible applications that can be extended by users or other programmers with plug-ins, modules, or scripts.

Conjure connects to a running Guile REPL through a socket file you must specify.

The default Scheme filetype client is conjure.client.mit-scheme.stdio, to use this client instead you must override the configuration.

let g:conjure#filetype#scheme = "conjure.client.guile.socket"

Prerequisites

  • Install the latest Neovim.

  • Ensure your Neovim supports the scheme or scheme.guile filetype. You may need to find a plugin for this! (suggestion).

  • Install the Conjure plugin.

  • Guile - version 2.0 minimum, 3.0 or later preferred.

Start a REPL

First, you need to start your Guile REPL and give it a path to a socket file, this path has to be absolute as far as I can tell. Here’s a script that starts a REPL and places the .socket file in your current repository then cleans up after it exits.

#!/usr/bin/env bash

set -xe

SOCKET=$(git rev-parse --show-toplevel)/.guile-repl.socket
if [ -f $SOCKET ]; then rm $SOCKET; fi
guile --listen=$SOCKET
rm $SOCKET

Connecting to your REPL

Open up a .scm file of your choosing and use :ConjureConnect [path to .socket file]. This path can be relative, unlike the one passed to guile itself. You should now be connected and ready to start evaluating code!

If you’re unsure how to evaluate things with Conjure, please refer to :help conjure, :help conjure-client-guile-socket and :ConjureSchool (an interactive tutorial).

Connecting automatically

If you set the g:conjure#client#guile#socket#pipename variable to a socket file path then Conjure will attempt to connect to that socket file automatically when you first open a .scm file.

You can configure this using a plugin to manage per-project configuration. For example, you’d configure this with nvim-local-fennel by placing the following code in .lnvim.fnl.

(module my-project-name
  {require {nvim nvim-local-fennel.aniseed.nvim}})

(set nvim.g.conjure#client#guile#socket#pipename "guile-repl.socket")

Which would be the following in VimScript.

let g:conjure#client#guile#socket#pipename = "guile-repl.socket"

Now all you have to do is open a .scm file with your REPL running in the background. This will also be used when executing the <prefix>cc mapping, which is useful if you set this up after opening Neovim.