csvview: init

This commit is contained in:
dathegreat 2026-06-11 14:15:58 -06:00 committed by Snoweuph
commit 6f6b34a0b9
6 changed files with 153 additions and 0 deletions

View file

@ -235,6 +235,9 @@
`languages/haskell.nix`
- Made the haskell LSP and formatter configurable
- Added [csvview.nvim](https://github.com/hat0uma/csvview.nvim) support under
`vim.utility.csvview` for rendering CSV/TSV files as aligned tables.
[alfarel](https://github.com/alfarelcynthesis):
[obsidian.nvim]: https://github.com/obsidian-nvim/obsidian.nvim

View file

@ -0,0 +1,50 @@
{
options,
config,
lib,
...
}: let
inherit (lib.generators) mkLuaInline;
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) mkKeymap;
cfg = config.vim.utility.csvview;
keys = cfg.mappings;
inherit (options.vim.utility.csvview) mappings;
in {
config = mkIf cfg.enable {
vim = {
lazy.plugins.csvview-nvim = {
package = "csvview-nvim";
setupModule = "csvview";
inherit (cfg) setupOpts;
cmd = ["CsvViewEnable" "CsvViewDisable" "CsvViewToggle" "CsvViewInfo"];
keys = [
(mkKeymap "n" keys.toggle "<cmd>CsvViewToggle<CR>" {desc = mappings.toggle.description;})
];
};
# csvview.nvim has no built-in auto-enable, so drive it with a FileType
# autocommand. The `is_enabled` guard keeps this idempotent so
# re-firing FileType (e.g. `:e!`, `:set ft=csv`) doesn't warn about an
# already-attached buffer.
autocmds = mkIf cfg.autoEnable [
{
event = ["FileType"];
pattern = ["csv" "tsv"];
callback = mkLuaInline ''
function(args)
if not require("csvview").is_enabled(args.buf) then
require("csvview").enable()
end
end
'';
desc = "Automatically enable CSV view for CSV/TSV files";
}
];
};
};
}

View file

@ -0,0 +1,80 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool int str listOf enum;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in {
options.vim.utility.csvview = {
enable = mkEnableOption "View CSV/TSV files as aligned tables [csvview.nvim]";
autoEnable =
mkEnableOption ''
Automatically enable the CSV view when opening CSV/TSV files.
''
// {default = true;};
mappings = {
toggle = mkMappingOption "Toggle CSV view [csvview]" "<leader>tc";
};
# Note: These defaults are a subset of the csvview default configuration, as defined in
# [https://github.com/hat0uma/csvview.nvim/blob/5c22774c3ecc7f8883af5d143b366e45b1f0875d/README.md?plain=1#L97]
# which I think users would most likely want to modify
setupOpts = mkPluginSetupOption "csvview.nvim" {
parser = {
async_chunksize = mkOption {
type = int;
default = 50;
description = "Number of lines processed per asynchronous parsing cycle. If the UI freezes, try reducing this value.";
};
comments = mkOption {
type = listOf str;
default = [];
description = ''
List of comment prefixes. Lines starting with one of these are
treated as comments and excluded from table rendering, e.g.
`["#" "//"]`.
'';
};
};
view = {
min_column_width = mkOption {
type = int;
default = 5;
description = "Minimum width of a column";
};
spacing = mkOption {
type = int;
default = 2;
description = "Spacing between columns";
};
display_mode = mkOption {
type = enum ["highlight" "border"];
default = "highlight";
description = ''
Display method for the column delimiter.
- `highlight`: highlight the delimiter character.
- `border`: render the delimiter as a vertical border.
'';
};
sticky_header = {
enabled = mkOption {
type = bool;
default = true;
description = "Keep the header row visible at the top while scrolling";
};
};
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./csvview.nix
./config.nix
];
}

View file

@ -2,6 +2,7 @@
imports = [
./binds
./ccc
./csvview
./diffview
./direnv
./fzf-lua

View file

@ -423,6 +423,19 @@
"url": "https://github.com/Decodetalkers/csharpls-extended-lsp.nvim/archive/be8093d19af1538aad9ee77dc5589e55b083967a.tar.gz",
"hash": "sha256-MDr3n9LaQ/YTHD7egDohQ7YmT2+itWXNoMLigmZp3KQ="
},
"csvview-nvim": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "hat0uma",
"repo": "csvview.nvim"
},
"branch": "main",
"submodules": false,
"revision": "5c22774c3ecc7f8883af5d143b366e45b1f0875d",
"url": "https://github.com/hat0uma/csvview.nvim/archive/5c22774c3ecc7f8883af5d143b366e45b1f0875d.tar.gz",
"hash": "sha256-JJZCrLhUzausIs61UfsE4472B1KzgZyI+BlbZH+gUn0="
},
"dashboard-nvim": {
"type": "Git",
"repository": {