This commit is contained in:
mewoocat 2025-12-24 13:07:18 -06:00 committed by GitHub
commit 85195287ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 1 deletions

View file

@ -4,6 +4,7 @@
inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr uniq; inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr uniq;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) luaInline; inherit (lib.nvim.types) luaInline;
inherit (lib.generators) mkLuaInline;
in { in {
# TODO: remove # TODO: remove
diagnosticsToLua = { diagnosticsToLua = {
@ -77,4 +78,26 @@ 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 = ["FileType"];
pattern = [ language ];
callback = mkLuaInline ''
function()
vim.bo.tabstop = ${toString indentSize}
vim.bo.softtabstop = ${toString indentSize}
vim.bo.shiftwidth = ${toString indentSize}
end
'';
once = true;
}
];
};
} }

View file

@ -13,6 +13,7 @@
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf; inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.languages) setLanguageIndent;
inherit (lib.trivial) warn; inherit (lib.trivial) warn;
cfg = config.vim.languages.markdown; cfg = config.vim.languages.markdown;
@ -205,5 +206,11 @@ in {
cfg.extraDiagnostics.types); cfg.extraDiagnostics.types);
}; };
}) })
(setLanguageIndent {
language = "markdown";
indentSize = 6;
})
]); ]);
} }

View file

@ -4,14 +4,16 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames toString;
inherit (lib) concatStringsSep; inherit (lib) concatStringsSep;
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;
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;
cfg = config.vim.languages.nix; cfg = config.vim.languages.nix;
@ -106,6 +108,12 @@ in {
inherit defaultDiagnosticsProvider; inherit defaultDiagnosticsProvider;
}; };
}; };
indentSize = mkOption {
description = "Sets the indent size in spaces for .nix files";
type = int;
default = 10;
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
@ -160,5 +168,11 @@ in {
cfg.extraDiagnostics.types); cfg.extraDiagnostics.types);
}; };
}) })
(setLanguageIndent {
language = "nix";
indentSize = cfg.indentSize;
})
]); ]);
} }