cp.nvim/scrapers/language_ids.py
Barrett Ruth ab67270472 fix: expand language IDs, fix AtCoder submit, normalize logging
Problem: AtCoder submit used a cookie fast-path that silently failed on
stale sessions; `_LANGUAGE_ID_EXTENSION` only covered 2 of 116 languages;
`LANGUAGE_VERSIONS` was incomplete for AtCoder, CF, and Kattis; AtCoder
`prolog` and `racket` entries had wrong IDs. Raw `vim.notify` calls
throughout bypassed `logger.log`, producing inconsistent or missing
`[cp.nvim]:` prefixes.

Solution: Remove cookie persistence from AtCoder login/submit — always
use a fresh login within a single session. Increase
`BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"]` to 40s and switch to in-memory
buffer upload with the correct per-language extension. Expand
`LANGUAGE_VERSIONS` with all 116 AtCoder languages, 15 new CF languages
with full version variants (java8/21, kotlin 1.7/1.9/2.2, rust 2021/2024,
etc.), and 50+ Kattis languages. Fix AtCoder `prolog` ID (`6079`→`6081`,
was Pony) and remove non-existent `racket` entry. Replace all raw
`vim.notify` calls with `logger.log`.
2026-03-06 21:28:21 -05:00

138 lines
3.3 KiB
Python

LANGUAGE_IDS = {
"atcoder": {
"cpp": "6017",
"python": "6082",
"java": "6056",
"rust": "6088",
"c": "6014",
"go": "6051",
"haskell": "6052",
"csharp": "6015",
"kotlin": "6062",
"ruby": "6087",
"javascript": "6059",
"typescript": "6100",
"scala": "6090",
"ocaml": "6073",
"dart": "6033",
"elixir": "6038",
"erlang": "6041",
"fsharp": "6042",
"swift": "6095",
"zig": "6111",
"nim": "6072",
"lua": "6067",
"perl": "6076",
"php": "6077",
"pascal": "6075",
"crystal": "6028",
"d": "6030",
"julia": "6114",
"r": "6084",
"commonlisp": "6027",
"scheme": "6092",
"clojure": "6022",
"ada": "6002",
"bash": "6008",
"fortran": "6047",
"gleam": "6049",
"lean": "6065",
"vala": "6106",
"v": "6105",
},
"codeforces": {
"cpp": "89",
"python": "70",
"java": "87",
"kotlin": "99",
"rust": "75",
"go": "32",
"csharp": "96",
"haskell": "12",
"javascript": "55",
"ruby": "67",
"scala": "20",
"ocaml": "19",
"d": "28",
"perl": "13",
"php": "6",
"pascal": "4",
"fsharp": "97",
},
"cses": {
"cpp": "C++17",
"python": "Python3",
"java": "Java",
"rust": "Rust2021",
},
"usaco": {
"cpp": "cpp",
"python": "python",
"java": "java",
},
"kattis": {
"cpp": "C++",
"python": "Python 3",
"java": "Java",
"rust": "Rust",
"ada": "Ada",
"algol60": "Algol 60",
"algol68": "Algol 68",
"apl": "APL",
"bash": "Bash",
"bcpl": "BCPL",
"bqn": "BQN",
"c": "C",
"cobol": "COBOL",
"commonlisp": "Common Lisp",
"crystal": "Crystal",
"csharp": "C#",
"d": "D",
"dart": "Dart",
"elixir": "Elixir",
"erlang": "Erlang",
"forth": "Forth",
"fortran": "Fortran",
"fortran77": "Fortran 77",
"fsharp": "F#",
"gerbil": "Gerbil",
"go": "Go",
"haskell": "Haskell",
"icon": "Icon",
"javascript": "JavaScript (Node.js)",
"julia": "Julia",
"kotlin": "Kotlin",
"lua": "Lua",
"modula2": "Modula-2",
"nim": "Nim",
"objectivec": "Objective-C",
"ocaml": "OCaml",
"octave": "Octave",
"odin": "Odin",
"pascal": "Pascal",
"perl": "Perl",
"php": "PHP",
"pli": "PL/I",
"prolog": "Prolog",
"racket": "Racket",
"ruby": "Ruby",
"scala": "Scala",
"simula": "Simula 67",
"smalltalk": "Smalltalk",
"snobol": "SNOBOL",
"swift": "Swift",
"typescript": "TypeScript",
"visualbasic": "Visual Basic",
"zig": "Zig",
},
"codechef": {
"cpp": "C++",
"python": "PYTH 3",
"java": "JAVA",
"rust": "rust",
},
}
def get_language_id(platform: str, language: str) -> str | None:
return LANGUAGE_IDS.get(platform, {}).get(language)