From f4072b710ab3f9cd2d3b0a7fd9c4e6049e48011b Mon Sep 17 00:00:00 2001 From: mewoocat Date: Sun, 21 Dec 2025 06:31:30 -0600 Subject: [PATCH 1/7] experimenting --- modules/plugins/languages/nix.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index f03806f9d..b1f7efba6 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -106,6 +106,12 @@ in { inherit defaultDiagnosticsProvider; }; }; + + indentSize = mkOption { + description = "Sets the indent size in spaces for .nix files"; + type = int; + default = 2; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -160,5 +166,26 @@ in { cfg.extraDiagnostics.types); }; }) - ]); + + vim = { + autocmds = [ + { + desc = "Sets indent for nix files"; + event = ["BufEnter"]; + pattern = [ + "*.nix" + "*.md" + ]; + callback = lib.generators.mkLuaInline '' + function() + vim.opt.tabstop = ${cfg.indentSize} + vim.opt.softtabstop = ${cfg.indentSize} + vim.opt.shiftwidth = ${cfg.indentSize} + end + ''; + once = true; + } + ]; + } + ]) } From 95f36449a7c93c5f1a650d52f4c41c3ac456987a Mon Sep 17 00:00:00 2001 From: mewoocat Date: Mon, 22 Dec 2025 14:28:43 -0600 Subject: [PATCH 2/7] working example --- lib/languages.nix | 3 +++ modules/plugins/languages/nix.nix | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/languages.nix b/lib/languages.nix index 899d9ea8d..423c4f8a3 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -77,4 +77,7 @@ in { }; }; }; + + # maybe put generic function to set indent for provided langs + # Then we can just call it with the lib arg } diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index b1f7efba6..16b27f198 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -4,12 +4,13 @@ lib, ... }: let - inherit (builtins) attrNames; + inherit (builtins) attrNames toString; inherit (lib) concatStringsSep; inherit (lib.meta) getExe; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.types) enum; + inherit (lib.types) int; inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf; inherit (lib.nvim.attrsets) mapListToAttrs; @@ -167,8 +168,8 @@ in { }; }) - vim = { - autocmds = [ + { + vim.autocmds = [ { desc = "Sets indent for nix files"; event = ["BufEnter"]; @@ -178,14 +179,15 @@ in { ]; callback = lib.generators.mkLuaInline '' function() - vim.opt.tabstop = ${cfg.indentSize} - vim.opt.softtabstop = ${cfg.indentSize} - vim.opt.shiftwidth = ${cfg.indentSize} + vim.opt.tabstop = ${toString cfg.indentSize} + vim.opt.softtabstop = ${toString cfg.indentSize} + vim.opt.shiftwidth = ${toString cfg.indentSize} end ''; once = true; } ]; } - ]) + + ]); } From 535d58afbab32ae4f13ae1fad45d0fb9a323adae Mon Sep 17 00:00:00 2001 From: mewoocat Date: Mon, 22 Dec 2025 22:35:50 -0600 Subject: [PATCH 3/7] generic indent func --- lib/languages.nix | 20 ++++++++++++++++++++ modules/plugins/languages/markdown.nix | 7 +++++++ modules/plugins/languages/nix.nix | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/lib/languages.nix b/lib/languages.nix index 423c4f8a3..f4e4f9903 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -4,6 +4,7 @@ inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr uniq; inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.types) luaInline; + inherit (lib.generators) mkLuaInline; in { # TODO: remove diagnosticsToLua = { @@ -80,4 +81,23 @@ in { # maybe put generic function to set indent for provided langs # Then we can just call it with the lib arg + + setLanguageIndent = {language, indentSize}: { + vim.autocmds = [ + { + desc = "Sets indent for nix files"; + event = ["BufEnter"]; + pattern = [ "*.${language}" ]; + callback = mkLuaInline '' + function() + vim.opt.tabstop = ${toString indentSize} + vim.opt.softtabstop = ${toString indentSize} + vim.opt.shiftwidth = ${toString indentSize} + end + ''; + once = true; + } + ]; + }; + } diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 59615cec2..427c401ca 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -13,6 +13,7 @@ inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.attrsets) mapListToAttrs; + inherit (lib.nvim.languages) setLanguageIndent; inherit (lib.trivial) warn; cfg = config.vim.languages.markdown; @@ -205,5 +206,11 @@ in { cfg.extraDiagnostics.types); }; }) + + (setLanguageIndent { + language = "md"; + indentSize = 4; + }) + ]); } diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 16b27f198..afc261044 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -13,6 +13,7 @@ inherit (lib.types) int; inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf; inherit (lib.nvim.attrsets) mapListToAttrs; + inherit (lib.nvim.languages) setLanguageIndent; cfg = config.vim.languages.nix; @@ -168,6 +169,12 @@ in { }; }) + (setLanguageIndent { + language = "nix"; + indentSize = cfg.indentSize; + }) + + /* { vim.autocmds = [ { @@ -188,6 +195,7 @@ in { } ]; } + */ ]); } From 8d8f9dd794a5e6fad900fd2e84f8466c47a4afa1 Mon Sep 17 00:00:00 2001 From: mewoocat Date: Wed, 24 Dec 2025 11:20:58 -0600 Subject: [PATCH 4/7] filetype no work --- lib/languages.nix | 10 +++++----- modules/plugins/languages/markdown.nix | 2 +- modules/plugins/languages/nix.nix | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/languages.nix b/lib/languages.nix index f4e4f9903..467668430 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -86,13 +86,13 @@ in { vim.autocmds = [ { desc = "Sets indent for nix files"; - event = ["BufEnter"]; - pattern = [ "*.${language}" ]; + event = ["FileType"]; + pattern = [ language ]; callback = mkLuaInline '' function() - vim.opt.tabstop = ${toString indentSize} - vim.opt.softtabstop = ${toString indentSize} - vim.opt.shiftwidth = ${toString indentSize} + vim.bo.tabstop = ${toString indentSize} + vim.bo.softtabstop = ${toString indentSize} + vim.bo.shiftwidth = ${toString indentSize} end ''; once = true; diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 427c401ca..2bacb512b 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -208,7 +208,7 @@ in { }) (setLanguageIndent { - language = "md"; + language = "markdown"; indentSize = 4; }) diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index afc261044..0373e0ae9 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -112,7 +112,7 @@ in { indentSize = mkOption { description = "Sets the indent size in spaces for .nix files"; type = int; - default = 2; + default = 10; }; }; From 78066496b2b044409163744174921248ac41151c Mon Sep 17 00:00:00 2001 From: mewoocat Date: Wed, 24 Dec 2025 13:07:14 -0600 Subject: [PATCH 5/7] switch to filetype event --- modules/plugins/languages/markdown.nix | 2 +- modules/plugins/languages/nix.nix | 23 ----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 2bacb512b..053462422 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -209,7 +209,7 @@ in { (setLanguageIndent { language = "markdown"; - indentSize = 4; + indentSize = 6; }) ]); diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 0373e0ae9..fb9da1aad 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -174,28 +174,5 @@ in { indentSize = cfg.indentSize; }) - /* - { - vim.autocmds = [ - { - desc = "Sets indent for nix files"; - event = ["BufEnter"]; - pattern = [ - "*.nix" - "*.md" - ]; - callback = lib.generators.mkLuaInline '' - function() - vim.opt.tabstop = ${toString cfg.indentSize} - vim.opt.softtabstop = ${toString cfg.indentSize} - vim.opt.shiftwidth = ${toString cfg.indentSize} - end - ''; - once = true; - } - ]; - } - */ - ]); } From a0d4238282c8a3161a375d9b1571c11e5e252d5c Mon Sep 17 00:00:00 2001 From: mewoocat Date: Tue, 13 Jan 2026 00:16:46 -0600 Subject: [PATCH 6/7] 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 e3b85f92b..a9a8cd1ea 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 5fd9b7327..dff2ec023 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 467668430..f1f2dcd31 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 0ac9dbc3f..f2a21f78f 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 300406c04..71cc6580c 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; }) ]); From 5dff56daab59e91e302d90aa782b1eac6a04540b Mon Sep 17 00:00:00 2001 From: mewoocat Date: Tue, 13 Jan 2026 00:42:11 -0600 Subject: [PATCH 7/7] dumb fix --- configuration.nix | 6 +++--- modules/plugins/languages/nix.nix | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configuration.nix b/configuration.nix index a9a8cd1ea..9eeebbc42 100644 --- a/configuration.nix +++ b/configuration.nix @@ -51,9 +51,9 @@ isMaximal: { # Languages that will be supported in default and maximal configurations. nix = { enable = true; - tabstop = 20; - softtabstop = 20; - shiftwidth = 20; + tabstop = 8; + softtabstop = 8; + shiftwidth = 8; }; markdown.enable = true; diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 71cc6580c..33624668e 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -110,7 +110,7 @@ in { tabstop = mkOption { description = "Sets the tabstop size in spaces for .nix files"; - type = nullOr null; + type = nullOr int; default = null; };