An Emacs major mode for Uiua, an array programming language.
Since the language’s semantics and syntax are still very much in flux, the mode will change as well. Please report any divergence from the major/minor releases of Uiua as GitHub issues — they are considered bugs.
- Syntax highlighting for all Uiua primitives, glyphs, numbers, and strings
- Auto-formatting on save via
uiua fmt(powered by reformatter) - Run the current buffer with
C-c C-c(uiua run, output in*compilation*) - Standalone compilation with
C-c C-k(uiua stand) - LSP support via Eglot or lsp-mode (see *LSP setup below)
- Quail input method for inserting Unicode glyphs by name (see *Input method)
Users with Emacs 29+ and tree-sitter support should prefer uiua-ts-mode.
Otherwise, install from MELPA:
(use-package uiua-mode
:mode "\\.ua\\'"
:ensure t) ; or :straight t if using straight.elUiua ships a built-in language server (uiua lsp). Configure it once
in your init file — no changes to the package are needed.
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((uiua-mode uiua-ts-mode) . ("uiua" "lsp"))))
(add-hook 'uiua-mode-hook #'eglot-ensure)(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration '(uiua-mode . "uiua"))
(add-to-list 'lsp-language-id-configuration '(uiua-ts-mode . "uiua"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("uiua" "lsp"))
:activation-fn (lsp-activate-on "uiua")
:server-id 'uiua-lsp
:major-modes '(uiua-mode uiua-ts-mode))))
(add-hook 'uiua-mode-hook #'lsp-deferred)uiua-input.el provides a Quail input method for inserting Unicode glyphs
by their ASCII names. Load it and activate it:
(require 'uiua-input) ; or (load "path/to/uiua-input.el")
(add-hook 'uiua-mode-hook
(lambda () (set-input-method "uiua")))Then type \NAME to insert the corresponding glyph. Multi-word names use
hyphens:
| Typed sequence | Inserted glyph |
|---|---|
\not | ¬ |
\fork | ⊃ |
\reduce | / |
\absolute-value | ⌵ |
\inner-product | ⨰ |
To regenerate uiua-input.el after a Uiua release:
emacs --batch --script uiua-input-gen.elSyntax highlighting of various Uiua elements, in flexoki-theme.
