How to run existing Clojure programme in Sublime REPL

本秂侑毒 提交于 2019-12-08 13:11:50

问题


I have setup sublime REPL(Sublime 2, MAC) and able to run small Clojure programs like (+ 2 2). I have created a small project using lein lein new app clojure-noob and I am able to run it via lein repl. And it loads the main class defined inside the project. How can I load the same main class in Sublime REPL.


回答1:


All you need to do is open your project's project.clj file in Sublime, make sure it has focus, then select Tools → SublimeREPL → Clojure → Clojure. This runs lein repl in project.clj's folder.

If you'd prefer to not have to go through so many submenus to open the REPL, you can do this:

  1. Select Preferences → Browse Packages… to open the Packages folder (~/Library/Application Support/Sublime Text 3/Packages) in Finder.
  2. Go to the User folder and create the following hierarchy: Packages/User/SublimeREPL/config/Clojure.
  3. Create a new file in Clojure called Main.sublime-menu and open it in Sublime with the JSON syntax.
  4. Add the following to the file:

    [
         {
            "id": "tools",
            "children":
            [
                {"command": "repl_open",
                 "caption": "Clojure",
                 "id": "repl_clojure",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": {"windows": ["lein.bat", "repl"],
                            "linux": ["lein", "repl"],
                            "osx":  ["lein", "repl"]},
                    "soft_quit": "\n(. System exit 0)\n",
                    "cwd": {"windows":"c:/Clojure",
                            "linux": "$file_path",
                            "osx": "$file_path"},
                    "syntax": "Packages/Clojure/Clojure.tmLanguage",
                    "external_id": "clojure",
                    "extend_env": {"INSIDE_EMACS": "1"}
                    }
                }
            ]
        }
    ]
    
  5. Once you save the file, you will now have a Tools → Clojure menu option.



来源:https://stackoverflow.com/questions/38042375/how-to-run-existing-clojure-programme-in-sublime-repl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!