Skip to content

Latest commit

 

History

100 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://img.shields.io/badge/license-GPL_3-green.svg https://melpa.org/packages/uiua-mode-badge.svg https://github.com/crmsnbleyd/uiua-mode/actions/workflows/ci.yml/badge.svg

uiua-mode

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.

Features

  • 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)

Setup

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.el

LSP setup

Uiua ships a built-in language server (uiua lsp). Configure it once in your init file — no changes to the package are needed.

Eglot (built-in, Emacs 29+)

(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)

lsp-mode

(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)

Input method

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 sequenceInserted glyph
\not¬
\fork
\reduce/
\absolute-value
\inner-product

To regenerate uiua-input.el after a Uiua release:

emacs --batch --script uiua-input-gen.el

Screenshots

Syntax highlighting of various Uiua elements, in flexoki-theme.

https://github.com/crmsnbleyd/uiua-mode/blob/main/assets/uiua-example.png

About

Emacs mode for uiua, a stack-based array language

Topics

Resources

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages