Skip to content
hy-emacs logo

hy-emacs - Hylang Emacs Integration

hy-emacs

Hylang Emacs integration with hy-mode, Hyuga LSP, and DisCoPy sexp coloring

plurigrid/asi0installs67stars

SKILL.md

Full skill instructions

hy-emacs - Hylang Emacs Integration

Trit: 0 (ERGODIC - Coordinator)

Complete Hy development environment for Emacs with LSP, REPL, and deterministic sexp coloring via Gay.jl patterns.

Overview

┌─────────────────────────────────────────────────────────────────┐
│                    Hy → Emacs → LSP Pipeline                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│   .hy files                 Hyuga LSP              Gay.jl       │
│      │                         │                      │         │
│      ▼                         ▼                      ▼         │
│  ┌────────┐    ┌───────────────────────────┐    ┌──────────┐   │
│  │hy-mode │───▶│ completion, diagnostics,  │───▶│ rainbow  │   │
│  │ (MELPA)│    │ hover, go-to-definition   │    │ parens   │   │
│  └────────┘    └───────────────────────────┘    └──────────┘   │
│      │                         │                      │         │
│      │         jedhy           │                      │         │
│      ▼         (IDE)           ▼                      ▼         │
│  ┌────────┐    ┌───────────────────────────┐    ┌──────────┐   │
│  │hy-shell│───▶│ company-mode, eldoc-mode  │───▶│ depth→   │   │
│  │ (REPL) │    │ hy-describe-thing-at-pt   │    │ color    │   │
│  └────────┘    └───────────────────────────┘    └──────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Triadic Structure

RoleComponentTritFunction
Validatorslime-lisp-1Common Lisp reference semantics
Coordinatorhy-emacs0Hy ↔ Python ↔ Emacs bridge
Generatorgeiser-chicken+1Scheme REPL with SplitMixTernary

GF(3) Conservation: slime-lisp (-1) ⊗ hy-emacs (0) ⊗ geiser-chicken (+1) = 0 ✓

Installation

1. Install Hyuga LSP

# Via pipx (recommended)
pipx install hyuga

# Or pip in venv
pip install hyuga

# Verify
hyuga --version  # Should show 1.0.0+

2. Install hy-mode (Emacs)

;; From MELPA
M-x package-install RET hy-mode RET

;; Install jedhy for IDE features
;; In your Python environment:
;; pip install jedhy

3. Configure lsp-mode

;; ~/​.emacs.d/​init.el or ~/​.doom.d/​config.el

(use-package hy-mode
  :ensure t
  :mode "\\.hy\\'"
  :hook ((hy-mode . company-mode)
         (hy-mode . eldoc-mode)
         (hy-mode . rainbow-delimiters-mode))
  :config
  (setq hy-jedhy--enable? t))

;; LSP via Hyuga
(use-package lsp-mode
  :ensure t
  :hook (hy-mode . lsp-deferred)
  :config
  ;; Register Hy language
  (add-to-list 'lsp-language-id-configuration '(hy-mode . "hy"))
  
  ;; Register Hyuga client
  (lsp-register-client
   (make-lsp-client
    :new-connection (lsp-stdio-connection "hyuga")
    :activation-fn (lsp-activate-on "hy")
    :server-id 'hyuga
    :priority -1)))

