clojure开发环境配置git, vscode插件配置

万事开头难,全是犄角旮旯的细节。html

1 安装lein

参见 http://www.javashuo.com/article/p-rrbfyozl-kk.htmlgit

2 建立工程 lein 

参考https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.mdgithub

lein new my-project

3 关联git

由于lein必须从没有文件夹的状态开始建立,因此不能直接从远程库建立好pull下来。visual-studio-code

前置条件:ide

  1在远程仓库建立了工程visual-studio

  2在本地用lein建立了工程atom

关联:spa

cd my-project
git init
git remote add origin git@XXX:YYY/my-project.git

git init 在工程里创建空的git库。而后关联到远程仓库插件

后面再提交就和别的工程同样了。code

——仍是不如ng-cli舒服,这种就应该能够在非空文件夹,或者包含.git的文件夹建立工程,能够省去 关联这一步

 4 安装code插件

主要是calva和 clojure

这2个各有利弊,最上面这个clojure好像对ClojureScript支持的通常,没有calva好。可是启动好像稍微简单点,因此装机量也多。

4.1 Clojure

直接叫clojure  https://github.com/avli/clojureVSCode

改porject.clj里 :profiles部分 

  :profiles {:uberjar {:aot :all}
             :repl {:plugins [[cider/cider-nrepl "0.21.1"]] :dependencies [[nrepl "0.6.0"] [cider/piggieback "0.4.0"] [figwheel-sidecar "0.5.18"]] :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}  :user {:plugins [[cider/cider-nrepl "0.21.1"]] :dependencies [[org.clojure/tools.nrepl "0.2.13"] [cljfmt "0.5.7"]]} })

若是正常,应该每次开启vscode的clojure项目时,在下面自动链接nrepl:过几秒钟:

这就表示连上了

如何运行脚本

在sublime里习惯ctrl+B运行py了,那么要运行clj呢?

参考https://spin.atomicobject.com/2017/06/22/clojure-development-with-visual-studio-code/

在文件-首选项-键盘快捷方式里

先搜索ctrl+B  vscode默认是显隐侧边栏,这个我不经常使用,直接用鼠标按侧边按钮代替,因此删除这个

而后搜索 Clojure 会有个 eval and show the result 命令, 把Ctrl+B绑这个上

 随便新建个文件,而后写两笔,按ctrl+B就能在下面看到运行结果了:

美中不足,每次运行不会清屏,相似matlab,而不是sublime。 

 

 

4.2 Calva

 

 

而后,参考https://github.com/BetterThanTomorrow/calva/wiki/Getting-Started

把porject.clj里 :profiles部分修改为

  :profiles {:uberjar {:aot :all}
 :repl {:plugins [[cider/cider-nrepl "0.21.2-SNAPSHOT"]] :dependencies [[nrepl "0.6.0"] [cider/piggieback "0.4.0"] [figwheel-sidecar "0.5.18"]] :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}
             })

退出在从新开启code,点开任何1个clj文件,会开始安装这些玩意

而后 :

1 ctrl+` 启动控制台

2在控制台lein repl 启动环境 这时候会随机分配1个端口号

nREPL server started on port 37749 on host 127.0.0.1 - nrepl://127.0.0.1:37749

3 点击code下边栏 nREPL标志,弹出对话框,端口应该已经输入进去了 enter确认

若是上面不弹窗,就先同时按ctrl+alt+v  再按 c

 

看到变成彩色的,说明成功

相关文章
相关标签/搜索