Syntax for rust-analyzer.files.excludeDirs in NeoVim Kickstart `init.lua`

What is the correct syntax for configuring rust-analyzer.files.excludeDirs in Kickstart's init.lua for NeoVim?

I.e., how should the following code snippet be modified to exclude two directories, "foo" and "bar", in the root of any Cargo Rust project in which NeoVim is editing a .rs file?

local servers = {
  rust_analyzer = {}
}

Kickstart version 56b9114bf29cdc0c0f5de78b5deae1fe0ab65db1

NeoVim installed as an app.image:
NVIM v0.11.0-dev-207+g20f22f75e
Build type: RelWithDebInfo
LuaJIT 2.1.1716656478

extra server specific settings should be put under a settings key, and the value is just a table containing the actual settings.

for your example, the rust-analyzer.files.excludeDirs configuration is expected to contain a list of (relative) paths. the following example I use a variable to hold all the settings, just to reduce some nested levels. you can inline the variable if you prefer.

-- note: hyphenated word is not valid identifier in Lua, must use full syntax
-- my_ra_settings["rust-analyzer"].files.excludeDirs = {"foo", "bar"}
local my_ra_settings = {
  ["rust-analyzer"] = {
    files = {
      excludeDirs = {
        "foo",
        "bar",
      }
    }
  }
}
local servers = {
  rust_analyzer = {
    settings = my_ra_settings
  }
}
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.