-- lx format
local format = require("core.format")

format.register({
	name = "Pipe-Separated Values (PSV)",
	shortname = "PSV",
	author = "liqube",
	extensions = "psv",
	default_mode = "preview", -- Render delimited rows through tabpreview
	disable_tab_autocomplete = true,
	defaults = {
		word_wrap = false, -- Keep lines unwrapped by default
	},

	patterns = {
		-- First four columns get dedicated styles
		{ pattern = "[^%|\n]+", type = "literal", line_start = true },
		{ pattern = "[^%|\n]+", type = "function", line_prefix = "[^%|\n]*%|" },
		{ pattern = "[^%|\n]+", type = "operator", line_prefix = "[^%|\n]*%|[^%|\n]*%|" },
--		{ pattern = "[^%|\n]+", type = "literal",  line_prefix = "[^%|\n]*%|[^%|\n]*%|[^%|\n]*%|" },

		{ pattern = "%|", type = "operator" }, -- separators
		{ pattern = { '"', '"', "\\" }, type = "string" }, -- quoted text (col 5+ fallback)
		{ pattern = { "'", "'", "\\" }, type = "string" }, -- quoted text (col 5+ fallback)
		{ pattern = "-?%.?%d+f?", type = "number" }, -- numbers (col 5+ fallback)
		{ pattern = "[^%|\n]+", type = "normal" }, -- everything else
	},
})
