local util = require("modus-themes.util")

local M = {}

--- @param colors ColorScheme
function M.generate(colors)
	local fishColors = {}
	for k, v in pairs(colors) do
		if type(v) == "string" then
			fishColors[k] = v:gsub("^#", "")
		end
	end

	local fish = util.template(
		[[
# Modus Themes for Fish
# Auto generated with https://github.com/miikanissi/modus-themes.nvim/blob/master/lua/modus-themes/extras/fish.lua

set -l foreground ${fg_main}
set -l selection ${visual}
set -l comment ${comment}
set -l red ${red}
set -l orange ${yellow_warmer}
set -l yellow ${yellow}
set -l green ${green}
set -l purple ${magenta_cooler}
set -l cyan ${cyan}
set -l pink ${magenta}

# Syntax Highlighting Colors
set -g fish_color_normal $foreground
set -g fish_color_command $cyan
set -g fish_color_keyword $pink
set -g fish_color_quote $yellow
set -g fish_color_redirection $foreground
set -g fish_color_end $orange
set -g fish_color_option $pink
set -g fish_color_error $red
set -g fish_color_param $purple
set -g fish_color_comment $comment
set -g fish_color_selection --background=$selection
set -g fish_color_search_match --background=$selection
set -g fish_color_operator $green
set -g fish_color_escape $pink
set -g fish_color_autosuggestion $comment

# Completion Pager Colors
set -g fish_pager_color_progress $comment
set -g fish_pager_color_prefix $cyan
set -g fish_pager_color_completion $foreground
set -g fish_pager_color_description $comment
set -g fish_pager_color_selected_background --background=$selection
]],
		fishColors
	)

	return fish
end

return M
