This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/racket
Benjamin Yang 7f5a53c2ef Racket: actually switch to insert state in REPL
As per the README, `SPC m s B' should put the REPL buffer in insert state, but
the keybinding as defined puts the racket file itself into insert state, not the
REPL.  This means that on returning to the racket file buffer, the cursor is
left in insert state, which means it is easy to accidentally add unwanted text
into the file.

To fix this, a `with-current-buffer' wraps the `evil-insert-state', so that
insert state is enabled in the REPL buffer, not the file being edited.

The first time this is run, `racket-run-and-switch-to-repl' is asynchronous of
`evil-insert-state', so trying to get the Racket REPL buffer will error.  To fix
this problem, we wrap the `with-current-buffer' with a check to determine that
the Racket REPL buffer is live.  The first time the Racket REPL buffer is
created, the contents will not run, since the Racket REPL buffer will not yet be
live.  This is fine, since we enter the REPL in insert state automagically.

This change does not need to be done to `spacemacs/racket-send-last-sexp-focus',
`spacemacs/racket-send-definition-focus', or
`spacemacs/racket-send-region-focus' since these functions follow all of their
racket-send functions with `(racket-repl)' before calling `evil-insert-state'.
2020-06-10 22:55:58 +02:00
..
img
config.el Add racket-xp-mode to Racket layer 2020-05-15 22:58:29 +02:00
packages.el Racket: actually switch to insert state in REPL 2020-06-10 22:55:58 +02:00
README.org

Racket layer

/TakeV/spacemacs/media/commit/1a28a2673847908a8dc1087b51a0fffa9c114d38/layers/+lang/racket/img/racket.png

Description

Adds support for the Racket programming language.

Features:

  • Syntax highlighting with racket-mode
  • Test runner
  • Interactive REPL
  • Code navigation with gtags
  • Structurally safe editing using optional evil-cleverparens

Install

To use this configuration layer, add it to your ~/.spacemacs. You will need to add racket to the existing dotspacemacs-configuration-layers list in this file. You will also need DrRacket installed. Alternatively, one can use the "Minimal Racket" installation, and then run the following command.

  raco pkg install drracket

Structurally safe editing

This layer adds support for evil-cleverparens which allows to safely edit lisp code by keeping the s-expressions balanced.

By default this mode is not activated. You can turn it on locally on the active buffer with SPC m T s (s for safe).

To turn it on automatically for all racket buffers call the following function in your dotspacemacs/user-config function:

  (spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hook-racket-mode)

or to enable it for all supported modes:

  (spacemacs/toggle-evil-safe-lisp-structural-editing-on-register-hooks)

When enabled the symbol 🆂 should be displayed in the mode-line.

Key bindings

Navigation

Key binding Description
SPC m g ` Return to previous location
SPC m g g Go to definition of symbol at point
SPC m g m Go to module at point
SPC m g r Open require path

Documentation

Key binding Description
SPC m h d Describes the function at point in a Racket Describe buffer
SPC m h h View documentation of the identifier or string at point.

Tests

Key binding Description
SPC m t b Run tests of buffer
SPC m t B Run tests of buffer with coverage

REPL

Key binding Description
SPC m s b Send buffer to REPL
SPC m s B Send buffer to REPL and switch to REPL buffer in insert state
SPC m s e Send last sexp to REPL
SPC m s E Send last sexp to REPL and switch to REPL in insert state
SPC m s f Send function at point to REPL
SPC m s F Send function at point and switch to REPL in insert state
SPC m s i Start a REPL or switch to REPL buffer
SPC m s r Send region to REPL
SPC m s R Send region to REPL and switch to REPL in insert state
SPC m s s Show and switch to REPL buffer

Other key bindings

Key binding Description
SPC m i l Insert lambda character
H-r Run current file and open REPL (H is hyper, may be bound to command on macOS)