Skip to content

Instantly share code, notes, and snippets.

@treatmesubj
treatmesubj / nvimgitdiff.sh
Last active September 9, 2024 17:06
vimdiff a file against a main branch or a prior commit, while actively editing the file
#!/usr/bin/env bash
# https://stackoverflow.com/a/78932988/11255791
alias nvimdiff='nvim -d'
nvimgitdiff() {
if [[ "$#" == 2 ]]; then
local ref=${1}
local gitrelfp=${2}
gitfullfp=$(git ls-files --full-name $gitrelfp)
fname=$(basename ${gitrelfp})
@treatmesubj
treatmesubj / Duckdb.lua
Last active September 4, 2024 21:13
execute visually selected SQL with duckdb in neovim and open csv results in new pane
-- inspired by
-- https://gist.github.com/Leenuus/7a2ea47b88bfe16430b42e4e48122718
-- https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7
local function duckdb(args)
local range = args.range
local line1 = args.line1 - 1
local line2 = args.line2
line2 = line1 == line2 and line1 + 1 or line2
local stdin = vim.api.nvim_buf_get_lines(0, line1, line2, false)