Skip to content

Instantly share code, notes, and snippets.

@0riginaln0
0riginaln0 / transpose.lua
Created November 8, 2026 10:01
Emacs transpose chars (ctrl+t) action for Pragtical
-- mod-version:3
local command = require "core.command"
local keymap = require "core.keymap"
local translate = require "core.doc.translate"
command.add("core.docview", {
["doc:transpose-chars"] = function(dv)
local doc = dv.doc
for idx, line, col, line2, col2 in doc:get_selections(true, true) do
local has_no_selection = line == line2 and col == col2
@0riginaln0
0riginaln0 / indentguide.lua
Created November 6, 2026 10:51
vibecoded indentguide.lua plugin modification to sync the lines drawn with the codefold plugin
-- mod-version:3
-- Indent Guide, synced with the code folding plugin (codefold.lua).
--
-- In codefold mode the guides are not derived from raw whitespace but from
-- the fold regions that the code folding plugin detects on the DocView
-- (view.cf_regions). A vertical guide is drawn on a line, at a given indent
-- level, only when that line is inside a fold region that starts at that
-- level. Continuation/alignment lines (e.g. wrapped function call arguments
-- aligned under an opening parenthesis) are interior lines of the region
-- started by the statement header, so they only get the guides of their
@0riginaln0
0riginaln0 / dub.c3
Last active November 4, 2026 11:52
Routing tree command-line arguments parsing approach
module dub;
import std::io;
struct Dub {
String[] args;
int i;
int savepoint_i;
}
// ----- API -----
-- light
local style = require "core.style"
local common = require "core.common"
local NIGHT_MODE_INTENSITY = 30 -- [0, 1, ... 100]
local function clamp(min, max, value)
return math.max(min, math.min(max, value))
end
-- mod-version:3
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
-------------------
-- Configuration --
-------------------
##
PersistentVector
32-way persistent vector, equivalent to Clojure's PersistentVector.
Public API:
Instantiation:
let vec = PersistentVector.empty()
@0riginaln0
0riginaln0 / frequration.lua
Last active July 25, 2026 14:11
Lua library for duration and frequencies unit-aware time arithmetic
--[[
-- ===========
-- Usage
-- ===========
local F = require("frequration")
-- Full list of avaliable constructors can be found in the source code.
F.register_globals()
-- ======================================================
@0riginaln0
0riginaln0 / why.lua
Last active March 28, 2026 15:35
Lua... why?
pp = function(t)
print("{ " .. table.concat(t, ", ") .. " }")
end
a = function() return 1, 2 end
b = function() return 11, 12 end
pp { a(), b(), "why?"} -- { 1, 11, "why?" }
@0riginaln0
0riginaln0 / packer.lua
Created March 11, 2026 10:32
Pack the Lua files in the current folder into an archive and unpack the archive
local function unzip(input_path)
-- Open the archive file for reading
local archive_file = io.open(input_path, "r")
if not archive_file then
error("Could not open file: " .. input_path)
end
local current_file = nil
local current_content = {}
@0riginaln0
0riginaln0 / lite-light.focus-theme
Last active March 8, 2026 12:46
Port of Lite themes for Focus editor
[16] # Version number. Do not delete.
# Based on the original Lite Light theme:
# https://github.com/pragtical/colors/blob/master/colors/lite-light.lua
[colors]
background0: F5F5F5FF
background1: E0E0E0FF
background2: E0E0E0FF
background3: E0E0E0FF