Something went wrong. Try again.
forked from nix-community/nixvim
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100{ lib, pkgs, config, ...}:let builders = lib.nixvim.builders.withPkgs pkgs; byteCompileLua = with config.performance.byteCompileLua; enable && configs;
fileTypeModule = { name, config, options, ... }: { options = { enable = lib.mkOption { type = lib.types.bool; default = true; description = '' Whether this file should be generated. This option allows specific files to be disabled. ''; };
target = lib.mkOption { type = lib.types.str; defaultText = lib.literalMD "the attribute name"; description = '' Name of symlink, relative to nvim config. ''; };
text = lib.mkOption { type = with lib.types; nullOr lines; default = null; description = "Text of the file."; };
source = lib.mkOption { type = lib.types.path; description = "Path of the source file."; };
finalSource = lib.mkOption { type = lib.types.path; description = "Path to the final source file."; readOnly = true; visible = false; internal = true; }; };
config = let derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name; in { target = lib.mkDefault name; source = lib.mkIf (config.text != null) ( # mkDerivedConfig uses the option's priority, and calls our function with the option's value. # This means our `source` definition has the same priority as `text`. lib.mkDerivedConfig options.text (pkgs.writeText derivationName) ); finalSource = # Byte compile lua files if performance.byteCompileLua option is enabled if byteCompileLua && lib.hasSuffix ".lua" config.target then if lib.isDerivation config.source then # Source is a derivation builders.byteCompileLuaDrv config.source else # Source is a path or string builders.byteCompileLuaFile derivationName config.source else config.source; }; };in{ options = { extraFiles = lib.mkOption { type = lib.types.attrsOf (lib.types.submodule fileTypeModule); description = "Extra files to add to the runtime path"; default = { }; example = lib.literalExpression '' { "after/ftplugin/nix.lua".text = ''' vim.opt_local.tabstop = 2 vim.opt_local.shiftwidth = 2 vim.opt_local.expandtab = true '''; } ''; }; };}