Skip to content

Commit ba721ad

Browse files
RulentWavekmha915
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 f9b9398 commit ba721ad

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

0 commit comments

Comments
 (0)