| nael | [readme] nael-lsp is now on melpa too | |
| nael-lsp | [lsp] capitalize synopsis | |
| .dir-locals.el | [dir-locals] remove jinx-dir-local-words | |
| .gitignore | [build] build info manuals and re-add them to git, for melpa users | |
| build.el | [nael] add SPDX-License-Identifier where missing | |
| LICENSE | fork notes; license notes and files; library headers; file renamings | |
| README.org | [readme] nael-lsp is now on melpa too | |
Nael — An Emacs major mode for Lean
Nael is a set of packages that extend GNU Emacs for the Lean language. It is a radically refactored fork of Lean4-Mode with focus on simplicity, modularity and integration into Emacs' core.
The nael package defines the major mode. It also introduces simple and two-sided abbreviations per Abbrev and Skeleton respectively. It teaches Emacs' built-in LSP client Eglot about Lean-specific LSP-extensions and tells ElDoc to display that information, similar to the "info view" in vscode-lean that many are familiar with. Similarly, the separate package nael-lsp may be installed when lsp-mode is preferred as LSP client.
Get Started
To install Nael the easy way, first set up Melpa as package-archive, then type M-x package-install RET nael RET. For more detailed instructions, consult the Installation chapter below.
Usage
Language Server Protocol (LSP):
C-c C-e(eglot) starts Eglot, the LSP client.C-h .(eldoc-doc-buffer) displays the ElDoc documentation buffer showing tactic state and expected goal at point.C-c C-l(lsp) starts lsp-mode, an alternative LSP client. The key is only bound ifnael-lspis (auto)loaded.
Abbreviations:
C-c C-a(abbrev-mode) enables abbreviations.C-c C-k(nael-abbrev-help) echoes abbreviations that expand to the character at point, or, if active, to the selected region.C-x '(expand-abbrev) expands the abbreviation before point without any inserting any character. (Usually, you'd insert a space or newline to expand.)
Build:
C-c C-c(project-compile) prompts for a command to build the current project. It will suggestlake buildbecause Nael configures thecompile-commandvariable.
Navigation:
M-a(forward-sentence) go to beginning of current sentence/block, or to previous one.M-e(backward-sentence) go to end of current sentence/block, or to next one.M-g i(imenu) jumps to an interactively chosen definition in current buffer.
Comments:
M-;(comment-dwim) toggles the active region as comment or, if no region is active, creates a comment at end of line.M-q(prog-fill-reindent-defun) fills the string- or comment-paragraph at point, or reindents the point-surrounding code.
Configuration
To view the complete list of Nael's user option variables from within Emacs, customize the group nael (and its child-groups) with M-x customize-group RET nael RET. This chapter highlights and elaborates on some of them.
As an exception, Emacs customization groups cannot include keymaps. You can bind custom keys in nael-mode-map like this:
(keymap-set nael-mode-map "C-c ." #'highlight-symbol-at-point)
To automatically enable features (e.g. abbreviations, Eglot or lsp-mode) when Nael is started, customize nael-mode-hook as follows:
(add-hook 'nael-mode-hook #'abbrev-mode)
(add-hook 'nael-mode-hook #'eglot-ensure)
Nael's Abbrev tables use the :regexp property which is incompatible with Company's company-abbrev and Cape's cape-abbrev. Instead, Nael supports completion-at-point natively via nael-abbrev-capf. This CAPF is buffer-locally added to completion-at-point-functions whenever Abbrev mode is enabled inside Nael. To ditch this feature, set the nael-abbrev-capf variable to nil.
Installation
Nael's LSP-based features (via Eglot or lsp-mode), require Lean version 4 to be installed.
Installation from Melpa
nael and nael-lsp packages are available on Melpa (and Melpa-Stable). To install, first add the package-archive by adding this code to your Emacs initialization file and evaluating it interactively.
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
Then type M-x package-refresh-contents RET. Finally, choose one of the following approaches: ⦿ To install interactively, type M-x package-install RET nael RET. ⦿ To install via package selection, add (setopt package-selected-packages '(nael)) to your init file, evaluate it, and type M-x package-install-selected-packages RET. ⦿ To install via Use-Package, add (use-package nael :ensure t) to your init file and evaluate it.
Installation from Sources
When installing nael-lsp from sources, lsp-mode might not be pulled in and installed as dependency automatically, i.e. you might need to install it manually beforehand.
Manual Installation
First clone the Git repository, then, in your Emacs initialization file, add Nael to load-path and load it. For lazy loading the autoloads-file needs to be build beforehand.
;; git clone https://codeberg.org/mekeor/nael.git ~/path/to/nael
(add-to-list 'load-path "~/path/to/nael/nael")
;; (add-to-list 'load-path "~/path/to/nael/nael-lsp")
;; Option 1, eager loading:
(require 'nael)
;; (require 'nael-lsp)
;; Option 2, lazy loading:
;; cd ~/path/to/nael && ./build.el autoloads
;; (require 'nael-autoloads)
;; (require 'nael-lsp-autoloads)
;; Optionally, make readme available as info manual:
(require 'info)
(info-initialize)
(add-to-list 'Info-directory-list "~/path/to/nael/nael")
Installation via package-vc
Since version 29 from 2023, Emacs ships with package-vc which enables the built-in package manager package to install from version-controlled source repositories. Keep in mind to regularly upgrade such packages with the command package-vc-upgrade or package-vc-upgrade-all. (And please ignore the warnings that arise when package-vc attempts to byte-compile all Elisp source files in the repository instead of just the package-specific ones.)
Installation via package-vc-selected-packages
In your Emacs session, select packages per package-vc-selected-packages variable and install them with M-x package-vc-install-selected-packages RET. Persist the package selection in your Emacs initialization file too. package-vc will generate the autoloads-file automatically. To lazy-load Nael, load the autoloads-file.
(require 'package-vc)
(setopt package-vc-selected-packages
'((nael
:doc "nael/README.org"
:lisp-dir "nael"
:url "https://codeberg.org/mekeor/nael.git")
;; (nael-lsp
;; :lisp-dir "nael-lsp"
;; :url "https://codeberg.org/mekeor/nael.git")
))
(package-initialize)
;; Option 1, lazy loading:
(require 'nael-autoloads)
;; (require 'nael-lsp-autoloads)
;; Option 2, eager loading:
;; (require 'nael)
;; (require 'nael-lsp)
Installation via use-package :vc
Since version 30 from 2025, Emacs' popular use-package macro supports a :vc keyword as interface to package-vc. (Because each package has autoload-cookies on relevant expressions, and because use-package will load the autoloads-file that is generated at installation, you don't need to specify load-triggers like :mode. I.e. lazy-loading should work out of the box.)
(use-package nael
:vc ( :doc "nael/README.org"
:lisp-dir "nael"
:url "https://codeberg.org/mekeor/nael.git"))
;; (use-package nael-lsp
;; :after nael
;; :vc ( :lisp-dir "nael-lsp"
;; :url "https://codeberg.org/mekeor/nael.git"))
Changelog
Version 0.7.0 from 2025年12月15日
- Remove the
nael-markdownpackage. Move its code intonaelpackage instead. (Wrapped intowith-eval-after-load.) naelis now on Melpa and Melpa-Stable.nael-lspis not there yet.
Version 0.6.2 from 2025年11月30日
- Re-add readme as .texi and .info to repository because Nael might soon be added to Melpa which won't build Info manuals itself.
Version 0.6.0 from 2025年11月30日
- Remove .texi, .info, and -autoloads.el files from repository. Thus, don't load autoloads-files from other Elisp sources. This makes Nael compatible with package-vc.
- build.el: Only build files/targets passed as command-line arguments. Valid arguments are abbreviations, autoloads, compile, info and root-readme.
- dir-locals.el: Remove an assignment of a non-core Emacs variable which lead to Emacs asking for confirmation.
- README: Provide installation instructions via package-vc-selected-packages and use-package :vc.
- Add several autoload-cookies. This allows for simpler use-package expressions.
- README: Add changelog chapter.
-
nael, nael-abbrev:
- Rename nael-abbrev-table-only-singletons to nael-abbrev-singleton-table.
- Rename nael-abbrev-table-only-skeletons to nael-abbrev-skeleton-table.
License and Maintenance
Nael is effectively licensed under GNU GPL version 3 only. More precisely, it is licensed under Apache-2.0 and sublicensed under GPL-3.0.
Nael is maintained by Mekeor Melire (mekeor@posteo.de) on Codeberg.