1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
return {
{
"hat0uma/csvview.nvim",
cmd = { "CsvViewEnable", "CsvViewDisable", "CsvViewToggle" },
event = { "BufReadPre *.csv" }, -- Lazy-load the plugin when a CSV file is about to be read
init = function()
local wk = require("which-key")
wk.add({
mode = { "n", "v", "x" },
{ "<leader>cs", group = "csv" },
})
end,
config = function()
require("csvview").setup()
vim.api.nvim_create_autocmd("BufRead", {
pattern = "*.csv",
callback = function()
vim.cmd("CsvViewEnable")
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "csv",
callback = function()
vim.keymap.set(
"n",
"<leader>zv",
"<cmd>CsvViewToggle<cr>",
{ desc = "Toggle CSV view", buffer = true }
)
end,
})
end,
keys = {
{
"<leader>csv",
function()
local delimiter = vim.fn.input("Delimiter (e.g., ,): ")
local quote_char = vim.fn.input("Quote char (e.g., '): ")
local comment = vim.fn.input("Comment char (e.g., #): ")
local command = string.format(
":CsvViewToggle delimiter=%s quote_char=%s comment=%s<CR>",
delimiter,
quote_char,
comment
)
vim.cmd(command)
end,
desc = "Toggle CSV view",
},
},
},
}
|