Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim setup for conjure development ~/.config/nvim/init.vim #14

Open
humorless opened this issue Jul 8, 2020 · 3 comments
Open

neovim setup for conjure development ~/.config/nvim/init.vim #14

humorless opened this issue Jul 8, 2020 · 3 comments

Comments

@humorless
Copy link
Owner

humorless commented Jul 8, 2020

  • 在 mac 上安裝 neovim
    brew install neovim

  • 安裝 vim-plug

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  • 修改 ~/.config/nvim/init.vim
  • :source %
  • :PlugInstall
" Specify a directory for plugins.
call plug#begin(stdpath('data') . '/plugged')

" Specify your required plugins here.

" better default
Plug 'liuchengxu/vim-better-default'

" Syntax highlights                                                                                                               
Plug 'clojure-vim/clojure.vim'   

" Conjure
Plug 'Olical/conjure'

" s-expression editing
Plug 'guns/vim-sexp'
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'tpope/vim-surround'   
Plug 'jiangmiao/auto-pairs', { 'tag': 'v2.0.0' }

" rainbow parentheses
Plug 'amdt/vim-niji'

" linter 
Plug 'w0rp/ale'

" better preview window for suggestion/ auto-complete 
Plug 'ncm2/float-preview.nvim'

" syntax highlight for fennel language
Plug 'bakpakin/fennel.vim'

" color, look and feel 
Plug 'tomasr/molokai'
" install ack                                                                                                        
Plug 'mileszs/ack.vim' 
call plug#end()

" Place configuration AFTER `call plug#end()`!

let g:float_preview#docked = 0
let g:float_preview#max_width = 80
let g:float_preview#max_height = 40

let g:ale_linters = {
      \ 'clojure': ['clj-kondo', 'joker']
      \}
let maplocalleader=","
let g:ackprg = 'ack --nogroup --nocolor --column'  
tnoremap <Esc> <C-\><C-n> 

runtime! plugin/default.vim
set nonu
set norelativenumber
colorscheme molokai

function! Cljfmt()
 !cljfmt fix %
 " :e is to force reload the file after it got formatted.
 :e
endfunction

function! CljfmtSlow()
 !clojure -Sdeps '{:deps {dev.weavejester/cljfmt {:mvn/version "0.10.6"}}}' -m cljfmt.main fix %
 " :e is to force reload the file after it got formatted.
 :e
endfunction                                                                                  
                                                                                                
function! Sqlfmt()                                                                              
 !sqlformat --reindent --keywords upper --identifiers lower % -o %                              
 :e                                                                                             
endfunction

function! Yamlfmt()
 " pip install yamlfix
 !yamlfix %
 :e
endfunction

autocmd BufWritePost *.clj call Cljfmt()
autocmd BufWritePost *.cljs call Cljfmt()
@humorless humorless changed the title neovim ~/.config/nvim/init.vim neovim setup for conjure development ~/.config/nvim/init.vim Feb 10, 2021
@humorless
Copy link
Owner Author

humorless commented Feb 10, 2021

主要會使用到的 Conjure 指令:
:ConjureEval [code] 類似 fireplace 的 cqp
<localleader> ee // evaluate the form under the cursor. (e 是 inner 的諧音)
<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

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

看文章、切換到定義
K // 看 document
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

@humorless
Copy link
Owner Author

humorless commented Feb 10, 2021

使用 nvim + Conjure 來開發 ClojureScript

  1. 啟動 cljs repl
:ConjureShadowSelect [build-id]
  1. 關閉 cljs repl
:ConjureEval :cljs/quit

參考資料

@humorless
Copy link
Owner Author

humorless commented Feb 12, 2021

使用 nvim 的 terminal 來取代 tmux

  1. 進入 terminal
:terminal
  1. 從 terminal 切換成 normal mode (上文的 init.vim 改成 mapping 到 )
<C-\><C-n>
  1. 列舉所有的 buffers
    :ls
    :buffers

  2. 跳轉不同的 buffer

:b [index number]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant