nvim: fix handling of tabs/spaces for shfmt
formatter
This commit is contained in:
parent
73da48e6e6
commit
24fe53f1cc
1 changed files with 24 additions and 1 deletions
|
@ -1,3 +1,26 @@
|
||||||
|
local shfmt = function()
|
||||||
|
local indent = 0 -- Assume tabs initially.
|
||||||
|
if vim.opt.expandtab:get() then
|
||||||
|
local shiftwidth = vim.opt.shiftwidth:get()
|
||||||
|
if shiftwidth == 0 then
|
||||||
|
indent = vim.opt.tabstop:get()
|
||||||
|
else
|
||||||
|
indent = shiftwidth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
exe = "shfmt",
|
||||||
|
-- stylua: ignore start
|
||||||
|
args = {
|
||||||
|
"--indent", indent, -- 0 for tabs, >0 for number of spaces.
|
||||||
|
"--keep-padding", -- Keep column alignment paddings.
|
||||||
|
},
|
||||||
|
-- stylua: ignore end
|
||||||
|
stdin = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"mhartington/formatter.nvim",
|
"mhartington/formatter.nvim",
|
||||||
|
|
||||||
|
@ -28,7 +51,7 @@ return {
|
||||||
lua = { builtin.lua.stylua },
|
lua = { builtin.lua.stylua },
|
||||||
markdown = { builtin.markdown.prettier },
|
markdown = { builtin.markdown.prettier },
|
||||||
python = {}, -- TODO: pick one
|
python = {}, -- TODO: pick one
|
||||||
sh = { builtin.sh.shfmt },
|
sh = { shfmt() },
|
||||||
zsh = { builtin.zsh.beautysh },
|
zsh = { builtin.zsh.beautysh },
|
||||||
-- stylua: ignore end
|
-- stylua: ignore end
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue