設定
github.com
- vim-lsp-settingsの本家のサイトへ行ってみてください
- plugでのinstall方法が書かれているのでそれに従ってinstallします
mapping
- コマンドの割り当てはplug mappingを使用したらいいとmattnさんに教えて貰いました。
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> ,n <plug>(lsp-next-error)
nmap <buffer> ,p <plug>(lsp-previous-error)
nmap <buffer> <F2> <plug>(lsp-rename)
- 上記の方法だとbufferにだけ適用されます
- 無難に適用しようとするとこちらの方がいいという話もききました
nmap <F12> <Plug>(lsp-definition)
nmap ,n <plug>(lsp-next-error)
nmap ,p <plug>(lsp-previous-error)
nmap <F2> <plug>(lsp-rename)
- ただ、最初の方法はやり方がちゃんとあって
- kaoriyaさんが書いた拡張を教えて貰いました。
.vim/plugin/lsp-common.vim
ここに置くらしいです
scriptencoding utf-8
function! s:on_lsp_buffer_enabled() abort
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> <f2> <plug>(lsp-rename)
endfunction
augroup lsp_install
au!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
rust側
github.com
- 上記に書かれていますが
- rls等のインストールが必要です
rustup update
rustup component add rls rust-analysis rust-src
動作しない場合
lspコマンドがインストールされてない
lsp
- installされてなければ
- このようなメッセージがでます
error: 'rls' is not installed for the toolchain 'stable-x86_64-apple-darwin'
To install, run `rustup component add rls --toolchain stable-x86_64-apple-darwin`
set hiddenが無い
- vim-lsp-settingsの機能と関係があるんと思うんですが
- set hiddenが無いと美味く動作しない様です
set hidden