Skip to content

Commit 801cae7

Browse files
RulentWaveshrkamat
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 b0db53d commit 801cae7

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
@@ -767,16 +767,14 @@ require('lazy').setup({
767767
-- have a well standardized coding style. You can add additional
768768
-- languages here or re-enable it for the disabled ones.
769769
local disable_filetypes = { c = true, cpp = true }
770-
local lsp_format_opt
771770
if disable_filetypes[vim.bo[bufnr].filetype] then
772-
lsp_format_opt = 'never'
771+
return nil
773772
else
774-
lsp_format_opt = 'fallback'
773+
return {
774+
timeout_ms = 500,
775+
lsp_format = 'fallback',
776+
}
775777
end
776-
return {
777-
timeout_ms = 500,
778-
lsp_format = lsp_format_opt,
779-
}
780778
end,
781779
formatters_by_ft = {
782780
lua = { 'stylua' },

0 commit comments

Comments
 (0)