@@ -36,11 +36,7 @@ return {
3636 [" <Leader>lc" ] = { function () vim .cmd .ConformInfo () end , desc = " Conform information" },
3737 [" <Leader>uf" ] = {
3838 function ()
39- if vim .b .autoformat == nil then
40- if vim .g .autoformat == nil then vim .g .autoformat = true end
41- vim .b .autoformat = vim .g .autoformat
42- end
43- vim .b .autoformat = not vim .b .autoformat
39+ vim .b .autoformat = not vim .F .if_nil (vim .b .autoformat , vim .g .autoformat , true )
4440 require (" astrocore" ).notify (
4541 string.format (" Buffer autoformatting %s" , vim .b .autoformat and " on" or " off" )
4642 )
@@ -49,9 +45,7 @@ return {
4945 },
5046 [" <Leader>uF" ] = {
5147 function ()
52- if vim .g .autoformat == nil then vim .g .autoformat = true end
53- vim .g .autoformat = not vim .g .autoformat
54- vim .b .autoformat = nil
48+ vim .g .autoformat , vim .b .autoformat = not vim .F .if_nil (vim .g .autoformat , true ), nil
5549 require (" astrocore" ).notify (
5650 string.format (" Global autoformatting %s" , vim .g .autoformat and " on" or " off" )
5751 )
@@ -66,10 +60,7 @@ return {
6660 opts = {
6761 default_format_opts = { lsp_format = " fallback" },
6862 format_on_save = function (bufnr )
69- if vim .g .autoformat == nil then vim .g .autoformat = true end
70- local autoformat = vim .b [bufnr ].autoformat
71- if autoformat == nil then autoformat = vim .g .autoformat end
72- if autoformat then return { timeout_ms = 500 } end
63+ if vim .F .if_nil (vim .b [bufnr ].autoformat , vim .g .autoformat , true ) then return { timeout_ms = 500 } end
7364 end ,
7465 },
7566}
0 commit comments