rust-clippyはrustcのAPIを利用しており、clippyのソースコードを編集する際、デフォルトではrust-analyzerの補完が効かない.
そのためrust-analyzerに対し以下の設定が必要.
{ "rust-analyzer.rustc.source": "discover" }
これをrust-tools.nvimで設定する方法が若干わかりづらかったのでメモ.
TL;DR
結論、以下の様にserverに対しsettings.["rust-analyzer"]を渡す.
require('rust-tools').setup({
server = {
settings = {
["rust-analyzer"] = {
rustc = {
source = "discover"
}
}
}
}
})
rust-toolsの#configurationの項を見ると、rust-analyzerへのオプションを渡すserverが用意されていることがわかる.
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- standalone file support
-- setting it to false may improve startup time
standalone = true,
}, -- rust-analyzer options
all the opts to send to nvim-lspconfig
とあるので、nvim-lspconfigでの設定をそのままrust-toolsのserverに記述すればよいのだが、当時の自分は"そうは言っても["rust-analyzer"]ディレクティブに渡すのだろう"と思い込みんでいた.
Comments