From a0d4238282c8a3161a375d9b1571c11e5e252d5c Mon Sep 17 00:00:00 2001 From: mewoocat Date: Tue, 13 Jan 2026 00:16:46 -0600 Subject: [PATCH] broken more granular indent options --- configuration.nix | 7 ++++++- flake.nix | 1 + lib/languages.nix | 10 +++++----- modules/plugins/languages/markdown.nix | 5 +---- modules/plugins/languages/nix.nix | 27 +++++++++++++++++++------- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/configuration.nix b/configuration.nix index e3b85f92..a9a8cd1e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -49,7 +49,12 @@ isMaximal: { enableExtraDiagnostics = true; # Languages that will be supported in default and maximal configurations. - nix.enable = true; + nix = { + enable = true; + tabstop = 20; + softtabstop = 20; + shiftwidth = 20; + }; markdown.enable = true; # Languages that are enabled in the maximal configuration. diff --git a/flake.nix b/flake.nix index 5fd9b732..dff2ec02 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,7 @@ flake = { lib = { inherit (lib) nvim; + inherit (lib) generators; inherit (lib.nvim) neovimConfiguration; }; diff --git a/lib/languages.nix b/lib/languages.nix index 46766843..f1f2dcd3 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -82,17 +82,17 @@ in { # maybe put generic function to set indent for provided langs # Then we can just call it with the lib arg - setLanguageIndent = {language, indentSize}: { + setLanguageIndent = {language, tabstop, softtabstop, shiftwidth}: { vim.autocmds = [ { desc = "Sets indent for nix files"; - event = ["FileType"]; + event = [ "FileType" ]; pattern = [ language ]; callback = mkLuaInline '' function() - vim.bo.tabstop = ${toString indentSize} - vim.bo.softtabstop = ${toString indentSize} - vim.bo.shiftwidth = ${toString indentSize} + ${if tabstop != null then "vim.bo.tabstop = " + toString tabstop else ""} + ${if softtabstop != null then "vim.bo.softtabstop = " + toString softtabstop else ""} + ${if shiftwidth != null then "vim.bo.shiftwidth = " + toString shiftwidth else ""} end ''; once = true; diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 0ac9dbc3..f2a21f78 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -207,10 +207,7 @@ in { }; }) - (setLanguageIndent { - language = "markdown"; - indentSize = 6; - }) + # todo ]); } diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 300406c0..71cc6580 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -9,8 +9,7 @@ inherit (lib.meta) getExe; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; - inherit (lib.types) enum; - inherit (lib.types) int; + inherit (lib.types) enum int nullOr; inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf; inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.languages) setLanguageIndent; @@ -109,10 +108,22 @@ in { }; }; - indentSize = mkOption { - description = "Sets the indent size in spaces for .nix files"; - type = int; - default = 10; + tabstop = mkOption { + description = "Sets the tabstop size in spaces for .nix files"; + type = nullOr null; + default = null; + }; + + softtabstop = mkOption { + description = "Sets the softtabstop size in spaces for .nix files"; + type = nullOr int; + default = null; + }; + + shiftwidth = mkOption { + description = "Sets the shiftwidth in spaces for .nix files"; + type = nullOr int; + default = null; }; }; @@ -171,7 +182,9 @@ in { (setLanguageIndent { language = "nix"; - indentSize = cfg.indentSize; + tabstop = cfg.tabstop; + softtabstop = cfg.softtabstop; + shiftwidth = cfg.shiftwidth; }) ]);