Editor Setup
Sigil provides first-class Emacs support with syntax highlighting, REPL integration, and project commands. Other editors can use the nREPL protocol for basic integration.
Emacs
The sigil.el package provides a complete development environment:
- sigil-mode — Major mode for
.sglfiles - sigil-nrepl — Network REPL client for interactive development
- sigil-transient — Menu for CLI commands
Installation
Add the Sigil editor directory to your load path:
(add-to-list 'load-path "/path/to/sigil/editor/emacs")
(require 'sigil)Or with use-package:
(use-package sigil
:load-path "/path/to/sigil/editor/emacs"
:mode ("\\.sgl\\'" . sigil-mode)
:commands (run-sigil sigil-transient-menu)
:bind (:map sigil-mode-map
("C-c C-z" . sigil-switch-to-repl)
("C-c C-p" . sigil-transient-menu)))[DW] Show an example with the Emacs version that supports package-vc-install in use-package? Was that Emacs 29 or 30?
Key Bindings
Source Buffers
| Key | Command | Description |
|---|---|---|
C-c C-z | sigil-switch-to-repl | Switch to REPL buffer |
C-c C-c | sigil-send-definition | Send current definition to REPL |
C-c C-r | sigil-send-region | Send selected region to REPL |
C-c C-b | sigil-send-buffer | Send entire buffer to REPL |
C-c C-l | sigil-load-file | Load current file in REPL |
C-c C-k | sigil-compile-file | Compile current file |
C-c C-p | sigil-transient-menu | Open project command menu |
C-c C-d d | sigil-describe-symbol | Describe symbol at point |
REPL Buffer
| Key | Command | Description |
|---|---|---|
RET | Send input | Evaluate expression |
C-c C-c | Interrupt | Cancel current evaluation |
M-p / M-n | History | Navigate command history |
Starting the REPL
Use M-x run-sigil to start a Sigil REPL with nREPL support:
- Starts
sigil repl --nreplsubprocess - Connects to the nREPL server
- Opens the REPL buffer
With prefix argument (C-u M-x run-sigil), prompts for port number.
Project Commands
The transient menu (C-c C-p) provides quick access to CLI commands:
┌─────────────────────────────────────┐ │ Sigil │ ├─────────────────────────────────────┤ │ Project │ │ b Build │ │ t Test │ │ r Run task │ ├─────────────────────────────────────┤ │ Code │ │ f Format file │ │ F Format buffer │ ├─────────────────────────────────────┤ │ REPL │ │ i Start REPL │ │ z Switch to REPL │ └─────────────────────────────────────┘
Completion
Symbol completion works automatically via the nREPL connection. Type part of a symbol and use your completion framework (company-mode, corfu, etc.):
;; With company-mode
(add-hook 'sigil-mode-hook #'company-mode)
;; With corfu
(add-hook 'sigil-mode-hook #'corfu-mode)Completion queries the running REPL for available symbols in the current module context.
Multiple Projects
When working with multiple Sigil projects, each source buffer automatically associates with the REPL for its project (based on package.sgl location).
Customization
(setq sigil-program "/path/to/sigil") ; Sigil executable path
(setq sigil-nrepl-default-port 7888) ; Default nREPL portnREPL Protocol
Start the server:
sigil repl --nrepl 7888The protocol uses length-prefixed S-expression messages:
<length:u32-be><sexp>
Request Types
;; Evaluate code
(request :id "1" :op eval :code "(+ 1 2)")
;; Complete symbol
(request :id "2" :op complete :prefix "str")
;; Get documentation
(request :id "3" :op doc :symbol "map")
;; Describe symbol
(request :id "4" :op describe :symbol "cons")
;; Expand macro
(request :id "5" :op macroexpand :code "(when test body)")
;; List modules
(request :id "6" :op modules)
;; Ping
(request :id "7" :op ping)Response Types
;; Success
(response :id "1" :status ok :value "3")
(response :id "2" :status ok :completions ("string?" "string-ref" ...))
;; Error
(response :id "1" :status error :message "unbound variable: x")Terminal REPL
For editors without nREPL support, use the standard REPL in a terminal:
sigil replSend code via terminal integration features.
Vim/Neovim
Basic setup with Scheme syntax:
" In .vimrc or init.vim
autocmd BufRead,BufNewFile *.sgl set filetype=schemeFor REPL integration, consider using a terminal multiplexer (tmux) or a plugin like vim-slime to send code to a running sigil repl.
Configuration Files
Sigil uses package.sgl as the project configuration file. Editors should recognize this for project root detection:
;; Emacs - already built into sigil.el
(defun sigil-project-root ()
(locate-dominating-file default-directory "package.sgl"))