Skip to content

Instantly share code, notes, and snippets.

View lobre's full-sized avatar

Loric Brevet lobre

View GitHub Profile
@lobre
lobre / README.md
Last active May 16, 2025 07:42
Understanding Kakoune’s Command Language: Parsing, Evaluations, and Beyond

Understanding Kakoune’s Command Language: Parsing, Evaluations, and Beyond

Kakoune is a modal editor. That means when you’re editing text, you’re constantly interacting with the editor using a powerful language of keystrokes — moving around, selecting text, transforming content, all through short, expressive commands typed directly in the editing interface. This is the core editing experience, and it’s what gives Kakoune its speed and fluidity.

But this isn’t the only way to interact with Kakoune.

There’s another side to Kakoune — a more structural, programmable one — which lets you interact with the editor through commands. These commands can be used to configure Kakoune, automate behavior, and define complex workflows. Commands can be written in configuration files, invoked via custom keybindings, or typed directly into the command prompt.

This document focuses on that second side: the command interface. We will explore how commands work, how they are built, and how Kakoune interprets them

@lobre
lobre / zig_type_system.md
Last active March 15, 2025 04:56
Zig type system illustrated using ascii diagrams

Zig Type System

Zig aims to be a simple language. It is not easy to define what simple exactly means, but zig is also a low-level programming language that aims for c-compatibility. To reach this goal, it needs good semantics in its type system so that developers have a complete toolbox to manipulate data.

So types in zig are composable, but this can become rapidly overwhelming. See those examples. Are you able to understand them at a glance, as soon as you read them?

*const ?u8
?*const u8
*const [2]u8
@lobre
lobre / oni.sh
Created August 25, 2020 21:32
Bash function to run oni2 AppImage on NixOS
function oni() {
dir="$HOME"
if [[ -n "$1" ]]; then
dir=$(readlink -m "$1")
fi
unset LD_LIBRARY_PATH
unset LIBGL_DRIVERS_PATH
nix-shell -p appimage-run --run "appimage-run $HOME/Downloads/Onivim2-x86_64-master.AppImage $dir"
@lobre
lobre / .lesskey
Created August 24, 2020 09:37
lesskey with default keybindings
#command
t next-tag
T prev-tag
j forw-line
k back-line
d forw-scroll
u back-scroll
h left-scroll
l right-scroll
r repaint
@lobre
lobre / default.nix
Last active June 23, 2020 19:11
How to nix-shell for Go projects
# Example with go modules fetched by
# nix and linked to the vendor directory
# when entering the shell.
with import <nixpkgs> {};
buildGoModule {
pname = "example";
version = "0.0.1";
src = ./.;
{
"workbench.colorTheme": "One Dark Pro",
"editor.detectIndentation": true,
"editor.fontFamily": "FiraCode-Regular.ttf",
"editor.fontSize": 14,
"editor.largeFileOptimizations": true,
"editor.highlightActiveIndentGuide": true,
"editor.indentSize": 4,
"editor.insertSpaces": false,
"editor.lineNumbers": "on",
@lobre
lobre / composer-inc-minor.sh
Created December 4, 2019 16:09
Minor upgrade in composer.json
#!/bin/bash
# This script takes a composer.json file as first parameter
# and will increase the minor number of the semantic version.
# e.g. From 1.3.3 to 1.4.0.
oops() {
echo "$0:" "$@" >&2
exit 1
}
@lobre
lobre / cli_test.go
Created November 7, 2019 21:21
Testing the cli kit
package main
import (
"flag"
"fmt"
"github.com/lobre/kits/cli"
)
func main() {
@lobre
lobre / tascam-generate-schema-frame.sh
Created September 2, 2019 13:28
Generate a good quality PNG image from the Tascam block diagram in the official manual
#!/bin/bash
# Downloading official manual
wget -O tascam.pdf https://tascam.com/downloads/products/tascam/model_24/e_model-24_om_va.pdf
# Extract page 52 to PNG and crop/rotate/erase content
# Sizes are chosen to keep a 3:2 ratio
convert -density 600 "tascam.pdf[52]" -quality 100 -rotate 90 -crop 6051x4033+250+460 -bordercolor white -shave 150x0 -border 150x0 tascam.png
# Remove manual
@lobre
lobre / isobuilder.sh
Created July 5, 2019 12:16
Arguments parsing in bash example
#!/bin/bash
#
# This script will extract, modify and repack a bootable iso image.
#
# Features:
# - Add kickstart file
# - Add post install kickstart scripts
# - Play scripts in a chroot of the filesystem
#
# Dependencies: