nREPL implementation for Hy (Hylang)
Project description
hy-nrepl
hy-nrepl is an implementation of the nREPL protocol for Hy.
hy-nrepl is a fork from HyREPL and has been adjusted to work with the current Hy.
Implemented Operations
from nREPL Built-in Ops
- add-middleware
- clone
- close
- completions
- describe
- eval
- interrupt
- load-file
- lookup
- ls-middleware
- ls-sessions
- stdin
- swap-middleware
Usage
hy-nrepl requires Python >= 3.11 and Hy >= 0.29.0.
To install:
pip install hy-nrepl
To run the server (default port is 7888):
hy-nrepl
# Output debug log and specify port
hy-nrepl --debug 7888
Testing
Install test dependencies, then run pytest:
pip install -e .[test]
pytest tests
Known Issues
Code evaluation is performed in a thread that is not Python's main thread. Therefore, some libraries that expect to be run on the main thread will not work as expected.
- GUI Libraries: Libraries like Tkinter will not function correctly.
- Plotting Libraries: Matplotlib is known to have issues. As an alternative, you can use libraries like Plotly, which work without relying on the main thread.
Confirmed working nREPL clients
Emacs
The following combinations are currently confirmed to work stably.
- hy-mode + Rail
- REPL (Eval and Interruption)
- Symbol completion
- Eldoc (Function arg documentations)
- Jump to source
Emacs Configuration Example
Here is an example configuration for a plain Emacs setup using use-package.
1. Install Rail
This setup uses a forked version of Rail that has been modified to work well with hy-nrepl.
Clone the forked Rail repository from GitHub. This example clones it to the home directory (~/Rail).
git clone [https://github.com/masatoi/Rail.git](https://github.com/masatoi/Rail.git) ~/Rail
2. Configure Emacs
Add the following settings to your Emacs initialization file (e.g., ~/.emacs.d/init.el). This setup assumes you are using package.el and use-package.
;;; Assumes use-package is already installed.
;;; If not, add bootstrap code for package.el and use-package.
(require 'package)
(add-to-list 'package-archives '("melpa" . "[https://melpa.org/packages/](https://melpa.org/packages/)") t)
(package-initialize)
;;; hy-mode (will be installed from MELPA)
;;; jedhy is disabled as Rail provides completion.
(use-package hy-mode
:mode "\\.hy\\'"
:custom (hy-jedhy--enable? nil))
;;; Rail (loaded from the local path)
(use-package rail
:ensure nil
:load-path "~/Rail" ; Must match the path where you cloned Rail
:commands (rail rail-interaction-mode)
:hook ((hy-mode . rail-interaction-mode)
(hy-mode . rail-setup-eldoc)
(rail-mode . rail-setup-eldoc)))
3. How to Connect
-
Start the nREPL server in your terminal. It will listen on
localhost:7888by default.hy-nrepl
-
Connect to the nREPL server from Emacs. Run
M-x rail, and you will be prompted for the host and port. Enter the default value,localhost:7888, and press Enter. This will complete the connection and open a REPL buffer. -
Developing with
.hyfiles. Once connected, opening a.hyfile will automatically enable the minor moderail-interaction-mode. This provides features like:- Evaluating Hy S-expressions within the buffer
- Symbol completion
- Displaying function argument information via Eldoc
-
Interrupting Execution. While an evaluation is running in the REPL buffer, you can interrupt it by pressing
C-c C-c.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hy_nrepl-1.0.4.tar.gz.
File metadata
- Download URL: hy_nrepl-1.0.4.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f244f1a55b8e8570bdbc36f1fd7fcf993b38a106c84054f34468ea9d49b1541
|
|
| MD5 |
0f32c17b19e2a8a68d3145da3e173d8f
|
|
| BLAKE2b-256 |
0f3cd017f6e4690413398dc9da3332112770728c4ea69c3c4d28f89771a55485
|
Provenance
The following attestation bundles were made for hy_nrepl-1.0.4.tar.gz:
Publisher:
release.yaml on masatoi/hy-nrepl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hy_nrepl-1.0.4.tar.gz -
Subject digest:
6f244f1a55b8e8570bdbc36f1fd7fcf993b38a106c84054f34468ea9d49b1541 - Sigstore transparency entry: 380538277
- Sigstore integration time:
-
Permalink:
masatoi/hy-nrepl@a34e88dde2ef4d1d0e208390faa4bce8915496c3 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/masatoi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@a34e88dde2ef4d1d0e208390faa4bce8915496c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hy_nrepl-1.0.4-py3-none-any.whl.
File metadata
- Download URL: hy_nrepl-1.0.4-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
269820f7dd8ee0d14849b968642bbd75e281e32cc14fb743309bf05cf11915fa
|
|
| MD5 |
7fea24969d703c0b29227cc4a3089cea
|
|
| BLAKE2b-256 |
112dd92500b0d5327d22a742feecf1d955f47588cddc0fb861ba7521255a1b6d
|
Provenance
The following attestation bundles were made for hy_nrepl-1.0.4-py3-none-any.whl:
Publisher:
release.yaml on masatoi/hy-nrepl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hy_nrepl-1.0.4-py3-none-any.whl -
Subject digest:
269820f7dd8ee0d14849b968642bbd75e281e32cc14fb743309bf05cf11915fa - Sigstore transparency entry: 380538308
- Sigstore integration time:
-
Permalink:
masatoi/hy-nrepl@a34e88dde2ef4d1d0e208390faa4bce8915496c3 -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/masatoi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@a34e88dde2ef4d1d0e208390faa4bce8915496c3 -
Trigger Event:
push
-
Statement type: