Skip to content

Olical/nvim-local-fennel

Repository files navigation

nvim-local-fennel

This has been superseded! I now recommend installing Olical/nfnl and enabling the exrc option in order to have directory local Neovim configuration in Fennel.

Once you have nfnl and a .nfnl.fnl file at the root of your project you can write to .nvim.fnl and have .nvim.lua compiled for you automatically. This file is loaded by native Neovim with zero plugins provided you have :set exrc enabled.

This means even colleagues that don’t have nfnl installed can use your directory local configuration. Consider this repo as essentially archived and superseded by this much smoother approach.

Run Fennel inside Neovim on startup with Aniseed.

Add some Fennel code such as (print "Hello, World!") to a file named .lnvim.fnl in your current directory or anywhere above it such as your home directory. A file will be created beside the .fnl called .lnvim.lua which will be executed upon startup. Files higher up in your directory hierarchy, such as the home directory, will be executed before those found lower down, such as in a project.

Be sure to git ignore .lnvim.fnl and .lnvim.lua if you don’t want to share your local configuration with others. If you do want to share a .lnvim.fnl I’d recommend you ignore the .lua file to prevent duplicated changes in git commits.

Aniseed will only re-compile the Fennel code if it’s changed since last time you opened Neovim. If you delete the .lnvim.fnl file then the .lnvim.lua file will be deleted automatically next time you launch Neovim to ensure you don’t accidentally leave Lua files laying around.

Installation

If you want interactive evaluation of the forms in your .lnvim.fnl file you can install Conjure too.

use 'Olical/nvim-local-fennel'
use 'Olical/aniseed'
Plug 'Olical/nvim-local-fennel'
Plug 'Olical/aniseed'

Access to Aniseed

Aniseed is embedded under the nvim-local-fennel.aniseed.* module prefix, this means you can use Aniseed’s macros and functions in your .lnvim.fnl files!

;; .lnvim.fnl
;; You can give the module any name you want.
(module my-local-fennel
  {autoload {a nvim-local-fennel.aniseed.core
             str nvim-local-fennel.aniseed.string
             nvim nvim-local-fennel.aniseed.nvim}})

;; A hyphen suffix denotes a private function.
(defn- do-some-things [numbers]
  (a.println
    (nvim.fn.getcwd)
    (a.map a.inc numbers)
    {:Hello :Fennel!}))

;; Public value.
;; You could require this module and access it.
(def counting [1 2 3])

;; Executed as the file is loaded.
(do-some-things counting)

Unlicenced

Find the full unlicense in the UNLICENSE file, but here’s a snippet.

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.