Skip to content

Commit 1c79cae

Browse files
RulentWaveGabrielTorland
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 c89d37e commit 1c79cae

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
@@ -1014,16 +1014,14 @@ require('lazy').setup({
10141014
-- have a well standardized coding style. You can add additional
10151015
-- languages here or re-enable it for the disabled ones.
10161016
local disable_filetypes = { c = true, cpp = true }
1017-
local lsp_format_opt
10181017
if disable_filetypes[vim.bo[bufnr].filetype] then
1019-
lsp_format_opt = 'never'
1018+
return nil
10201019
else
1021-
lsp_format_opt = 'fallback'
1020+
return {
1021+
timeout_ms = 500,
1022+
lsp_format = 'fallback',
1023+
}
10221024
end
1023-
return {
1024-
timeout_ms = 500,
1025-
lsp_format = lsp_format_opt,
1026-
}
10271025
end,
10281026
formatters_by_ft = {
10291027
lua = { 'stylua' },

0 commit comments

Comments
 (0)