This plugin will add completion for the values of an arbitrary column of a csv
-file.
{
'PhilippFeO/cmp-csv',
opts = {
-- see below
}
}
There are currently two options, one, csv_path
, is mandatory.
require('cmp-csv').setup({
documentation_format = '',
csv_path = '' -- No csv, no party 😞
filetype = '',
completion_column = 1,
skip_rows = 0
})
documentation_format
: Lua format string, should contain three%s
. No checks are performed, example:%s (Col 1)\n%s (Col 2)\n%s (Col 3)
.csv_path
: Path to thecsv
-file to generated sources for nvim-cmp. Without acsv
-file no sources can be established andsetup()
will fail. No consistency checks for thecsv
are performed1.filetype
: In which buffers we wish to have the completion.completion_column
: Which column of your CSV is used for syntax completion. If it exceeds the number of values in one row, an error is thrown.skip_rows
: First rows to skip in case there are header information. An error is thrown ifskip_rows
exceeds the line number ofcsv_path
.
Enabling within nvim-cmp
require("cmp").setup({
sources = {
{ name = "cmp_csv" }, -- '_' not '-' 😯
}
})
- TJ DeVires video on nvim-cmp was a great help and is an inspiration: TakeTuesday E01: nvim-cmp
Footnotes
-
Currently, no space(s) around the
,
are skipped, ie.John ,...
will captureJohn
(there is a whitespace afterJohn
). ↩