mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
Initial commit
This commit is contained in:
commit
2c9631997f
9 changed files with 490 additions and 0 deletions
105
nixvim.nix
Normal file
105
nixvim.nix
Normal file
|
@ -0,0 +1,105 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.programs.nixvim;
|
||||
|
||||
pluginWithConfigType = types.submodule {
|
||||
options = {
|
||||
config = mkOption {
|
||||
type = types.lines;
|
||||
description = "vimscript for this plugin to be placed in init.vim";
|
||||
default = "";
|
||||
};
|
||||
|
||||
optional = mkEnableOption "optional" // {
|
||||
description = "Don't load by default (load with :packadd)";
|
||||
};
|
||||
|
||||
plugin = mkOption {
|
||||
type = types.package;
|
||||
description = "vim plugin";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
programs.nixvim = {
|
||||
enable = mkEnableOption "enable NixVim";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.neovim;
|
||||
description = "The package to use for neovim.";
|
||||
};
|
||||
|
||||
extraPlugins = mkOption {
|
||||
type = with types; listOf (either package pluginWithConfigType);
|
||||
default = [ ];
|
||||
description = "List of vim plugins to install.";
|
||||
};
|
||||
|
||||
colorscheme = mkOption {
|
||||
type = types.str;
|
||||
description = "The name of the colorscheme";
|
||||
};
|
||||
|
||||
extraConfigLua = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Extra contents for init.lua";
|
||||
};
|
||||
|
||||
extraConfigVim = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Extra contents for init.vim";
|
||||
};
|
||||
|
||||
configure = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./plugins
|
||||
];
|
||||
|
||||
config = let
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
||||
configure = cfg.configure;
|
||||
plugins = cfg.extraPlugins;
|
||||
|
||||
withPython2 = false;
|
||||
withPython3 = false;
|
||||
withNodeJs = false;
|
||||
withRuby = false;
|
||||
};
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs;
|
||||
});
|
||||
in mkIf cfg.enable {
|
||||
environment.systemPackages = [ wrappedNeovim ];
|
||||
programs.nixvim = {
|
||||
configure = {
|
||||
customRC = cfg.extraConfigVim + (optionalString (cfg.colorscheme != "") ''
|
||||
|
||||
colorscheme ${cfg.colorscheme}
|
||||
'');
|
||||
packages.nixvim = {
|
||||
start = filter (f: f != null) (map (x:
|
||||
if x ? plugin && x.optional == true then null else (x.plugin or x))
|
||||
cfg.extraPlugins);
|
||||
opt = filter (f: f!= null)
|
||||
(map (x: if x ? plugin && x.optional == true then x.plugin else null)
|
||||
cfg.extraPlugins);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue