Skip to content

alexaandru/fennel-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fennel-nvim

Yet another Fennel shim for Neovim.

Description

A tiny(iest?) Fennel shim.

I was really curious to see what does it take to do it, specifically: what is the least amount of work you needed to do.

That, and I wanted to write it in Fennel itself, as much as possible 😎

Inspired by Moonwalk.

Design

It adds a fennel loader to package.loaders and it hooks up to SourceCmd for *.fnl so it can resolve :source and :runtime commands. It also adds a caching layer on top of that. That's it.

Usage

Get it in your rtp "somehow" (use your plugin manager, git clone it, whatever) and then load it before you attempt to run any .fnl code. You can see an example of being used here.

Status

What works:

  • require() any <rtp>/fnl/**/*.fnl (from either Lua or Fennel);
  • :source fennel scripts;
  • <rtp>[/after]/plugin/**/*.fnl automatic loading;
  • optional <rtp>/ftplugin/*.fnl filetype plugin loading (see below);
  • all requests are logged to stdpath("cache")/fennel-shim.log, and the logfile is flushed async, every 1s;
  • caching so that the fennel compile price is only paid once.

You can see it in action here, where it loads all my ~700LOC config files, as well as my four plugins and one colorscheme.

Ftplugin support

Support for ftplugin is disabled by default as it is costly. You can enable it by setting vim.g.fennel_shim_ftplugin to either true or any valid pattern for autocmd (see :he {aupat}).

Colorscheme support

The :colorscheme command is hardwired to look for colors/<colorscheme>.{vim,lua} which obviously excludes .fnl files. There is also no event similar to SourceCmd to hook up to. That means one line of lua code is required, to load the rest of the fennel color scheme. See froggy for an example.

Benchmark

It is only 1.1 times slower than Hotpot (which is what I've been previously using). Benchmark was done by running nvim --startuptime x +q 10 times for each. I got a 196ms avg. startup time with Hotpot and 224ms with this shim.

At the same time it is only ~100LOC, not counting blank lines, vs. +6.3KLOC for Hotpot.

Similar Projects

About

Fennel shim for Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published