-- wezterm API
local wezterm = require("wezterm")

local config = wezterm.config_builder()

config.color_scheme = {{ .drapeau.colorscheme | replace "-" " " | title | quote }}
config.enable_tab_bar = false

-- config.default_prog = { "/usr/bin/fish" }

config.enable_wayland = false

config.font = wezterm.font_with_fallback({
	{ family = "FairiesevkaTerm Nerd Font Mono" },
	{
		family = "FiraCode Nerd Font",
		harfbuzz_features = {
			"cv02",
			"cv06",
			"ss01",
			"cv14",
			"onum",
			"ss04",
			"cv18",
			"cv31",
			"cv30",
			"cv25",
			"cv26",
			"cv32",
			"ss06",
			"ss07",
		},
	},
	{ family = "Apple Color Emoji" },
})

{{ if eq .chezmoi.hostname "mairley" -}}
config.font_size = 14.0
{{ else -}}
config.font_size = 11.0
{{- end }}

config.hyperlink_rules = {
	-- Linkify things that look like URLs and the host has a TLD name.
	--
	-- Compiled-in default. Used if you don't specify any hyperlink_rules.
	{
		regex = "\\b\\w+://[\\w.-]+\\.[a-z]{2,15}\\S*\\b",
		format = "$0",
	},

	-- linkify email addresses
	-- Compiled-in default. Used if you don't specify any hyperlink_rules.
	{
		regex = [[\b\w+@[\w-]+(\.[\w-]+)+\b]],
		format = "mailto:$0",
	},

	-- file:// URI
	-- Compiled-in default. Used if you don't specify any hyperlink_rules.
	{
		regex = [[\bfile://\S*\b]],
		format = "$0",
	},

	-- Linkify things that look like URLs with numeric addresses as hosts.
	-- E.g. http://127.0.0.1:8000 for a local development server,
	-- or http://192.168.1.1 for the web interface of many routers.
	{
		regex = [[\b\w+://(?:[\d]{1,3}\.){3}[\d]{1,3}\S*\b]],
		format = "$0",
	},

	-- Make username/project paths clickable. This implies paths like the following are for GitHub.
	-- As long as a full URL hyperlink regex exists above this it should not match a full URL to
	-- GitHub or GitLab / BitBucket (i.e. https://gitlab.com/user/project.git is still a whole clickable URL)
	{
		regex = [[["]?([\w\d]{1}[-\w\d]+)(/){1}([-\w\d\.]+)["]?]],
		format = "https://www.github.com/$1/$3",
	},
}

return config
