From 82be9764b72c845518eae3a0664efaf59319f304 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Mon, 20 May 2024 02:53:40 -0700 Subject: [PATCH] fix(enable_clippy): apply type checks to avoid unintended overwrite --- lua/rustaceanvim/config/server.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/rustaceanvim/config/server.lua b/lua/rustaceanvim/config/server.lua index c4206929..3c6a37db 100644 --- a/lua/rustaceanvim/config/server.lua +++ b/lua/rustaceanvim/config/server.lua @@ -22,15 +22,18 @@ function server.load_rust_analyzer_settings(project_root, opts) local default_settings = opts.default_settings or config.server.default_settings local use_clippy = config.tools.enable_clippy and vim.fn.executable('cargo-clippy') == 1 ---@diagnostic disable-next-line: undefined-field - if default_settings['rust-analyzer'].check == nil and use_clippy then + if default_settings['rust-analyzer'].check == nil and use_clippy and + type(default_settings['rust-analyzer'].checkOnSave) ~= 'table' then ---@diagnostic disable-next-line: inject-field default_settings['rust-analyzer'].check = { allFeatures = true, command = 'clippy', extraArgs = { '--no-deps' }, } - ---@diagnostic disable-next-line: inject-field - default_settings['rust-analyzer'].checkOnSave = true + if type(default_settings['rust-analyzer'].checkOnSave) ~= 'boolean' then + ---@diagnostic disable-next-line: inject-field + default_settings['rust-analyzer'].checkOnSave = true + end end if not project_root then return default_settings @@ -151,3 +154,4 @@ function server.create_client_capabilities() end return server +