From 4cdac1381bfee7e3cf4f15e379805c8ecdbc30ec Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Mon, 29 Dec 2025 10:19:20 +0200 Subject: [PATCH 1/4] feat(conform): re-enable auto formatting, fix #47 --- config/modules/plugins/conform-nvim.nix | 67 +++++++++++++++++++------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/config/modules/plugins/conform-nvim.nix b/config/modules/plugins/conform-nvim.nix index 873f390..346f8a2 100644 --- a/config/modules/plugins/conform-nvim.nix +++ b/config/modules/plugins/conform-nvim.nix @@ -1,8 +1,3 @@ -{ - lib, - pkgs, - ... -}: { config = { extraConfigLuaPre = @@ -48,6 +43,7 @@ enable = true; autoInstall.enable = true; settings = { + default_format_opts.lsp_format = "fallback"; formatters_by_ft = { html = { __unkeyed-1 = "prettierd"; @@ -81,7 +77,7 @@ }; python = [ "ruff_format" ]; lua = [ "stylua" ]; - nix = [ "nixfmt-rfc-style" ]; + nix = [ "nixfmt" ]; markdown = { __unkeyed-1 = "prettierd"; __unkeyed-2 = "prettier"; @@ -103,20 +99,61 @@ "goimports" "gofmt" ]; + # Auto correct misspelled words + # "*" = [ "codebook" ]; "_" = [ "trim_whitespace" ]; }; formatters = { - terraform_fmt = { - command = "${lib.getExe ( - pkgs.terraform.overrideAttrs (oldAttrs: { - meta = lib.recursiveUpdate oldAttrs.meta { - license = lib.licenses.gpl3Only; - }; - }) - )}"; - }; + # Disabling because if project has a project limitatiton, then + # formatter not working at all + # terraform_fmt = { + # command = "${lib.getExe ( + # pkgs.terraform.overrideAttrs (oldAttrs: { + # meta = lib.recursiveUpdate oldAttrs.meta { + # license = lib.licenses.gpl3Only; + # }; + # }) + # )}"; + # }; }; + format_on_save = # Lua + '' + function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + + if slow_format_filetypes[vim.bo[bufnr].filetype] then + return + end + + local function on_format(err) + if err and err:match("timeout$") then + slow_format_filetypes[vim.bo[bufnr].filetype] = true + end + end + + return { timeout_ms = 200, lsp_fallback = true }, on_format + end + ''; + # format_after_save = # Lua + # '' + # function(bufnr) + # if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + # return + # end + # + # if not slow_format_filetypes[vim.bo[bufnr].filetype] then + # return + # end + # + # return { lsp_fallback = true } + # end + # ''; + log_level = "warn"; + notify_on_error = true; + notify_no_formatters = false; }; }; keymaps = [ -- 2.49.1 From 543ccb7573439320b9b0e6a6158552e351716db4 Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Mon, 29 Dec 2025 12:05:57 +0200 Subject: [PATCH 2/4] feat(conform): do not disable formatters on timeout --- config/modules/plugins/conform-nvim.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config/modules/plugins/conform-nvim.nix b/config/modules/plugins/conform-nvim.nix index 346f8a2..3ec165d 100644 --- a/config/modules/plugins/conform-nvim.nix +++ b/config/modules/plugins/conform-nvim.nix @@ -124,14 +124,15 @@ return end - if slow_format_filetypes[vim.bo[bufnr].filetype] then - return - end + -- if slow_format_filetypes[vim.bo[bufnr].filetype] then + -- return + -- end local function on_format(err) - if err and err:match("timeout$") then - slow_format_filetypes[vim.bo[bufnr].filetype] = true - end + return + -- if err and err:match("timeout$") then + -- slow_format_filetypes[vim.bo[bufnr].filetype] = true + -- end end return { timeout_ms = 200, lsp_fallback = true }, on_format -- 2.49.1 From 6286e367c77456c2ae87e034f3e81edccb3505fd Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Mon, 29 Dec 2025 12:06:17 +0200 Subject: [PATCH 3/4] chore: add editorconfig --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f352616 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false -- 2.49.1 From eae4cbc30f3efc9465b01dc0d300a3d9221c5edd Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Mon, 29 Dec 2025 12:06:30 +0200 Subject: [PATCH 4/4] chore(flake): bump version --- flake.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index ed9c296..d100ab5 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1763759067, - "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", "type": "github" }, "original": { @@ -26,11 +26,11 @@ ] }, "locked": { - "lastModified": 1763759067, - "narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=", + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", "type": "github" }, "original": { @@ -87,11 +87,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1764522689, - "narHash": "sha256-SqUuBFjhl/kpDiVaKLQBoD8TLD+/cTUzzgVFoaHrkqY=", + "lastModified": 1766473571, + "narHash": "sha256-5G1NDO2PulBx1RoaA6U1YoUDX0qZslpPxv+n5GX6Qto=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8bb5646e0bed5dbd3ab08c7a7cc15b75ab4e1d0f", + "rev": "76701a179d3a98b07653e2b0409847499b2a07d3", "type": "github" }, "original": { @@ -103,11 +103,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1761765539, - "narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=", + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "719359f4562934ae99f5443f20aa06c2ffff91fc", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", "type": "github" }, "original": { @@ -118,11 +118,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1764338033, - "narHash": "sha256-1LNGcU+aTbATD3BPCf7U1KsP1CjCH+ZWqM6JH0sZ6Q0=", - "owner": "NixOS", + "lastModified": 1766473571, + "narHash": "sha256-5G1NDO2PulBx1RoaA6U1YoUDX0qZslpPxv+n5GX6Qto=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "ba9b83e5fb4b552a423d24dabe5ccb47a9c89901", + "rev": "76701a179d3a98b07653e2b0409847499b2a07d3", "type": "github" }, "original": { @@ -140,11 +140,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1764614282, - "narHash": "sha256-oHT1/E5yf9lvOVHtO5joevADcQLGp5mVab5shVVqxso=", + "lastModified": 1766849711, + "narHash": "sha256-gtLBwhgjERca1UCzGkFplD5epIVRiNkePHVVtyFr73g=", "owner": "nix-community", "repo": "nixvim", - "rev": "6bdabc1359d7658e1d9ce065db37df92e904b581", + "rev": "cae79c48e93bd61e478dfc12456bf68b1ce66074", "type": "github" }, "original": { -- 2.49.1