Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/lua
--[[*
* test case: cmus-notify status playing file path title hola artist qace album ok
*
* installation:
* - Set the status_display_program variable in cmus
* :set status_display_program=/path-to/cmus-notify.lua
*
* - Save the changes using
HISTFILE="$HOME/.zsh_history"
HISTSIZE=50000
SAVEHIST=10000
## History command configuration
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
@VonHeikemen
VonHeikemen / map_utils.lua
Last active March 27, 2022 16:15
Allows you to use lua functions with `vim.api.nvim_set_keymap` (for neovim 0.6.1 or lower)
local M = {}
local module_name = 'map_utils'
local fn_store = {}
local function register_fn(fn)
table.insert(fn_store, fn)
return #fn_store
end
function M.apply_function(id)
@VonHeikemen
VonHeikemen / commit-hash.vim
Last active January 23, 2022 00:48
collect commit hash from vim plugins using vimscript
let s:packpath = expand('~/.local/share/nvim/site/pack/minpac')
let s:hash_dir = expand('~/.local/share/nvim/site/pack/minpac/hashes')
let s:pattern = '/{opt,start}'
function! s:save_hashes() abort
let plugin_dirs = glob(s:packpath .. s:pattern, 1, 1)
if empty(plugin_dirs)
return
endif
@VonHeikemen
VonHeikemen / prompt-backspace.lua
Last active January 10, 2022 01:57
Neovim: Use backspace when `buftype=prompt`
-- Taken from here:
-- https://github.com/neovim/neovim/issues/14116#issuecomment-977555102
function PromptBackspace()
-- Have to know the length of the prompt
local prompt = 2
local cursor = vim.api.nvim_win_get_cursor(0)
local line = cursor[1]
local col = cursor[2]
if col ~= prompt then
@VonHeikemen
VonHeikemen / completion.lua
Created November 16, 2021 17:20
Sublime-like autocompletion for neovim, using nvim-cmp and luasnip
--[[
Dependencies:
Completion:
https://github.com/hrsh7th/nvim-cmp
https://github.com/hrsh7th/cmp-buffer
https://github.com/hrsh7th/cmp-path
https://github.com/saadparwaiz1/cmp_luasnip
Snippets:
#! /usr/bin/env node
const os = require('os');
const getNetworkAddress = (interfaces) => {
for (const name of Object.keys(interfaces)) {
for (const interface of interfaces[name]) {
const {address, family, internal} = interface;
if (family === 'IPv4' && !internal) {
return address;
@VonHeikemen
VonHeikemen / esm.json
Last active February 10, 2021 13:22
Create a productive environment for small personal scripts. Only try this at home.
{
"cache": false,
"await": true
}
@VonHeikemen
VonHeikemen / rc.vim
Created January 4, 2021 03:02
simple vimrc
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Don't include vi compatibility
set nocompatible
" Sensible backspace
set backspace=indent,eol,start
@VonHeikemen
VonHeikemen / example-transducers-v3.js
Last active December 28, 2020 18:28
Transducers (in javascript) in action.
// Getting some stats from https://dev.to/dashboard
// Inspired by this: https://dev.to/tylerlwsmith/get-your-dev-2020-year-in-review-scraping-data-using-the-console-3gen
function compose(...fns) {
const apply = (arg, fn) => fn(arg);
return (initial) => fns.reduceRight(apply, initial);
}
function to_transducer(reducer) {
if(typeof reducer['@@transducer/step'] == 'function') {