Skip to content

Commit 5e2d7e1

Browse files
authored
changed Conform's format_on_save lambda so that buffers that match disable_filetypes return nil. This allows you to enable a formatter for langages in the disable_filetypes table to have a formatter that can be run manually with Leader-f but doesnt enable format_on_save for them (nvim-lua#1395)
1 parent 2abcb39 commit 5e2d7e1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

init.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,16 +749,14 @@ require('lazy').setup({
749749
-- have a well standardized coding style. You can add additional
750750
-- languages here or re-enable it for the disabled ones.
751751
local disable_filetypes = { c = true, cpp = true }
752-
local lsp_format_opt
753752
if disable_filetypes[vim.bo[bufnr].filetype] then
754-
lsp_format_opt = 'never'
753+
return nil
755754
else
756-
lsp_format_opt = 'fallback'
755+
return {
756+
timeout_ms = 500,
757+
lsp_format = 'fallback',
758+
}
757759
end
758-
return {
759-
timeout_ms = 500,
760-
lsp_format = lsp_format_opt,
761-
}
762760
end,
763761
formatters_by_ft = {
764762
lua = { 'stylua' },

0 commit comments

Comments
 (0)