Skip to content

Commit 528d981

Browse files
RulentWaveanton-oz
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 cfee3e3 commit 528d981

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
@@ -685,16 +685,14 @@ require('lazy').setup({
685685
-- have a well standardized coding style. You can add additional
686686
-- languages here or re-enable it for the disabled ones.
687687
local disable_filetypes = { c = true, cpp = true }
688-
local lsp_format_opt
689688
if disable_filetypes[vim.bo[bufnr].filetype] then
690-
lsp_format_opt = 'never'
689+
return nil
691690
else
692-
lsp_format_opt = 'fallback'
691+
return {
692+
timeout_ms = 500,
693+
lsp_format = 'fallback',
694+
}
693695
end
694-
return {
695-
timeout_ms = 500,
696-
lsp_format = lsp_format_opt,
697-
}
698696
end,
699697
formatters_by_ft = {
700698
lua = { 'stylua' },

0 commit comments

Comments
 (0)