如何在Sublime REPL中运行现有的Clojure程序 [英] How to run existing Clojure programme in Sublime REPL
问题描述
我已经设置了sublime REPL(Sublime 2,MAC),并且能够运行像(+ 2 2)
这样的小型Clojure程序.我使用lein lein new app clojure-noob
创建了一个小项目,并且可以通过lein repl
运行它.并加载项目内部定义的主类.如何在Sublime REPL中加载相同的主类.
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.
推荐答案
您需要做的就是在Sublime中打开项目的project.clj
文件,确保它具有焦点,然后选择 Tools → SublimeREPL → Clojure → Clojure
>.这将在project.clj
的文件夹中运行lein repl
.
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.
如果您不想通过太多子菜单来打开REPL,则可以执行以下操作:
If you'd prefer to not have to go through so many submenus to open the REPL, you can do this:
- 选择
Preferences → Browse Packages…
,以在Finder中打开Packages
文件夹(~/Library/Application Support/Sublime Text 3/Packages
). - 转到
User
文件夹并创建以下层次结构:Packages/User/SublimeREPL/config/Clojure
. - 在
Clojure
中创建一个名为Main.sublime-menu
的新文件,并使用JSON语法在Sublime中打开它. -
将以下内容添加到文件中:
- Select
Preferences → Browse Packages…
to open thePackages
folder (~/Library/Application Support/Sublime Text 3/Packages
) in Finder. - Go to the
User
folder and create the following hierarchy:Packages/User/SublimeREPL/config/Clojure
. - Create a new file in
Clojure
calledMain.sublime-menu
and open it in Sublime with the JSON syntax. 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"}
}
}
]
}
]
保存文件后,现在将具有 Tools → Clojure
菜单选项.
Once you save the file, you will now have a Tools → Clojure
menu option.
这篇关于如何在Sublime REPL中运行现有的Clojure程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!