Skip to content

Preparing Neovim Config release

Preparing the first major release of Practicalli nvim-astro5

Submitted 4 pull requests to Astrocommunity last week, to support the new config and keep it nice and light.

Received a request to add Babashka file support to Practicalli nvim-astro5

For some user acceptance testing work I did a few weeks ago, I received a nice sized Amazon gift card. To give me more ways to keep healthy, I spent some of the money on parts and upgrades to my Brompton folding bike.

Neovimλ︎

Practicalli Nvim-Astro5 planning board

Practicalli nvim-astro5

Babashka supportλ︎

After posting an update on the new Practicalli Astro5 I had a suggestion to add Babashka file support.

Neovim detects Babashka *.bb files as BitBake files by default, so Babashka files do not get any of the tools available for a Clojure file.

After 🎫 lots of different experiments with lua I discovered Neovim had a way to set the filetype for a filename extension, by defining a ftdetect/bb.vim file.

Filetype was previous approach although was replaced by a more scalable approach

Neovim filetypes - clojure

Manually set the filetype for the buffer

Whist this may support syntax highlighting, completion does not seem to work.

:bufdo setfiletype clojure

Fallback: match on file contents

Check the first line of the file for a babashka shell command

vim.filetype.add({
  pattern = {
    [".*"] = {
      function(_, bufnr)
        local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ""
        if vim.startswith(content, "#!/usr/bin/env bb") then
          return "clojure"
        end
      end,
      { priority = -math.huge },
    },
  },
})

Running Lua codeλ︎

Neovim can be used to run a stand-alone lua file.

Determine Operating System architecture

os-name.lua
#!/usr/bin/env -S nvim -l

local osarch = vim.uv.os_uname().machine
vim.print(osarch)

nvim has an -l flag that will run a lua script non-interactively (no Neovim UI), with

Run Lua from file

nvim -l os-name.lua

Adding a shell shebang to the file allow the script to be executed directly on the command line

Executable Lua script

os-name.lua
#!/usr/bin/env -S nvim -l

local osarch = vim.uv.os_uname().machine
vim.print(osarch)

Add execution permissions to the file name

chmod a+x os-name.lua

Run the lua script from the command line shell

./os-name.lua

Use the :source command to run lua script from the Neovim UI.

The script will need to be updated to show the result within neovim, e.g. in a notification.

Run Neovim with a specific configuration file

Neovim can use the -U flag to run with a minimal configuration, e.g. when troubleshooting configuration and plugins

Reditλ︎

I finally bit the bullet and signed up to Reddit. It can be useful to see new things that arent mentioned in the Clojurians Slack.

I do take a lot of comments and some posts with a bit pinch of salt (pragmatic scepticism)

Ask Anything April 14 2025λ︎

I saw a commonly asked question 🌐 this week:

Given Clojure's Lisp-style syntax and dynamic typing, do you find that it becomes harder to maintain and refactor code in larger projects or teams?

My Reply:

Lisp style syntax and dynamic typing makes it easier for me to refactor code. The Clojure REPL is also a very valuable tool for creating and maintaining code, providing instant feedback and easy experimentation with code.

A specification library (clojure.spec or Malli) can be used to validate the correct form of data, especially useful on data coming from outside the Clojure code. Creating a specification for the important concepts and business objects in the domain ensures consistency and a simple way to validate data.

Clojure syntax allows code to be written very cleanly and concisely. Immutability of Clojure and a pure functional approach leads to deterministic functions, making it easy to understand exactly what a function does.

Of course the biggest challenge in maintaining any code base is understanding why the code is there in the first place and what is its value to the organisation in keeping that code. Clojure functions, vars and namespaces all have doc-strings that explain why the code should be there. This provides vital information to those considering maintenance and refactor of that code.

Healthλ︎

Brompton upgradesλ︎

The Brompton folding bicycle is an excellent way to commute and although I work from home I do have some opportunities to cycling into the city.

This weekend I am volunteering for the London Marathon, supporting those who will take longer than 8 hours to complete. There is a pace car that indicates where people should be throughout the course to complete in 8 hours.

Following the pace car are mini-busses for the support team and people who need help. The mini-buses also have lots of snacks (which I will try to resist myself).

The Brompton has rim brakes that work okay, but after using a bike with disk breaks I really notice the difference. Even though I dont go too fast on the Bromption, rarely above 20km/hour, having very responsive breaks is important if cars and other vehicles suddenly break or drive recklessly.

The Brompton has Fibraz rim breaks which have replaceable break pads, a great environmental feature. The stock Fibraz pads are okay but from the customer feedback on Amazon.co.uk the Swiss Stop break pads are far superior, especially in the wet.

Swiss Stop FlashPro BXP Break Pads


Thank you.

🌐 Practical.li Website

Practical.li GitHub Org practicalli-johnny profile

@practicalli@clj.social @practical_li