Skip to content

Instantly share code, notes, and snippets.

@ii14
ii14 / bd.lua
Last active March 18, 2024 12:03
local api, fn = vim.api, vim.fn
local function find_prev(bufnr)
local bufs = api.nvim_list_bufs()
local idx = nil
for i, buf in ipairs(bufs) do
if buf == bufnr then
idx = i
break
This file has been truncated, but you can view the full file.
/binutils/ltversion.m4
/binutils/ChangeLog
/binutils/intl
/binutils/gprofng
/binutils/config-ml.in
/binutils/setup.com
/binutils/intl/localename.c
/binutils/COPYING
/binutils/gprofng/libcollector
/binutils/intl/intl-compat.c
@ii14
ii14 / ci-logs-monke.js
Last active May 14, 2023 00:14
TamperMonkey script for interpreting (or stripping) terminal control sequences in Github CI logs
// ==UserScript==
// @name ci logs monke
// @namespace https://github.com/neovim/neovim
// @version 0.1.0
// @description Interpret (or strip) terminal control sequences in Github CI logs
// @author neovim chat
// @match https://pipelines.actions.githubusercontent.com/serviceHosts/*/_apis/pipelines/*/runs/*/signedlogcontent/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=githubusercontent.com
// @grant none
// ==/UserScript==
@ii14
ii14 / redir.lua
Created August 26, 2022 20:34
redir.lua
vim.api.nvim_create_user_command('Redir', function(ctx)
local lines = vim.split(vim.api.nvim_exec(ctx.args, true), '\n', { plain = true })
if #lines > 0 then
vim.cmd('new')
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
vim.opt_local.modified = false
else
vim.api.nvim_echo({{'No output', 'WarningMsg'}}, false, {})
end
end, { nargs = '+', complete = 'command' })
@ii14
ii14 / execute.vim
Created August 14, 2022 18:34
execute.vim
" Execute selected vim script lines
function! s:__execute__(line1, line2, arg) abort
let l:src = substitute(join(getline(a:line1, a:line2), "\n"), '\n\s*\\', ' ', 'g')
if a:arg ==# ''
try
call execute(l:src, '')
catch
echohl ErrorMsg
@ii14
ii14 / pipe.lua
Last active August 17, 2022 16:05
pipe.lua
-- :! replacement that supports char-wise selection
-- from visual mode :Pipe <command>
vim.api.nvim_create_user_command('Pipe', function(ctx)
local ms = vim.api.nvim_buf_get_mark(0, '<')
local me = vim.api.nvim_buf_get_mark(0, '>')
local mt = vim.fn.visualmode()
if mt == '\22' then
error 'blockwise selection not supported'
end
@ii14
ii14 / braille.c
Last active July 8, 2022 13:59
quick program for converting ascii art to braille
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
const char *braille[256] = {
"⠀", "⢀", "⠠", "⢠", "⠐", "⢐", "⠰", "⢰", "⠈", "⢈", "⠨", "⢨", "⠘", "⢘", "⠸", "⢸",
"⡀", "⣀", "⡠", "⣠", "⡐", "⣐", "⡰", "⣰", "⡈", "⣈", "⡨", "⣨", "⡘", "⣘", "⡸", "⣸",
"⠄", "⢄", "⠤", "⢤", "⠔", "⢔", "⠴", "⢴", "⠌", "⢌", "⠬", "⢬", "⠜", "⢜", "⠼", "⢼",
"⡄", "⣄", "⡤", "⣤", "⡔", "⣔", "⡴", "⣴", "⡌", "⣌", "⡬", "⣬", "⡜", "⣜", "⡼", "⣼",
"⠂", "⢂", "⠢", "⢢", "⠒", "⢒", "⠲", "⢲", "⠊", "⢊", "⠪", "⢪", "⠚", "⢚", "⠺", "⢺",
@ii14
ii14 / startuptime.lua
Last active July 9, 2022 23:36
Shows lua's `require` in `--startuptime` logs
-- OUTDATED: it got merged to neovim: https://github.com/neovim/neovim/commit/2c739431e8e5a2aacc39ef429401f5e4427d027a
-- nvim --cmd 'so startuptime.lua' --startuptime nvim.log
local ffi = require('ffi')
local C = ffi.C
ffi.cdef([[
typedef void FILE;
typedef uint64_t proftime_T;
@ii14
ii14 / luvgrind.lua
Last active May 28, 2022 00:33
luvgrind.lua
-- for this to be complete, we'd also need to patch
-- luv metatables, patch async callbacks and keep
-- track of file descriptors
local uv = vim.loop
local handles = setmetatable({}, { __mode = 'k' })
local function install()
local function pack(...)
return {...}, select('#', ...)
@ii14
ii14 / raw.lua
Created May 18, 2022 19:03
:sh port for neovim
function _G.make(command)
command = command or 'make'
local running = true
vim.api.nvim_chan_send(vim.v.stderr, '\r\n')
local job = vim.fn.jobstart(command, {
env = { TERM = vim.env.TERM },
pty = true,
width = vim.api.nvim_get_option('columns'),