csvview.nvim
is a lightweight CSV file viewer plugin for Neovim.
With this plugin, you can easily view and edit CSV files within Neovim.
highlight
: Highlights the delimiter.border
: Displays the delimiter with │
.Neovim v0.10 or newer is required.
Install the plugin using your favorite package manager.
Plug 'hat0uma/csvview.nvim'
lua require('csvview').setup()
{
'hat0uma/csvview.nvim',
config = function()
require('csvview').setup()
end
}
csvview.nvim
works with default settings, but you can customize options as follows:
require('csvview').setup({
-- Add your configuration here
})
The configuration options are as follows:
{
parser = {
--- The number of lines that the asynchronous parser processes per cycle.
--- This setting is used to prevent monopolization of the main thread when displaying large files.
--- If the UI freezes, try reducing this value.
--- @type integer
async_chunksize = 50,
--- The delimiter character
--- You can specify a string, a table of delimiter characters for each file type, or a function that returns a delimiter character.
--- e.g:
--- delimiter = ","
--- delimiter = function(bufnr) return "," end
--- delimiter = {
--- default = ",",
--- ft = {
--- tsv = "\t",
--- },
--- }
--- @type string | {default: string, ft: table<string,string>} | fun(bufnr:integer): string
delimiter = {
default = ",",
ft = {
tsv = "\t",
},
},
--- The quote character
--- If a field is enclosed in this character, it is treated as a single field and the delimiter in it will be ignored.
--- e.g:
--- quote_char= "'"
--- You can also specify it on the command line.
--- e.g:
--- :CsvViewEnable quote_char='
--- @type string
quote_char = '"',
--- The comment prefix characters
--- If the line starts with one of these characters, it is treated as a comment.
--- Comment lines are not displayed in tabular format.
--- You can also specify it on the command line.
--- e.g:
--- :CsvViewEnable comment=#
--- @type string[]
comments = {
-- "#",
-- "--",
-- "//",
},
},
view = {
--- minimum width of a column
--- @type integer
min_column_width = 5,
--- spacing between columns
--- @type integer
spacing = 2,
--- The display method of the delimiter
--- "highlight" highlights the delimiter
--- "border" displays the delimiter with `│`
--- see `Features` section of the README.
---@type "highlight" | "border"
display_mode = "highlight",
},
}
After opening a CSV file, use the following commands to interact with the plugin:
:CsvViewEnable [options]
: Enable CSV view with the specified options.:CsvViewDisable
: Disable CSV view.:CsvViewToggle [options]
: Toggle CSV view with the specified options.To toggle CSV view, use the following command. By default, the delimiter is ,
for CSV files and \t
for TSV files.
:CsvViewToggle
To toggle CSV view with a custom field delimiter, a custom string delimiter and comment, use the following command.
:CsvViewToggle delimiter=, quote_char=' comment=#
require('csvview').enable()
: Enable CSV view.require('csvview').disable()
: Disable CSV view.require('csvview').toggle()
: Toggle CSV view.require('csvview').is_enabled()
: Check if CSV view is enabled.Group | Default | Description |
---|---|---|
CsvViewDelimiter | link to Comment |
used for , |
CsvViewComment | link to Comment |
used for comment |
This plugin is released under the MIT License