Skip to content

Commit

Permalink
fix(enable_clippy): apply type checks to avoid unintended overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryex authored May 20, 2024
1 parent 116615a commit 82be976
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/rustaceanvim/config/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -151,3 +154,4 @@ function server.create_client_capabilities()
end

return server

0 comments on commit 82be976

Please sign in to comment.