I made a micro.blog plugin for Neovim

What’s stopping you from publishing to your blog more? Is your boring life giving you nothing to write about? Demotivated by the chronic lack of engagement your posts have been getting? What about that crippling self-consciousness and perfectionism manifesting in dozens of “unfinished” drafts? Of course not — we all know it’s the friction of having to take 15 seconds to copy your post from your favourite text editor into the micro.blog window and clicking publish (probably even using the mouse, ugh).

Thankfully, I’ve made a Neovim plugin (really, a curl wrapper wrapper) to create and update micro.blog posts with just a couple of keybinds of your choosing.

Isn’t Neovim for coding? Why would you use it for blog posts?

Vim’s motions (keyboard shortcuts that are used to navigate and select text) are good for all editing tasks, not just source code. For example, to select a sentence, including the full-stop and following whitespace, place the cursor anywhere in the sentence and type vas ("Visually select Around Sentence"). Similar commands exist to select/delete/change words, paragraphs, text in brackets, up to a comma, in quotation marks, etc. It’s also easy to configure tools like spellchecking, dictionary, and thesaurus in Neovim.

Other popular text editors (including Obsidian) often implement a “vim mode” to emulate a subset of Vim’s shortcuts. If you’ve never tried learning these, I highly recommend giving it a go — the learning curve is steep but it’s fun, and you’ll never want to use the mouse or hold down modifiers to edit text again.

Neovim loads virtually instantly. Even with over 80 plugins installed, my startup time is around 200ms1. With just a couple of keyboard shortcuts I can go from having a shitty half-formed opinion to having published it on the open web in just a few seconds.

The plugin

The plugin is based around just four main commands. publish (used to both create and update posts), quickpost (which is like publish with some default settings for “micro” posts), and two commands for opening a post to edit and update. First, let’s look at getting set up.

Configuration and installation

You need to have curl installed, as well as the Neovim plugins telescope and plenary. You can pass the following table to the lazy plugin manager:

{
    's-cassidy/microblog.nvim',
    dependencies = {
        'nvim-telescope/telescope.nvim',
        'nvim-lua/plenary.nvim'
    }
}

Next you need a micro.blog App Token, which you can get from the Account Settings page. This needs to be set as an environment variable (default MB_APP_TOKEN). As shell processes only have access to variables defined when they start, you need to set this before starting Neovim (there’s a configuration option to warn you if the plugin starts without setting the App Token).

