@Patrick Massot I got it up to date (at least as far as getting it to run):
reformat.lean
/-Copyright (c) 2021 Microsoft Corporation. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Gabriel Ebner-/importLeanopenLeanElabPrettyPrinterpartialdefgetCommands(cmds:Syntax):StateT(ArraySyntax)IdUnit:=doifcmds.getKind==nullKind||cmds.getKind==``Parser.Module.headerthenforcmdincmds.getArgsdogetCommandscmdelsemodify(·.pushcmds)partialdefreprintCore:Syntax→OptionFormat|Syntax.missing=>none|Syntax.atom_val=>val.trim|Syntax.ident_rawVal__=>rawVal.toString|Syntax.node_kindargs=>matchargs.toList.filterMapreprintCorewith|[]=>none|[arg]=>arg|args=>Format.group<|Format.nest2<|Format.line.joinSepargsdefreprint(stx:Syntax):Format:=reprintCorestx|>.getD""defprintCommands(cmds:Syntax):CoreMUnit:=doforcmdingetCommandscmds|>.run#[]|>.2dotryIO.println(←ppCategory`commandcmd).prettycatche=>IO.printlnf!"/-\ncannot print: {← e.toMessageData.format}\n{reprint cmd}\n-/"deffailWith(msg:String)(exitCode:UInt8:=1):IOα:=do(←IO.getStderr).putStrLnmsgIO.Process.exitexitCodestructureCommandSyntaxwhereenv:EnvironmentcurrNamespace:Name:=Name.anonymousopenDecls:ListOpenDecl:=[]stx:SyntaxdefparseModule(input:String)(fileName:String)(opts:Options:={})(trustLevel:UInt32:=1024):IO<|ArrayCommandSyntax:=doletmainModuleName:=Name.anonymous-- FIXMEletinputCtx:=Parser.mkInputContextinputfileNamelet(header,parserState,messages)←Parser.parseHeaderinputCtxlet(env,messages)←processHeaderheaderoptsmessagesinputCtxtrustLevelletenv:=env.setMainModulemainModuleNameletenv0:=envlets←IO.processCommandsinputCtxparserState{Command.mkStateenvmessagesoptswithinfoState:={enabled:=true}}lettopLevelCmds:ArrayCommandSyntax←s.commandState.infoState.trees.toArray.mapMfun|InfoTree.context{env,currNamespace,openDecls,..}(InfoTree.node(Info.ofCommandInfo{stx,..})_)=>pure{env,currNamespace,openDecls,stx}|_=>failWith"unknown info tree"return#[{env:=env0,stx:=header:CommandSyntax}]++topLevelCmdsunsafedefmain(args:ListString):IOUnit:=dolet[fileName]:=args|failWith"Usage: reformat file"initSearchPath(←findSysroot)letinput←IO.FS.readFilefileNameletmoduleStx←parseModuleinputfileNameletleadingUpdated:=mkNullNode(moduleStx.map(·.stx))|>.updateLeading|>.getArgsletmutfirst:=truefor{env,currNamespace,openDecls,..}inmoduleStx,stxinleadingUpdateddoiffirstthenfirst:=falseelseIO.print"\n"let_←printCommandsstx|>.toIO{currNamespace,openDecls,fileName,fileMap:=fileName.toFileMap}{env}
It only uses the info tree superficially though to extract the syntax tree and environment of each command. The language server is the main user of the info tree.