Skip to content

Commit 6824556

Browse files
RulentWaveDerFrZocker
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 561260e commit 6824556

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
@@ -770,16 +770,14 @@ require('lazy').setup({
770770
-- have a well standardized coding style. You can add additional
771771
-- languages here or re-enable it for the disabled ones.
772772
local disable_filetypes = { c = true, cpp = true }
773-
local lsp_format_opt
774773
if disable_filetypes[vim.bo[bufnr].filetype] then
775-
lsp_format_opt = 'never'
774+
return nil
776775
else
777-
lsp_format_opt = 'fallback'
776+
return {
777+
timeout_ms = 500,
778+
lsp_format = 'fallback',
779+
}
778780
end
779-
return {
780-
timeout_ms = 500,
781-
lsp_format = lsp_format_opt,
782-
}
783781
end,
784782
formatters_by_ft = {
785783
lua = { 'stylua' },

0 commit comments

Comments
 (0)