Skip to content

Instantly share code, notes, and snippets.

@treatmesubj
treatmesubj / Duckdb.lua
Last active December 6, 2024 20:30
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)