Wednesday, July 8, 2020

Neovim + Conjure

友人推荐我試用看看 Neovim + Conjure 來取代 vim + fireplace 。我試了之後,覺得整體而言,算是又改進了一些些,這邊簡單記錄一下 Conjure 的用法。

主要會使用到的 Conjure 指令:
:ConjureEval [code]                類似 fireplace 的 cqp
<localleader> ee    // evaluate the form under the cursor.  (e 是 inner 的諧音)
<localleader> ece  // Evaluates the form under the cursor and displays the
                         result as a comment at the end of the line or below
                         the current line if you already have a comment there.
<localleader> er    //  evaluate the root form under the cursor. (r 是 outer 的諧音)
<localleader> e!     // evaluate the form under the cursor and replace it.  (! 意指 side effect)

類似 fireplace     :Require 的功能,重新載入整個檔案。
<localleader> eb   // evaluate the current buffer
<localleader> ef    // evaluate the current file from disk

快速檢查特定變數的『值』
<localleader> ew   // evaluate the current word
<localleader> ecw  // Evaluates the word under the cursor and displays the
                         result as a comment at the end of the line or below
                         the current line if you already have a comment there.

開啟 log buffer  的指令
<localleader> ls            // 水平開啟
<localleader> lv           //  垂直開啟
<localleader> lq           //  關閉


看文章、切換到定義
K                               //  Look up documentation for the word under the cursor.
<localleader> gd          //  跳轉到定義

貼上最後一次 evaluation 的結果。 ( 與 nvim register 的『組合功能』)
"cp                            // 上一次 evaluation 的結果會自動存放在 "c 這個 register 裡。
:reg                           // 可以顯示所有的 registers 的內容

對某一特定的 expression 遠端求值。 (與 nvim mark 的『組合功能』)
mf                               // 標記「位值」於 mark f 
<localleader> emf          // 對 mark f 的 expression 做求值。

對被反白的區塊 expression 做求值。 (與 nvim 反白選取的『組合功能』)
<localleader>E              // evaluate visual selection 

應用於 ClojureScript + shadow-cljs
:ConjureShadowSelect [build-id]        // 啟動 cljs repl ([build-id] 是 symbol 非 keyword)
:ConjureEval :cljs/quit                       // 關閉 cljs repl