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

format.register({
	name = "Pipe-Separated Values (PSV)",
	shortname = "PSV",
	author = "liqube",
	extensions = "psv",
	disable_tab_autocomplete = true,

	patterns = {
		-- First four PSV 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
	},
})
