Skip to content

Commit 307c227

Browse files
RulentWavejimmielyon
authored andcommitted
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 5f16189 commit 307c227

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
@@ -754,16 +754,14 @@ require('lazy').setup({
754754
-- have a well standardized coding style. You can add additional
755755
-- languages here or re-enable it for the disabled ones.
756756
local disable_filetypes = { c = true, cpp = true }
757-
local lsp_format_opt
758757
if disable_filetypes[vim.bo[bufnr].filetype] then
759-
lsp_format_opt = 'never'
758+
return nil
760759
else
761-
lsp_format_opt = 'fallback'
760+
return {
761+
timeout_ms = 500,
762+
lsp_format = 'fallback',
763+
}
762764
end
763-
return {
764-
timeout_ms = 500,
765-
lsp_format = lsp_format_opt,
766-
}
767765
end,
768766
formatters_by_ft = {
769767
lua = { 'stylua' },

0 commit comments

Comments
 (0)