diff options
author | Micah Halter <micah@mehalter.com> | 2024-07-01 13:58:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-01 10:58:55 -0700 |
commit | cd75be867f2331b22905f47d28c0c270a69466aa (patch) | |
tree | 026bb2bd83bacad4e12e590b67073d4472197733 /lua/conform/runner.lua | |
parent | fc19dfc0e7d0f5e9f01cd42a4c518e030b3790f0 (diff) |
feat(shfmt): add automatic indentation detection (#481)
* feat(shfmt): automatically detect indentation
* fix(markdown-toc): improve correctness of indentation size calculation
* fix(djlint): improve correctness of indentation size calculation
* feat: add effective `shiftwidth` to `conform.Context`
this also refactors formatters that automatically set indentation level
to use the new shiftwidth context
Diffstat (limited to 'lua/conform/runner.lua')
-rw-r--r-- | lua/conform/runner.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lua/conform/runner.lua b/lua/conform/runner.lua index 3831198..c0a19cd 100644 --- a/lua/conform/runner.lua +++ b/lua/conform/runner.lua @@ -450,6 +450,11 @@ M.build_context = function(bufnr, config, range) end local filename = vim.api.nvim_buf_get_name(bufnr) + local shiftwidth = vim.bo[bufnr].shiftwidth + if shiftwidth == 0 then + shiftwidth = vim.bo[bufnr].tabstop + end + -- Hack around checkhealth. For buffers that are not files, we need to fabricate a filename if vim.bo[bufnr].buftype ~= "" then filename = "" @@ -482,6 +487,7 @@ M.build_context = function(bufnr, config, range) filename = filename, dirname = dirname, range = range, + shiftwidth = shiftwidth, } end |