Skip to content

Commit 88819c4

Browse files
RulentWavemercurialworld
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 5a0f40c commit 88819c4

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

0 commit comments

Comments
 (0)