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 785
Source specific Configuration
Santo Cariotti edited this page Jan 8, 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,
}),
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,
})