broken more granular indent options

This commit is contained in:
mewoocat 2026-01-13 00:16:46 -06:00
commit a0d4238282
5 changed files with 33 additions and 17 deletions

View file

@ -49,7 +49,12 @@ isMaximal: {
enableExtraDiagnostics = true; enableExtraDiagnostics = true;
# Languages that will be supported in default and maximal configurations. # 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; markdown.enable = true;
# Languages that are enabled in the maximal configuration. # Languages that are enabled in the maximal configuration.

View file

@ -27,6 +27,7 @@
flake = { flake = {
lib = { lib = {
inherit (lib) nvim; inherit (lib) nvim;
inherit (lib) generators;
inherit (lib.nvim) neovimConfiguration; inherit (lib.nvim) neovimConfiguration;
}; };

View file

@ -82,17 +82,17 @@ in {
# maybe put generic function to set indent for provided langs # maybe put generic function to set indent for provided langs
# Then we can just call it with the lib arg # Then we can just call it with the lib arg
setLanguageIndent = {language, indentSize}: { setLanguageIndent = {language, tabstop, softtabstop, shiftwidth}: {
vim.autocmds = [ vim.autocmds = [
{ {
desc = "Sets indent for nix files"; desc = "Sets indent for nix files";
event = ["FileType"]; event = [ "FileType" ];
pattern = [ language ]; pattern = [ language ];
callback = mkLuaInline '' callback = mkLuaInline ''
function() function()
vim.bo.tabstop = ${toString indentSize} ${if tabstop != null then "vim.bo.tabstop = " + toString tabstop else ""}
vim.bo.softtabstop = ${toString indentSize} ${if softtabstop != null then "vim.bo.softtabstop = " + toString softtabstop else ""}
vim.bo.shiftwidth = ${toString indentSize} ${if shiftwidth != null then "vim.bo.shiftwidth = " + toString shiftwidth else ""}
end end
''; '';
once = true; once = true;

View file

@ -207,10 +207,7 @@ in {
}; };
}) })
(setLanguageIndent { # todo
language = "markdown";
indentSize = 6;
})
]); ]);
} }

View file

@ -9,8 +9,7 @@
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum; inherit (lib.types) enum int nullOr;
inherit (lib.types) int;
inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf; inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.languages) setLanguageIndent; inherit (lib.nvim.languages) setLanguageIndent;
@ -109,10 +108,22 @@ in {
}; };
}; };
indentSize = mkOption { tabstop = mkOption {
description = "Sets the indent size in spaces for .nix files"; description = "Sets the tabstop size in spaces for .nix files";
type = int; type = nullOr null;
default = 10; 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 { (setLanguageIndent {
language = "nix"; language = "nix";
indentSize = cfg.indentSize; tabstop = cfg.tabstop;
softtabstop = cfg.softtabstop;
shiftwidth = cfg.shiftwidth;
}) })
]); ]);