~technomancy/fennel-mode

Emacs support for the Fennel programming language
kill the current buffer when killing the REPL if it is a REPL buffer
pick-values doesn't have a body.
Make fennel-repl return the repl buffer

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~technomancy/fennel-mode
read/write
git@git.sr.ht:~technomancy/fennel-mode

You can also use your local clone with git send-email.

#Fennel Mode

Font-lock, indentation, navigation, documentation, and repl support for the Fennel programming language.

Supports M-x imenu for quick navigation to local definitions.

#Installation

Add this to your config:

(autoload 'fennel-mode "/path/to/fennel-mode/fennel-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))

Note that fennel-mode doesn't inherit from lisp-mode since 0.4.0, and instead switched to prog-mode. This means that there is no longer any way to declare shared functionality (such as paredit) that you want applied to every lisp you use; you have to add hooks specifically to fennel-mode-hook.

#Interactivity

Run M-x fennel-repl RET to open a repl buffer. Once a repl is open, you can send code from a fennel-mode buffer to be evaluated.

  • C-c C-z - Start or switch to repl buffer
  • C-c C-e - Evaluate current top-level form
  • C-c C-r - Evaluate the region
  • C-c C-k - Reload the module for the current file (requires fennel.seacher)
  • C-c C-d - Ask for a value and show its docstring in the repl
  • C-c C-a - Ask for a function and show its argument list in the repl
  • C-c C-l - Display compilation output for the current file
  • C-c C-t - Reformat current buffer with fnlfmt (separate install)
  • C-c C-p - Print macro expansion of expression at point in the repl
  • M-. - Jump to the definition of a globally-visible function
  • M-' - Jump to the definition of a function in a module
  • M-, - Jump back to where you were before jumping to definition
  • M-TAB - Completion at point (Fennel 0.9.3+)

These functions assume a fennel executable is present on your path. You can override the location by setting inferior-lisp-program or invoking C-u M-x fennel-repl. For instance, if you have a stdio repl in a LÖVE game, you can set this to love ..

Note that finding the definition of a function with M-. only works when the function is in scope for the repl, which means it's usually best to load a module and set it as a global if you want to use it this way.

#Eldoc support

As of 0.5.0, the eldoc-mode is supported in regular file buffers, meaning that when the connection to the REPL is established, echo area will show known function arglists and variable documentation. In addition to that documentation popup can be displayed if completion frontend supports this feature.

#Antifennel

This repo also contains antifennel.el which allows you to compile Lua code to Fennel straight from a lua-mode buffer. It requires installing antifennel first. Install it with:

(autoload 'antifennel-mode "/path/to/fennel-mode/antifennel.el" nil t)
(add-hook 'lua-mode-hook 'antifennel-mode)

Now when antifennel-mode is active in a Lua buffer, you can press C-c C-f to open a new buffer containing the Fennel equivalent of the Lua code.

#Contributing

Send patches to the Fennel mailing list. If you prefer not to use email you can send a pull request on the Codeberg mirror. Please byte-compile to check for warnings.

Copyright © 2018-2022 Phil Hagelberg and contributors

Licensed under the same license as Emacs (GPL v3 or later); see LICENSE