From f4072b710ab3f9cd2d3b0a7fd9c4e6049e48011b Mon Sep 17 00:00:00 2001 From: mewoocat Date: Sun, 21 Dec 2025 06:31:30 -0600 Subject: [PATCH 1/5] 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 f03806f9..b1f7efba 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/5] 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 899d9ea8..423c4f8a 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 b1f7efba..16b27f19 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/5] 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 423c4f8a..f4e4f990 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 59615cec..427c401c 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 16b27f19..afc26104 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/5] 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 f4e4f990..46766843 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 427c401c..2bacb512 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 afc26104..0373e0ae 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/5] 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 2bacb512..05346242 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 0373e0ae..fb9da1aa 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; - } - ]; - } - */ - ]); }