Syntax highlighting, Lisp-aware indentation, and an interactive REPL for editing .sema files, with optional LSP support.
The MELPA recipe (
melpa-recipe) is pending acceptance. Until it lands, use the from-source install below.
Once available on MELPA:
;; M-x package-install RET sema-mode
(package-install 'sema-mode)With use-package:
(use-package sema-mode
:ensure t
:mode "\\.sema\\'")Clone the repo and add it to your load-path:
(add-to-list 'load-path "/path/to/emacs-sema")
(require 'sema-mode)Or, on Emacs 29+, install straight from GitHub with use-package :vc:
(use-package sema-mode
:vc (:url "https://github.com/sema-lisp/emacs-sema" :rev :newest)
:mode "\\.sema\\'")Doom Emacs — in packages.el:
(package! sema-mode
:recipe (:host github :repo "sema-lisp/emacs-sema"))- Syntax highlighting — special forms, standard-library builtins (including the
llm/*,agent/*,conversation/*, andtool/*primitives), keyword literals (:foo), booleans (#t/#f/true/false),nil, character literals, numbers, strings, and;/#| ... |#comments. - Lisp-aware indentation — Sema-specific indent rules layered over
lisp-modeindentation. - REPL integration — start an inferior
semaREPL and send the region, last sexp, or whole buffer to it. - imenu — navigate functions, variables, macros, agents, tools, and record types.
- Electric pairs — auto-close
(),[],{}, and"". - LSP —
sema-moderegisterssema lspwith eglot automatically (M-x eglot); an lsp-mode recipe is below.
-
Emacs 25.1 or newer.
-
The
semabinary on yourPATHfor the REPL,sema-run-file, and LSP. Install it from the Sema project (cargo install sema). Pointsema-programat a non-default location if needed:(setq sema-program "/path/to/sema")
| Key | Command | Description |
|---|---|---|
C-c C-z |
sema-repl |
Start or switch to the Sema REPL |
C-c C-e |
sema-send-last-sexp |
Send sexp before point to REPL |
C-c C-r |
sema-send-region |
Send selected region to REPL |
C-c C-b |
sema-send-buffer |
Send entire buffer to REPL |
C-c C-l |
sema-run-file |
Run current file with sema |
Sema ships with a built-in language server (sema lsp) providing completions,
hover docs, go-to-definition, find references, rename, signature help,
diagnostics, document symbols, and code lens (run expressions).
sema-mode registers the server with eglot automatically — just run M-x eglot
in a .sema buffer. For automatic startup, add:
(add-hook 'sema-mode-hook #'eglot-ensure)(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration '(sema-mode . "sema"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("sema" "lsp"))
:activation-fn (lsp-activate-on "sema")
:server-id 'sema-lsp)))The Sema LSP server also emits a custom
sema/evalResultnotification for inline evaluation results, which requires a custom client handler — see the Sema documentation for details.
The ready-to-submit recipe lives in melpa-recipe. To publish,
open a PR against melpa/melpa adding it as
recipes/sema-mode. Lint locally first:
emacs -Q --batch -f batch-byte-compile sema-mode.el
emacs -Q --batch -l package-lint -f package-lint-batch-and-exit sema-mode.el
emacs -Q --batch --eval '(checkdoc-file "sema-mode.el")'- Website — sema-lang.com
- Playground — sema.run
- Documentation — sema-lang.com/docs
- Grammar — tree-sitter-sema
- Repository — sema-lisp/emacs-sema