0xda157's nixvim config

formatter thingy

awwpotato 0036a82c 6714c5ac

+30 -4
+29
modules/plugins/conform/default.nix
··· 92 92 "_" = [ "trim_whitespace" ]; 93 93 }; 94 94 }; 95 + luaConfig.post = '' 96 + require("conform").setup({ 97 + format_on_save = function(bufnr) 98 + -- Disable with a global or buffer-local variable 99 + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then 100 + return 101 + end 102 + return { timeout_ms = 500, lsp_format = "fallback" } 103 + end, 104 + }) 105 + 106 + vim.api.nvim_create_user_command("FormatDisable", function(args) 107 + if args.bang then 108 + -- FormatDisable! will disable formatting just for this buffer 109 + vim.b.disable_autoformat = true 110 + else 111 + vim.g.disable_autoformat = true 112 + end 113 + end, { 114 + desc = "Disable autoformat-on-save", 115 + bang = true, 116 + }) 117 + vim.api.nvim_create_user_command("FormatEnable", function() 118 + vim.b.disable_autoformat = false 119 + vim.g.disable_autoformat = false 120 + end, { 121 + desc = "Re-enable autoformat-on-save", 122 + }) 123 + ''; 95 124 }; 96 125 }
+1 -4
modules/plugins/lsp/default.nix
··· 61 61 # - config - 62 62 yamlls.enable = true; 63 63 jsonls.enable = true; 64 - nixd = { 65 - enable = true; 66 - settings.formatting.command = [ "nix fmt" ]; 67 - }; 64 + nixd.enable = true; 68 65 ansiblels.enable = true; 69 66 dockerls.enable = true; 70 67 # - general -