wuub / SublimeREPL

SublimeREPL - run an interpreter inside ST2 (Clojure, CoffeeScript, F#, Groovy, Haskell, Lua, MozRepl, NodeJS, Python, R, Ruby, Scala, shell or configure one yourself)
https://github.com/wuub/SublimeREPL
Other
2.14k stars 312 forks source link

How can I make a REPL for Wolfram Mathematica? #561

Open nimafazeli opened 6 years ago

nimafazeli commented 6 years ago

I am not a programmer but I have been trying to get sublime repl to work for wolfram mathematica mostly by trial and error. So any hint on what is the systematic way to do it is appreciated.

Based on the documentations I created two new files in the repl config folder: Default.sublime-command and Main.sublime-menu and made some changes to fit mathematica and also the command line tool that mathematica uses. However I had no success and I tried all the combinations I could think of.

here is an instance of configs that I used

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "R",
            "id": "SublimeREPL",
            "children":
            [
                {"command": "repl_open",
                 "caption": "Mathematica",
                 "id": "repl_mathematica",
                 "mnemonic": "M",
                 "args": {
                    "type": "subprocess",
                    "encoding": "WindowsANSI", //mathematica gives me this
                    // "encoding": "$win_cmd_encoding", //other repls use this
                    // "encoding": "utf8", //To try
                    // "encoding": "", //PowerShell uses this
                    // "encoding": {
                    //     "windows": "$win_cmd_encoding",
                    //     "linux": "utf8",
                    //     "osx": "utf8"
                    //     },
                    // "cmd":  "wolfram.exe" ,
                    // "cmd": ["C:/Program Files/Wolfram Research/Mathematica/10.4/wolfram.exe"],
                    "cmd": ["wolfram.exe"],
                    // "cmd": ["wolfram.exe" , "-wstp"],
                    // "cmd": ["wolfram.exe", "-rawterm", "-noinit"],
                    // "cmd": ["wolfram.exe", "-noinit"],
                    // "cmd": ["wolfram.exe", "MATHKERNELINIT"],
                    // "cmd": ["math"],
                    // "cmd": ["math.exe"],
                    // "cmd":  "MathKernel.exe" ,
                    // "cmd": ["powershell", "-"],
                    // "cwd": "$file_path",
                    // "cmd_postfix": "\n", //Some repls use this
                    "external_id": "mathematica",
                    "env": {},
                    // "suppress_echo": {"osx": true,
                    //                   "linux": true,
                    //                   // "windows": false},
                    //                   "windows": true},
                    "syntax": "Packages/WolframLanguage/WolframLanguage.sublime-syntax"
                    }
                }
            ]
        }]
    }
]

I have commented out some of the configs that I tried. And here is my .sublime-command file

[
    {
        "caption": "SublimeREPL: Mathematica",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_mathematica",
            "file": "config/Mathematica/Main.sublime-menu"
        }
    }
]

The odd thing is that when I load PowerShell REPL, I can run wolfram.exe or math.exe and I can use it. I am on windows 10 and I use Mathematica 10. Any hint on how to do it is appreciated.