Read-only, live-updating CSV/TSV table viewer with full SQL support for Neovim — powered by DuckDB.

Open any .csv or .tsv file in Neovim and immediately inspect it as a crisp Unicode table, run real SQL queries against it (WHERE, GROUP BY, ORDER BY, SUMMARIZE, JOIN), and watch the table update in real time whenever the file changes on disk.
.csv / .tsv files in a safe modifiable = false view using DuckDB's Unicode box table. Never modifies or corrupts your underlying file.data. Query via :CsvSql <query> or a toggleable multi-line SQL scratch split (ft=sql).vim.uv.new_fs_event) on the parent directory (handles atomic save/rename writes) with debouncing and viewport/cursor preservation.build = ":CsvSqlInstall"). No manual setup required.>= 0.10).vim.uv and vim.system.curl (pre-installed on macOS, Linux, and Windows 10/11) — used once during install to download DuckDB automatically.Already have DuckDB on your
PATH?csvsql.nvimdetects and uses your existing systemduckdbautomatically and skips downloading.
return {
"ga2631/csvsql.nvim",
build = ":CsvSqlInstall",
event = { "BufReadPre *.csv", "BufReadPre *.tsv" },
cmd = {
"CsvSql",
"CsvSqlOpen",
"CsvSqlEditor",
"CsvSqlToggle",
"CsvSqlReset",
"CsvSqlRefresh",
"CsvSqlWatch",
"CsvSqlSummarize",
"CsvSqlInstall",
},
opts = {},
}
vim.packvim.api.nvim_create_autocmd("PackChanged", {
callback = function(ev)
if ev.data.spec.name == "csvsql.nvim" and (ev.data.kind == "install" or ev.data.kind == "update") then
require("csvsql").install()
end
end,
})
vim.pack.add({ "https://github.com/ga2631/csvsql.nvim" })
require("csvsql").setup()
-- lazy.nvim
return {
dir = "~/Projects/csvsql.nvim",
build = ":CsvSqlInstall",
opts = {},
}
If you prefer managing DuckDB via your OS package manager instead of :CsvSqlInstall:
brew install duckdbcurl https://install.duckdb.org | sh (or sudo pacman -S duckdb / nix-env -iA nixpkgs.duckdb)winget install DuckDB.cli (or scoop install duckdb / choco install duckdb)Verify your setup anytime inside Neovim with:
:checkhealth csvsql
.csv or .tsv file: nvim sales.csvdata::CsvSql SELECT region, SUM(amount) AS total FROM data GROUP BY region ORDER BY total DESCgs (or :CsvSqlEditor), write SQL, and press <CR>, <C-s>, or :w to execute.gS (or :CsvSqlSummarize) to run DuckDB's SUMMARIZE data.gr (or :CsvSqlToggle) to view/edit the raw file, and :CsvSqlToggle to return.| Command | Description |
|---|---|
:CsvSql [sql] |
Run SQL against data (or open the SQL scratch split if no query given) |
:CsvSqlOpen [file] |
Open a CSV/TSV file in the live table view |
:CsvSqlEditor |
Toggle the multi-line SQL scratch split (ft=sql) |
:CsvSqlToggle |
Toggle between rendered table view and raw CSV buffer |
:CsvSqlReset |
Reset SQL query back to SELECT * FROM data LIMIT ... |
:CsvSqlRefresh |
Manually refresh the table |
:CsvSqlWatch |
Pause / resume real-time file watching |
:CsvSqlSummarize |
Run SUMMARIZE data for instant column stats |
:CsvSqlInstall[!] |
Auto-install DuckDB CLI into Neovim's data directory (! forces reinstall/upgrade) |
:CsvSqlClose |
Close only the csvsql viewer buffer without quitting Neovim |
:CsvSqlTruncate |
Toggle column ellipsis truncation (default 48 chars) vs full cell values |
:CsvSqlWrap |
Toggle viewbox line wrapping (WRAP / NOWRAP) |
| Key | Action |
|---|---|
gs |
Toggle SQL scratch editor split |
gq |
Open quick single-line SQL prompt |
gS |
Run SUMMARIZE data |
gR |
Reset query to default |
r |
Manual refresh |
gr |
Toggle raw CSV buffer |
gw |
Toggle live file watching (LIVE / PAUSED) |
gt |
Toggle column ellipsis (TRUNC:48) vs full values (FULL) |
gW |
Toggle viewbox line wrap (WRAP / NOWRAP) |
q |
Close only the csvsql viewer buffer (:q also safely closes just the buffer) |
In the SQL scratch split: <CR> (normal mode), <C-s> (normal/insert), or :w runs the query; q closes the split.
All options and their defaults:
require("csvsql").setup({
auto_enable = true, -- Auto-render CSV/TSV files on open
filetypes = { "csv", "tsv" },
duckdb_bin = "duckdb", -- Binary name or full path to duckdb
table_name = "data", -- Virtual SQL table name for the current CSV
default_limit = 1000, -- Row limit for default query (false to disable)
truncate = true, -- Ellipsis-truncate cells longer than max_col_width
max_col_width = 48, -- Max characters per cell before ellipsis (…)
wrap = false, -- Wrap long lines to window viewbox width
output_mode = "box", -- "box" | "markdown" | "table" | "column"
debounce_ms = 200, -- Debounce interval for live file watcher (ms)
live_watch = true, -- Start live file watching automatically
editor_height = 8, -- Height (lines) of the SQL scratch split
show_header = true, -- Show status/query header banner
sticky_header = true, -- Lock banner & table column header at top when scrolling down
zebra_striping = true, -- Alternate row colors (CsvSqlRowOdd / CsvSqlRowEven)
safe_quit = true, -- Make :q close only the viewer buffer (not Neovim)
keymaps = {
editor = "gs",
prompt = "gq",
reset = "gR",
refresh = "r",
toggle_raw = "gr",
toggle_watch = "gw",
summarize = "gS",
toggle_truncate = "gt",
toggle_wrap = "gW",
close = "q",
},
})
MIT — see LICENSE.