From e29f99c1f2fd57fa99039a16d1ded7a725961e1f Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Fri, 19 Jan 2024 14:24:11 -0500 Subject: [PATCH] fix(nvim): Re-enable rust_analyzer optimizations --- nvim/lua/my/lsp/rust.lua | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/nvim/lua/my/lsp/rust.lua b/nvim/lua/my/lsp/rust.lua index 6660e46c..7dfb5fea 100644 --- a/nvim/lua/my/lsp/rust.lua +++ b/nvim/lua/my/lsp/rust.lua @@ -1,25 +1,23 @@ return { - -- before_init = function(_, config) - -- -- Override clippy to run in its own directory to avoid clobbering caches - -- -- but only if target-dir isn't already set in either the command or the extraArgs - -- local checkOnSave = config.settings['rust-analyzer'].checkOnSave - -- local needle = '--target-dir' - -- if string.find(checkOnSave.command, needle, nil, true) then - -- return - -- end - -- - -- checkOnSave.extraArgs = checkOnSave.extraArgs or {} - -- for _, v in pairs(checkOnSave.extraArgs or {}) do - -- if string.find(v, needle, nil, true) then - -- return - -- end - -- end - -- - -- p({ 'before', checkOnSave.extraArgs, checkOnSave.command }) - -- local target_dir = config.root_dir .. '/target/ide-clippy' - -- table.insert(checkOnSave.extraArgs, '--target-dir=' .. target_dir) - -- p({ 'after', checkOnSave.extraArgs }) - -- end, + before_init = function(_, config) + -- Override clippy to run in its own directory to avoid clobbering caches + -- but only if target-dir isn't already set in either the command or the extraArgs + local checkOnSave = config.settings['rust-analyzer'].checkOnSave + local needle = '--target-dir' + if string.find(checkOnSave.command, needle, nil, true) then + return + end + + checkOnSave.extraArgs = checkOnSave.extraArgs or {} + for _, v in pairs(checkOnSave.extraArgs or {}) do + if string.find(v, needle, nil, true) then + return + end + end + + local target_dir = config.root_dir .. '/target/ide-clippy' + table.insert(checkOnSave.extraArgs, '--target-dir=' .. target_dir) + end, settings = { ['rust-analyzer'] = { checkOnSave = {