#!/usr/bin/env python3
import json
import sys
import urllib.request


UA = f"lean-unicode.vim/regenerate ({sys.version})"
TRANSLATIONS_URL = "https://raw.githubusercontent.com/leanprover/vscode-lean/master/translations.json"

SNIPPET = r"""
snippet "\{translate}" "" w
{to}
endsnippet
"""

sys.stdout.write("# This file is autogenerated via lean-unicode.vim\n")

with urllib.request.urlopen(TRANSLATIONS_URL) as response:
    for translate, to in json.load(response).items():
        sys.stdout.write(SNIPPET.format(translate=translate, to=to))