;; Rainbow delimiters with Gay.jl colors
(use-package rainbow-delimiters
  :ensure t
  :config
  (setq rainbow-delimiters-max-face-count 12)
  ;; Gay.jl golden angle palette
  (custom-set-faces
   '(rainbow-delimiters-depth-1-face ((t (:foreground "#FF6B6B"))))  ; 0°
   '(rainbow-delimiters-depth-2-face ((t (:foreground "#4ECDC4"))))  ; 137.5°
   '(rainbow-delimiters-depth-3-face ((t (:foreground "#FFE66D"))))  ; 275°
   '(rainbow-delimiters-depth-4-face ((t (:foreground "#95E1D3"))))  ; 52.5°
   '(rainbow-delimiters-depth-5-face ((t (:foreground "#F38181"))))  ; 190°
   '(rainbow-delimiters-depth-6-face ((t (:foreground "#AA96DA"))))  ; 327.5°
   '(rainbow-delimiters-depth-7-face ((t (:foreground "#FCBAD3"))))  ; 105°
   '(rainbow-delimiters-depth-8-face ((t (:foreground "#A8D8EA"))))  ; 242.5°
   '(rainbow-delimiters-depth-9-face ((t (:foreground "#FFFFD2"))))  ; 20°
   '(rainbow-delimiters-depth-10-face ((t (:foreground "#B5EAEA")))) ; 157.5°
   '(rainbow-delimiters-depth-11-face ((t (:foreground "#EAB5E2")))) ; 295°
   '(rainbow-delimiters-depth-12-face ((t (:foreground "#C9E4CA")))))); 72.5°

Doom Emacs Configuration

;; ~/​.doom.d/​packages.el
(package! hy-mode)
(package! rainbow-delimiters)

;; ~/​.doom.d/​config.el
(use-package! hy-mode
  :mode "\\.hy\\'"
  :config
  (setq hy-jedhy--enable? t)
  
  ;; LSP
  (after! lsp-mode
    (add-to-list 'lsp-language-id-configuration '(hy-mode . "hy"))
    (lsp-register-client
     (make-lsp-client
      :new-connection (lsp-stdio-connection "hyuga")
      :activation-fn (lsp-activate-on "hy")
      :server-id 'hyuga))))

(add-hook! 'hy-mode-hook
  #'rainbow-delimiters-mode
  #'lsp!)

Spacemacs Layer

;; ~/​.spacemacs.d/​layers/​hy/​packages.el
(defconst hy-packages '(hy-mode rainbow-delimiters))

(defun hy/​init-hy-mode ()
  (use-package hy-mode
    :mode "\\.hy\\'"
    :init
    (add-hook 'hy-mode-hook #'lsp)
    :config
    (spacemacs/​set-leader-keys-for-major-mode 'hy-mode
      "'" 'hy-shell-start-or-switch-to-shell
      "sb" 'hy-shell-eval-buffer
      "sr" 'hy-shell-eval-region
      "sf" 'hy-shell-eval-current-form)))

UREPL Integration

Connect Hy to the unified REPL coordinator:

;; hy-urepl-bridge.el

(defun hy-urepl-eval (code)
  "Send Hy code to UREPL coordinator."
  (let ((msg `(:type :eval
               :lang :hy
               :code ,code
               :timestamp ,(float-time))))
    (urepl-send-message msg)))

(defun hy-urepl-connect ()
  "Connect to UREPL server."
  (interactive)
  (setq urepl-connection
        (open-network-stream "urepl" "*urepl*" "localhost" 7888))
  (message "Connected to UREPL"))

;; Integration with hy-mode
(defun hy-eval-to-urepl ()
  "Evaluate current form via UREPL."
  (interactive)
  (let ((code (hy-shell--current-form-string)))
    (hy-urepl-eval code)))

(define-key hy-mode-map (kbd "C-c C-u") #'hy-eval-to-urepl)

DisCoPy Sexp Coloring

For categorical diagram coloring in Hy files:

;; discopy-hy-colors.el

(defun discopy-color-sexp (depth)
  "Return Gay.jl color for sexp at DEPTH."
  (let* ((golden-angle 137.508)
         (hue (mod (* depth golden-angle) 360))
         (sat 0.7)
         (lum 0.55))
    (color-hsl-to-rgb (/ hue 360.0) sat lum)))

(defun discopy-fontify-sexps ()
  "Apply DisCoPy coloring to all sexps in buffer."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((depth 0))
      (while (not (eobp))
        (cond
         ((looking-at "(")
          (let ((color (discopy-color-sexp depth)))
            (put-text-property (point) (1+ (point))
                               'face `(:foreground ,color)))
          (setq depth (1+ depth)))
         ((looking-at ")")
          (setq depth (max 0 (1- depth)))
          (let ((color (discopy-color-sexp depth)))
            (put-text-property (point) (1+ (point))
                               'face `(:foreground ,color)))))
        (forward-char)))))

(add-hook 'hy-mode-hook
          (lambda ()
            (add-hook 'after-change-functions
                      (lambda (&rest _) (discopy-fontify-sexps))
                      nil t)))

Ruler Configuration

Add to .ruler/​ruler.toml:

[mcp_servers.hyuga]
command = "hyuga"
args = []
env = { HYRULE_MACROS = "true" }
description = "Hy Language Server for DisCoPy/​ACSet sexp files"

[lsp.hy]
server = "hyuga"
filetypes = ["hy"]
root_markers = ["pyproject.toml", ".git", "setup.py"]

Commands

# Start Hy REPL
just hy-repl

# Run Hy file
just hy-run lib/​discohy.hy

# Check Hy syntax
just hy-check lib/​*.hy

# Generate colors for Hy file
just hy-colors lib/​discohy.hy

# Connect to UREPL
just urepl-hy

Project Files

Your project has 24 Hy files in lib/:

FilePurpose
discohy.hyDisCoPy + ACSet sexp traversal
discohy_world.hyWord → World model bridges
discohy_thread_operad.hyThread operad composition
interaction_entropy.hyEntropy-driven interleaving
gay_world_ducklake.hyDuckDB + Gay.jl colors
thread_duckdb_bridge.hyThread ↔ DuckDB persistence

GF(3) Triads

# Lisp REPL Bundle
slime-lisp (-1) ⊗ hy-emacs (0) ⊗ geiser-chicken (+1) = 0 ✓

# Emacs Tool Bundle  
xenodium-elisp (-1) ⊗ hy-emacs (0) ⊗ cider-clojure (+1) = 0 ✓

# DisCoPy Integration Bundle
three-match (-1) ⊗ hy-emacs (0) ⊗ gay-mcp (+1) = 0 ✓

# LSP Configuration Bundle
polyglot-spi (-1) ⊗ hy-emacs (0) ⊗ gay-mcp (+1) = 0 ✓

Key Bindings

KeyCommandDescription
C-c C-zhy-shell-start-or-switchStart/​switch to REPL
C-c C-chy-shell-eval-current-formEval form at point
C-c C-bhy-shell-eval-bufferEval entire buffer
C-c C-rhy-shell-eval-regionEval selected region
C-c C-dhy-describe-thing-at-pointShow documentation
C-c C-uhy-jedhy-update-importsUpdate jedhy imports
M-.lsp-find-definitionGo to definition
M-?lsp-find-referencesFind references

See Also

  • geiser-chicken - Scheme REPL with SplitMixTernary
  • slime-lisp - Common Lisp REPL
  • cider-clojure - Clojure nREPL
  • xenodium-elisp - Modern Emacs packages
  • discohy-streams - DisCoPy categorical streams
  • uv-discohy - UV toolchain for DiscoHy

Dependencies

python:
  - hy >= 1.0.0
  - hyuga >= 1.0.0
  - jedhy >= 0.1.0
  - hyrule >= 0.7.0

emacs:
  - hy-mode (MELPA)
  - lsp-mode (MELPA)
  - rainbow-delimiters (MELPA)
  - company (MELPA)

Scientific Skill Interleaving

This skill connects to the K-Dense-AI/​claude-scientific-skills ecosystem:

Graph Theory

  • networkx [○] via bicomodule
    • Universal graph hub

Bibliography References

  • general: 734 citations in bib.duckdb

Cat# Integration

This skill maps to Cat# = Comod(P) as a bicomodule in the equipment structure:

Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826

GF(3) Naturality

The skill participates in triads satisfying:

(-1) + (0) + (+1) ≡ 0 (mod 3)

This ensures compositional coherence in the Cat# equipment structure.

More skills from plurigrid

cargo logo
plurigrid/asi

cargo

Rust package manager (36 subcommands).

67 0
View

Translate Figma nodes into production-ready code with 1:1 visual fidelity using the Figma MCP workflow (design context, screenshots, assets, and project-convention translation). Trigger when the user provides Figma URLs or node IDs, or asks to implement designs or components that must match Figma...

67 0
View

**Status**: 🌳 Production Ready (upstream in StringZilla v3+) **Type**: High-Performance String Operations / SIMD-Accelerated Text Processing **Principle**: Zero-copy views, SIMD/SWAR acceleration, deterministic hashing **Frame**: Cross-language interoperability (C, C++, Python, Rust, Go, Swift, ...

67 0
View
conformal-ga logo
plurigrid/asi

conformal-ga

Conformal Geometric Algebra (CGA) for circles, spheres, and Möbius transformations

67 0
View

Verifies code implements exactly what documentation specifies for blockchain audits. Use when comparing code against whitepapers, finding gaps between specs and implementation, or performing compliance checks for protocol implementations.

67 0
View
zig-systems logo
plurigrid/asi

zig-systems

Systems programming and performance optimization using Zig. Provides low-level abstractions, memory-safe compiled code, and performance benchmarking. Use for system-level operations, optimization, and interoperability with C/POSIX APIs.

67 0
View
paypal-mcp logo
plurigrid/asi

paypal-mcp

PayPal MCP server integration for invoices, payments, subscriptions, disputes, and transaction reporting via @paypal/mcp.

67 0
View
unison logo
plurigrid/asi

unison

Unison language - content-addressed functional programming with abilities for effects, distributed computing, and structural types. Use for pure functional code, effect management, distributed systems, and refactoring-safe codebases.

67 0
View
tasks-acset logo
plurigrid/asi

tasks-acset

Google Tasks management via TasksACSet. Transforms task operations into GF(3)-typed Interactions, routes to triadic queues, detects saturation for task-zero-as-condensed-state.

67 0
View
c logo
plurigrid/asi

c

World C Skill

67 0
View
syrup logo
plurigrid/asi

syrup

Syrup binary serialization for OCapN/CapTP wire format. Canonical encoding for capability messages.

67 0
View
skill-installer logo
plurigrid/asi

skill-installer

Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).

67 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View