The only bit of configuration that is absolutely essential is a Lua table containing your blogs. Each entry is a table with your blog’s url and uid (probably https://something.micro.blog). You’ll also probably want to set some keybindings. Here is what my configuration looks like in the lazy table

      local mb = require('microblog')

      mb.setup({
          blogs = {
            {
              url = 'https://samjc.me',
              uid = 'https://samjc.micro.blog'
            },
            {
              url = 'https://samjc-test.micro.blog',
              uid = 'https://samjc-test.micro.blog'
            }
          },
          no_save_quickpost = true,
        })

      vim.keymap.set({ 'n', 'v' }, '<leader>me', mb.pick_post, { desc = 'Edit a post' })
      vim.keymap.set({ 'n', 'v' }, '<leader>mp', mb.publish, { desc = 'Send a post' })
      vim.keymap.set({ 'n', 'v' }, '<leader>mq', mb.quickpost, { desc = 'Quick post' })
      vim.keymap.set({ 'n', 'v' }, '<leader>mu', mb.get_post_from_url, { desc = 'Open micro.blog url' })
      vim.keymap.set({ 'n', 'v' }, '<leader>ms', mb.display_post_status,
        { desc = 'Display post status' })

Some other configuration options:

  • no_save_quickpost will let you quit without saving if you used the quickpost command. Since quickpost is designed for sending short “micro” posts, you can set this to true if you don’t care about keeping a local copy of your micro posts.
  • always_input_url when set to true will always give you the option to manually edit the url of the post you are updating. Most users will want this set to false, because you’ll use one buffer per post, so the target url for a publish either won’t exist (brand new post) or it will be the existing url of the post in that buffer. However, some workflows might benefit from this (multiple posts in a single file, for example).

Using the plugin

The simplest usage is to make a new post. We open a new Neovim buffer, type out our post, and then run either publish (which will prompt the user to pick which blog to post to and input some options like a post title and categories) or quickpost, which skips the prompting and just posts to the default blog with no title or categories. We can also visually select some text and run either command to only post that part.

To edit an existing post, we can use edit_post_from_url which will prompt for an url (or takes an url as an argument) and then open that post in a new buffer. You can then make your changes and run publish to publish your updated version.

Alternatively, pick_post will load a large (full?) list of posts in telescope that you can fuzzy search. The search includes the date, title, content, and even url of the post. I’ve not yet got around to a previewer for pick_post, so it’s slightly dependent on you being able to recognise a post by its title or first sentence, but I imagine I’ll add a previewer soon. You can then pick a post to open and edit as described above.

Screenshot of Neovim showing the Telescope picker with a list of recent blog posts

Thanks

Thanks to HeyLoura — it was very useful to be able to read Lillihub’s source code to see examples of the micropub protocol in action. And thanks to you for reading and showing an interest; I’m not a developer and this is my first attempt at a plugin. If you give this a go and find bugs, please do open an issue or PR, drop me an email, whatever.


  1. About a fifth of this start-up time is obsidian.nvim ↩︎

I’m a maths teacher to young girls from age 11 to 16, and this is the longest I’ve ever gone without teaching. Previously, my students’ burning passion for life could make me forget about the tragedies we are living through in Gaza, and they pushed me to be a better person. Nine of my dear students have been killed in Israel’s unfolding genocide, each one a talented and kind girl who will never be able to follow her dreams now. I mourn each child as if they were my family. ~ Eman Mohamed

As a maths teacher this hits very hard

Farming animals is a threat to us all

Rise of drug-resistant superbugs could make Covid pandemic look ‘minor’, expert warns

Antibiotic misuse and overuse threatens to leave us in a post-antibiotic world. Antibiotics are not only essential for curing illnesses, but also to protect against wound infection — including surgical wounds. Routine, safe surgeries could become life-threatening.

The burden for reducing antibiotic use currently falls overwhelmingly on medical and healthcare workers. Yet the majority of antibiotics used worldwide are used on farmed animals. They are used en masse to prevent (not cure) infection in unsanitary conditions, as well as to promote rapid growth.

Most antibiotics used by humans and animals are excreted, ending up in fertiliser, in our rivers, or in our sewage. In other words, our food and water systems become breeding grounds for antimicrobial resistance. Moreover, the primary mechanism for the spread of antimicrobial resistance is via horizontal gene transfer — the tranfer of genetic material between species, even distantly related ones. Even if antimicrobial resistance evolves first in pathogens affecting animals, those adaptations can be passed on to pathogens affecting humans.

Animal farming is bad for animals, the planet, and poses a risk to the future of medicine. Cutting down the use of antibiotics in farming is likely to decrease animal welfare due to disease, and organic farming dramtically increases the land (and hence ecological) footprint of rearing animals. In the majority of the industrialised world, there’s no “good” way to do animal farming.

Finally finished constructing another crossword. Annotated solutions available. Comments, quibbles, and feedback always welcome

How do the kids I teach know about Salad Fingers?

Weekly Digest 2

  • Reviving rural railways with Monocab. This transport technology looks really cool. I can’t see it coming the Britain any time soon (our network is still largely non-electrified), but with public ownership of the railways just around the corner according to Starmer, who knows.
  • A Lesson From the Gymnasium. I enjoyed this post from Greg Morris sharing some wisdom from Marcus Aurelius.
  • CNN disgraces itself over Gaza. Owen Jones continuing to expose the media over its coverage of the atrocity in Gaza.
  • Simple, non-commercial, open source notes. I saw this when it first came out but was reminded of it earlier and how great it is. For those who love plaintext note-taking solutions — a highly entertaining trip down a rabbit hole.

Cooking

  • Vegan Lachmajou. One of my favourite recipes. Super quick, high protein, with simple ingredients. Enjoy with flatbread, hummous, and a salad of finely diced tomatoes, cucumber, and perhaps vegan feta.

Up to much else?

  • I’ve been coding this week in my free time, so there’s not a lot of stuff here. I’ll be posting what I made soon.
  • Finished laying plywood upstairs. Next is to get down the underlay.
  • Did gardening for the first time. Dug out a space and put in a raised bed.
  • Crossword is nearly finished, hoping to publish soon.
  • Next week I’m running an Only Connect quiz at school.

That’s all for this week, thanks for reading.

Just done my first bit of gardening that’s not mowing or weeding

In Praise Of A Little Camera

I had a blast trying the micro.blog 30-day photo challenge (link is to all entries — mine are here. I decided to play with a self-constraint: despite owning a Canon DSLR, I decided to only use photos from my Lumix LX100.

The LX100 is a fixed-lens, compact camera from 2014. It has a micro four-thirds sensor (I guess that’s appopriate for a micro.blog challenge?) with an output resolution of approximately 12MP depending on the selected aspect ratio. Its Leica-made zoom lens has a focal range of 24-75mm (FF-equivalent) and attains f/1.7 at its widest.

Despite it being an old, small-sensored, and relatively low-resolution camera, I absolutely love it. It was my first “proper camera” (barring a Pentax K1000 I had as a child), acquired second-hand during the first lockdown for about £250. Although I have only been taking pictures as a hobbyist for only a few years, and am nowhere close to being an actually good photographer, I think many of the pictures this camera and I have produced together are very Okay, and a couple may even be Quite Good.

In design, it’s essentially a poor man’s Fujifilm X100-series camera, with a zoom rather than prime lens and no built-in flash. It uses similar “retro” physical dials and rings for controlling exposure, has an electronic viewfinder rather than the X100-series' fancy hybrid, and is quite a bit smaller.

This size advantage is key — in most cases, it’s still the camera I reach for over 90% of the time. It’s easier to carry, and less intrusive in social environments. I know how to use it inside-out, with everything set just the way I like it. The design, as well as the number of settings, makes it clear this is a compact camera for a “serious” enthusiast. The dials and rings are an invitation to shoot with intention, and not just “point-and-shoot” – the usual name for the market in which cameras of this size compete.

12 mega-pixels sounds very small by today’s standards. But 12MP is twelve million pixels. My laptop screen is around two million pixels. How many pixels does a non-professional photographer really need? I’ve never made a print bigger than my laptop screen either. The pain only comes if you need to crop an image. One of my biggest photographic regrets is that Day 17: transcendence was taken from too far away and I had to crop — the resolution does suffer a bit here.

The micro four-thirds sensor is basically fine for everyday shooting. I don’t need ultra-fine control of depth-of-field for most scenes, and in fact the increased DoF means I rarely miss focus (which can’t be said when I’m using the full-frame DSLR…). I also get a zoom from 24 to 75mm with a lens about 7cm long.

The only real drag of this camera is that the zoom lens’s mechanism sure loves to eat dust, and being a fixed-lens camera, there’s no way to clean the dust from the sensor without disassembling the camera. This happens a lot, though it’s usually not too visible unless you’re stopped down to f/11 or beyond — you can see it clearly in Day 11: sky.

Would I really like an X100VI? Of course I would. But I don’t have two thousand pounds to spend on an out-of-stock-everywhere camera. And that’s fine. A £250 everyday-carry is fine. I’ve not outgrown it in terms of skill. I’d even guess learning on an older, cheaper camera has been good for pushing me to develop my skills. You really don’t need an expensive camera to get into photography. Just get an affordable camera that’s small enough you’ll actually take it with you, used with intention. I hear some phones have cameras these days, so you could use one of those as well. It’s just about shooting with intention.

The games in my backlog these days are ones that are supposed to have profound themes that I just don’t have time to give the attention they deserve

Day 30: hometown

Though there are many downsides as well, I’m lucky enough to have been brought up in one of the prettiest towns in this country

Day 29: drift

Weekly Digest

Trialing a new format.

This week we have a bunch of lefty links.

  • The Forest and The Factory by Phil A. Neel and Nick Chavez. Long, occasionally whimsical essay on a question that is often overlooked in utopian post-capitalist imaginaries — how do things actually get produced? In particular — how are things produced at scale? Neel and Chavez identify as communists, but even if you don’t like that word there is much to be learned here for anyone interested in imaginaries like eco-socialism, degrowth, social ecology, solarpunk and so on. Link to Chavez’s website
  • Mother Trees and socialist forests: is the “wood-wide web” a fantasy? by Daniel Immerwahr. The idea that trees are altruistic and can share resources and information has gained a lot of traction recently, sometimes in eco/leftist discourse as part of a project to naturalise peace and cooperation. But I’ve always found it farfetched, and this article seems to agree.
  • We Live In An Age Of “Vulture Capitalism”. Interview with economics writer Grace Blakeley. Some interesting discussion about why “state” vs “market” is the wrong debate.

Reading

Roadside Picnic by Arkady & Boris Strugatsky. Gripping Soviet-era sci-fi novel that the Stalker film and S.T.A.L.K.E.R games are based on.

Listening

The Airborne Toxic Event by the band of the same name. I’d not listened to this band in years. Brilliant album, with the standout track Sometime Around Midnight being one of the best sad songs of the 00s.

Watching

  • Watched Into The Congo with Ben Fogle this week. Fogle visits Congo-Brazzaville, and spends time with many interesting peoples and people, including Mbenjele hunter-gatherers, the fashion-loving Sapeurs, and stars of the absolutely bananas Congolese wrestling scene. I have a dear friend originally from Congo (hi if you’re reading!), so it was nice to learn a little more about his country.
  • Watched Britain’s Got Talent for the first time in over a decade. Saturday night family entertainment is a thing now, I guess.

Up to much else?

  • We’ve been laying plywood underfloor upstairs in our house ready to hopefully get some proper flooring soon.
  • Final parents' evening of the year was on Thursday. It went fine, despite me being a bit worried about it.
  • Made a bit of progress toward my next crossword for mycrossword.co.uk. I’ve not set one for months, and they take me so long to construct.

Day 27: surprise

Day 26: critter

Day 25: spine

Toy dinosaur close up in grass. Evening light. Filmic effect

Day 24: light

Day 23: dreamy

A photograph of a pale blue butterfly against green leaves, passed through a filter to give it an almost painted look

Day 22: blue

I’ve been experimenting with this approach to lesson planning recently. Impact on students remains to be seen. Impact on me so far: very positive. More efficient, less wasted planning, more enjoyable to plan.

Day 21: mountain

Himalayan