こんにちは、弊社唯一のemacsユーザの @takeokunn です。
最近ブログを書いていなかったのでそろそろやらねば...ということで筆を取りました。
はじめに
UUUMには 会社公認サークル #circle-vim というものがあります。
サークルメンバーはvim歴が浅い人が多く約10人(幽霊含み)いて、日々 BTO会長 を中心に素vim力を高めるべく精進をしていました。
が、BTO会長の会社卒業を期にneovimで闇の力を得ようと様々なpluginを突っ込んで新たな力を得ようという方針になってきているので、今回はその活動報告をしていこうと思います。
neovimを使えるようにする
homebrewでサクッと入ります。
$ brew install --HEAD neovim
ちなみに、僕はubuntuユーザなので自前でbuildをしました。
$ ghq get https://github.com/neovim/neovim $ cd ~/.ghq/github.com/neovim/neovim $ make -j $ sudo make install
dotfilesを整える
我らがvimサー会長BTOさんの 汎用性・拡張性の高い dotfiles 環境を作る という記事を参考に皆各々dotfilesを作っています。
僕はvimとnvimを以下のように使い分けて管理しています
plugin紹介
swoop
言わずと知れた検索/置換ライブラリ。emacsでは愛用していたのでnvimでも是非入れたかった逸品。
vim-swoop
では検索し終わった後にbufferを消してくれなかったのでしょうがなくkeybindにdeleteする処理を追加しました。
また、現在のカーソルの文字列を取得して検索する自前の関数を作りました。
function! MySwoop() let word = expand('<cword>') if len(word) > 0 call SwoopPattern(word) else call Swoop() end endfunction nnoremap <silent> ,s :call MySwoop()<CR> nnoremap <silent> ,q :bdelete! swoopBuf<CR>
EmacsLispだとこんな感じ
(use-package swoop :config (setq swoop-minibuffer-input-dilay 0.4) (defun my/swoop-from-isearch () (interactive) (let* ((symbol (thing-at-point 'symbol 'no-properties))) (swoop symbol)))) (define-key ivy-mode-map (kbd "C-o") 'my/swoop-from-isearch)
vim-multiple-cursors
url: terryma/vim-multiple-cursors
みんな大好きmultiple cursor。良いですね大好きです。
emacsだと smartrep
と multiple-cursors
を組み合わせてやるしかなくて結構たいへんです。
(use-package multiple-cursors :init (require 'smartrep) (declare-function smartrep-define-key "smartrep") (bind-key "C-M-c" 'mc/edit-lines) (bind-key "C-M-r" 'mc/mark-all-in-region) (global-unset-key (kbd "C-t")) (smartrep-define-key global-map "C-t" '(("C-t" . 'mc/mark-next-like-this) ("n" . 'mc/mark-next-like-this) ("p" . 'mc/mark-previous-like-this) ("m" . 'mc/mark-more-like-this-extended) ("u" . 'mc/unmark-next-like-this) ("U" . 'mc/unmark-previous-like-this) ("s" . 'mc/skip-to-next-like-this) ("S" . 'mc/skip-to-previous-like-this) ("*" . 'mc/mark-all-like-this) ("d" . 'mc/mark-all-like-this-dwim) ("i" . 'mc/insert-numbers) ("o" . 'mc/sort-regions) ("O" . 'mc/reverse-regions))))
Shougo/denite.nvim
url: Shougo/denite.nvim
最高のPlugin、とにかく最高のplugin。顧客が求めていた全てが詰まっている最高のPluginです。
bufferの検索、project内grep、file検索、outline検索など欲しかったものを全て提供してくれています。
「これがあればfzf要らないんじゃね?」と思ったが、共存の道を探っている部員もいます。
" config autocmd FileType denite call s:denite_my_settings() function! s:denite_my_settings() abort nnoremap <silent><buffer><expr> <CR> \ denite#do_map('do_action') nnoremap <silent><buffer><expr> d \ denite#do_map('do_action', 'delete') nnoremap <silent><buffer><expr> p \ denite#do_map('do_action', 'preview') nnoremap <silent><buffer><expr> q \ denite#do_map('quit') nnoremap <silent><buffer><expr> <Esc> \ denite#do_map('quit') nnoremap <silent><buffer><expr> i \ denite#do_map('open_filter_buffer') nnoremap <silent><buffer><expr> <Space> \ denite#do_map('toggle_select').'j' endfunction " keybind nnoremap <silent> ,k :Denite file/rec<CR> nnoremap <silent> ,b :Denite buffer<CR> nnoremap <silent> ,o :Denite outline<CR> nnoremap <silent> ,r :Denite file/old<CR> nnoremap <silent> ,h :Denite command_history<CR> nnoremap <silent> ,g :Denite grep<CR>
emacsだと abo-abo/swiper がこれに当たるのですが、こういうインターフェースで提供できたら最高だなって思わされました。
終わりに
「emacsのこのpluignや機能、nvimでもほしいな」「nvimのこのpluignや機能、emacsでもほしいな」といった感じでお互いを高めあえれば最高だと思いました。
dark poweredシリーズやLSPなどの設定をもっともっとやって快適なvimライフを送りたいです。
弊社ではvim/neovimを完全に理解しているプログラマを募集しています。