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

format.register({
	name = "Tab-Separated Values (TSV)",
	shortname = "TSV",
	author = "liqube",
	extensions = "tsv",
	disable_tab_autocomplete = true,
	defaults = {
		word_wrap = false, -- Keep lines unwrapped by default
	},

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

		{ pattern = "[\t]", 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 = "[^\t\n]+", type = "normal" }, -- everything else
	},
})
