This repository has been archived by the owner on Aug 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 791
Source specific Configuration
Jose Alvarez edited this page Mar 12, 2022
·
8 revisions
This page documents extended / advanced configurations for specific sources.
The configurations here are user-maintained and not guaranteed to work. If something is broken, fix it! If something is missing, add it!
Helpful when you have projects with different tabwidth in HTML, often in combination with .editorconfig
.
null_ls.builtins.formatting.djhtml.with({
extra_args = function(params)
return {
"--tabwidth",
vim.api.nvim_buf_get_option(params.bufnr, "shiftwidth"),
}
end,
}),
The pydocstyle
config discovery ignores the CWD and searches configuration starting at the file location. Since null-ls has to use a temporary file to call pydocstyle
it won't find the project configuration.
A workaround is to pass the config-filename to use:
local sources = {
null_ls.builtins.diagnostics.pydocstyle.with({
extra_args = { "--config=$ROOT/setup.cfg" }
}),
}
Note: If you are using
rust-analyzer
, format withrust-analyzer
. It reads edition fromCargo.toml
.
Choose one of the following:
- specify in
rustfmt.toml
.
edition = "2021"
- hardcode it.
null_ls.builtins.formatting.rustfmt.with({
extra_args = { "--edition=2021" }
})
- read from
Cargo.toml
.
null_ls.builtins.formatting.rustfmt.with({
extra_args = function(params)
local Path = require("plenary.path")
local cargo_toml = Path:new(params.root .. "/" .. "Cargo.toml")
if cargo_toml:exists() and cargo_toml:is_file() then
for _, line in ipairs(cargo_toml:readlines()) do
local edition = line:match([[^edition%s*=%s*%"(%d+)%"]])
if edition then
return { "--edition=" .. edition }
end
end
end
-- default edition when we don't find `Cargo.toml` or the `edition` in it.
return { "--edition=2021" }
end,
})