Interface-based programming by example in Vimscript

generic technology banner image
generic technology banner image

In software engineering, there is a simple yet powerful idea of programming to an interface. While the precise manner this is put into practice differs depending on the specifics of a given program, the core principle behind the idea remains the same. When implemented well, software systems that utilize interface-based programming will tend to exhibit desirable characteristics such as loose coupling, high cohesion, and better modularity, thereby improving code maintainability and extensibility.

In this post, I’ll be explaining how to program to an interface by walking-through a recent contribution I’d made to Vim-CtrlSpace (a workflow-management / fuzzy-finder plugin), which added…

A key design principle behind GNU Guix as a package manager is its extensibility, i.e. allowing users to easily write their own package definitions. Thus this post aims to serve as a starting reference for doing precisely that.

The package I’ll be using for this demonstration is LÖVE-Nuklear, which provide bindings to the immediate mode GUI library, Nuklear for the Lua game engine, LÖVE.

Load Required Modules

All Guix packages are defined in source files written in Guile Scheme, with each source corresponding to a single module that contains packages related along a common theme. …

When hacking on Vim itself, I often find myself staring at some error message without any clear ideas of its cause or how to proceed. Thus I wrote a small plugin to help tackle this problem.

Introducing GrepRtpScr, a plugin for grepping through your Vim’s scriptnames` & `runtimepath`, which should help you to debug your loaded Vimscript sources, and remind you of all loadable sources respectively.

Here’s an asciicast (also in project README) with a quick demo.

This article provides an introduction to the internals of SpaceVim layers, with the end goal being to prepare interested SpaceVim users with creating their own. To achieve this, I’ll first present a high-level overview of how SpaceVim layers work in general, then give a demonstration by example of how to create a new one.

Theoretical Overview


When Vim is launched, SpaceVim takes over by sourcing ~/.SpaceVim/config/main.vim, where after some compatibility and environment checks and sets, all SpaceVim features and functionalities are set into motion sequentially by the 3 core functions below:

  1. SpaceVim#begin(), where various basic options are set, common functions and keybindings…

SpaceVim on start-up

SpaceVim describes itself as “A community-driven modular vim distribution — The ultimate vim configuration”. It’s an excellent project targeting new or busy Vim users who don’t have the time to set up their own configs. It comes with a rich feature set, which provides all the essential tools needed to streamline the workflows of programmers, allowing them to just focus on writing code. I will introduce SpaceVim by offering some practical customization advice and demonstrating a few essential features. However it’s not absent of rough edges, which I shall also be informing potential users of.

Author’s Background

I first started using Vim…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store