nixvim: support standalone nixvim

This represents a major rearchitecture for nixvim, so I'm leaving this up to track the progress for now, and to serve as a reference for any breaking changes during transition.

The main change is, of course, being able to use nixvim standalone. To do this, you should use the new build function, which takes in two arguments: the system architecture (e.g. x86_64-linux) and the configuration. For the new configuration, do not use the programs.nixvim. prefix.

For module development, the main change is that you should no longer prefix your modules with programs.nixvim..
This commit is contained in:
Pedro Alves 2022-09-18 11:19:23 +01:00 committed by GitHub
parent bd6f978d51
commit 4ddd3969e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 1410 additions and 904 deletions

View file

@ -75,6 +75,25 @@ You can now access the module using `inputs.nixvim.homeManagerModules.nixvim`,
for a home-manager instalation, and `inputs.nixvim.nixosModules.nixvim`, if for a home-manager instalation, and `inputs.nixvim.nixosModules.nixvim`, if
you're not using it. you're not using it.
## Usage
NixVim can be used in three ways: through the home-manager and NixOS modules,
and through the `build` function. To use the modules, just import the
`nixvim.homeManagerModules.${system}.nixvim` and
`nixvim.nixosModules.${system}.nixvim` modules, depending on which system
you're using.
If you want to use it standalone, you can use the `build` function:
```nix
{ pkgs, nixvim, ... }: {
environment.systemModules = [
(nixvim.build pkgs {
colorschemes.gruvbox.enable = true;
})
];
}
```
## How does it work? ## How does it work?
When you build the module (probably using home-manager), it will install all When you build the module (probably using home-manager), it will install all
your plugins and generate a lua config for NeoVim with all the options your plugins and generate a lua config for NeoVim with all the options

View file

@ -1,14 +1,10 @@
{ pkgs ? import <nixpkgs> { } { pkgs ? import <nixpkgs> { }
, lib ? import <nixpkgs/lib> , lib ? import <nixpkgs/lib>
, ... }: , nmdSrc
, nixvimModules ? [ ]
, ...
}:
let let
nmdSrc = pkgs.fetchFromGitLab {
name = "nmd";
owner = "rycee";
repo = "nmd";
rev = "527245ff605bde88c2dd2ddae21c6479bb7cf8aa";
sha256 = "1zi0f9y3wq4bpslx1py3sfgrgd9av41ahpandvs6rvkpisfsqqlp";
};
nmd = import nmdSrc { inherit pkgs lib; }; nmd = import nmdSrc { inherit pkgs lib; };
scrubbedPkgsModule = { scrubbedPkgsModule = {
imports = [{ imports = [{
@ -22,14 +18,13 @@ let
nmd.buildModulesDocs ({ nmd.buildModulesDocs ({
moduleRootPaths = [ ./.. ]; moduleRootPaths = [ ./.. ];
mkModuleUrl = path: mkModuleUrl = path:
"https://github.com/pta2002/nixvim/blob/master/${path}#blob-path"; "https://github.com/pta2002/nixvim/blob/main/${path}#blob-path";
channelName = "nixvim"; channelName = "nixvim";
} // args); } // args);
nixvimDocs = buildModulesDocs { nixvimDocs = buildModulesDocs {
modules = [ modules = [
(import ../nixvim.nix {})
scrubbedPkgsModule scrubbedPkgsModule
]; ] ++ nixvimModules;
docBook.id = "nixvim-options"; docBook.id = "nixvim-options";
}; };
@ -40,11 +35,14 @@ let
documentType = "book"; documentType = "book";
chunkToc = '' chunkToc = ''
<toc> <toc>
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-home-manager-manual"><?dbhtml filename="index.html"?> <d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-nixvim-manual"><?dbhtml filename="index.html"?>
<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry> <d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry>
<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry> <d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry>
</d:tocentry> </d:tocentry>
</toc> </toc>
''; '';
}; };
in docs.html in
# TODO: Parse this json or something, since docbook isn't working (and it's kind of terrible anyway)
nixvimDocs.json

38
flake.lock generated
View file

@ -1,29 +1,42 @@
{ {
"nodes": { "nodes": {
"nixpkgs": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1641710811, "lastModified": 1659877975,
"narHash": "sha256-yVJ+CtwWZY8BnkNIJ/ue5a28yrRM6CkDF1LvmGmqqwM=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "NixOS", "owner": "numtide",
"repo": "nixpkgs", "repo": "flake-utils",
"rev": "0ecf7d414811f831060cf55707c374d54fbb1dec", "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "numtide",
"ref": "nixos-unstable", "repo": "flake-utils",
"repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": {
"locked": {
"lastModified": 1661353537,
"narHash": "sha256-1E2IGPajOsrkR49mM5h55OtYnU0dGyre6gl60NXKITE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0e304ff0d9db453a4b230e9386418fd974d5804a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nmdSrc": { "nmdSrc": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1637239786, "lastModified": 1654807200,
"narHash": "sha256-l2KsnY537mz0blZdqALZKrWXn9PD39CpvotgPnxyIP4=", "narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=",
"owner": "rycee", "owner": "rycee",
"repo": "nmd", "repo": "nmd",
"rev": "527245ff605bde88c2dd2ddae21c6479bb7cf8aa", "rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
@ -34,6 +47,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nmdSrc": "nmdSrc" "nmdSrc": "nmdSrc"
} }

157
flake.nix
View file

@ -1,102 +1,83 @@
{ {
description = "A neovim configuration system for NixOS"; description = "A neovim configuration system for NixOS";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nmdSrc.url = "gitlab:rycee/nmd"; inputs.nmdSrc.url = "gitlab:rycee/nmd";
inputs.nmdSrc.flake = false; inputs.nmdSrc.flake = false;
outputs = { self, nixpkgs, nmdSrc, ... }@inputs: rec { # TODO: Use flake-utils to support all architectures
packages."x86_64-linux".docs = import ./docs { outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs:
pkgs = import nixpkgs { system = "x86_64-linux"; }; with nixpkgs.lib;
lib = nixpkgs.lib; with builtins;
let
# TODO: Support nesting
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
modules = pkgs: nixvimModules ++ [
(rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = mkForce pkgs;
lib = pkgs.lib;
helpers = import ./plugins/helpers.nix { lib = pkgs.lib; };
}; };
nixosModules.nixvim = import ./nixvim.nix { nixos = true; };
homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; };
# This is a simple container for testing
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
boot.isContainer = true;
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
users.users.test = {
isNormalUser = true;
password = "";
};
imports = [ nixosModules.nixvim ];
programs.nixvim = {
enable = true;
package = pkgs.neovim;
colorschemes.tokyonight = { enable = true; };
extraPlugins = [ pkgs.vimPlugins.vim-nix ];
options = {
number = true;
mouse = "a";
tabstop = 2;
shiftwidth = 2;
expandtab = true;
smarttab = true;
autoindent = true;
cindent = true;
linebreak = true;
hidden = true;
};
maps.normalVisualOp."ç" = ":";
maps.normal."<leader>m" = {
silent = true;
action = "<cmd>make<CR>";
};
plugins.lualine = {
enable = true;
};
plugins.undotree.enable = true;
plugins.gitgutter.enable = true;
plugins.fugitive.enable = true;
plugins.commentary.enable = true;
plugins.startify = {
enable = true;
useUnicode = true;
};
plugins.goyo = {
enable = true;
showLineNumbers = true;
};
plugins.lsp = {
enable = true;
servers.clangd.enable = true;
};
plugins.telescope = {
enable = true;
extensions = { frecency.enable = true; };
};
plugins.nvim-autopairs = { enable = true; };
globals = {
vimsyn_embed = "l";
mapleader = " ";
};
plugins.lspsaga.enable = true;
plugins.treesitter.enable = true;
plugins.ledger.enable = true;
}; };
}) })
./plugins/default.nix
];
nixvimOption = pkgs: mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "Enable nixvim";
}]);
};
build = pkgs:
configuration:
let
eval = evalModules {
modules = modules pkgs ++ [ configuration ];
};
in
eval.config.output;
flakeOutput =
flake-utils.lib.eachDefaultSystem
(system: rec {
packages.docs = import ./docs {
pkgs = import nixpkgs { inherit system; };
lib = nixpkgs.lib;
nixvimModules = nixvimModules;
inherit nmdSrc;
};
nixosModules.nixvim = { pkgs, config, lib, ... }: {
options.programs.nixvim = nixvimOption pkgs;
config = mkIf config.programs.nixvim.enable {
environment.systemPackages = [
config.programs.nixvim.output
]; ];
}; };
}; };
homeManagerModules.nixvim = { pkgs, config, lib, ... }: {
options.programs.nixvim = nixvimOption pkgs;
config = mkIf config.programs.nixvim.enable {
home.packages = [
config.programs.nixvim.output
];
};
};
});
in
flakeOutput // {
inherit build;
# TODO: Stuff for home-manager and nixos modules backwards compat, keeping the architecture as x86_64 if none is specified...
homeManagerModules.nixvim = flakeOutput.homeManagerModules.x86_64-linux.nixvim;
nixosModules.nixvim = flakeOutput.nixosModules.x86_64-linux.nixvim;
};
} }

17
modules/colorscheme.nix Normal file
View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
with lib;
{
options = {
colorscheme = mkOption {
type = types.nullOr types.str;
description = "The name of the colorscheme to use";
default = null;
};
};
config = {
extraConfigVim = optionalString (config.colorscheme != "" && config.colorscheme != null) ''
colorscheme ${config.colorscheme}
'';
};
}

131
modules/keymaps.nix Normal file
View file

@ -0,0 +1,131 @@
{ config, lib, helpers, ... }:
with lib;
let
mapOption = types.oneOf [
types.str
(types.submodule {
options = {
silent = mkOption {
type = types.bool;
description = "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
default = false;
};
nowait = mkOption {
type = types.bool;
description = "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
default = false;
};
script = mkOption {
type = types.bool;
description = "Equivalent to adding <script> to a map.";
default = false;
};
expr = mkOption {
type = types.bool;
description = "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
default = false;
};
unique = mkOption {
type = types.bool;
description = "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
default = false;
};
noremap = mkOption {
type = types.bool;
description = "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
default = true;
};
action = mkOption {
type = types.str;
description = "The action to execute.";
};
description = mkOption {
type = types.nullOr types.str;
description = "A textual description of this keybind, to be shown in which-key, if you have it.";
default = null;
};
};
})
];
mapOptions = mode: mkOption {
description = "Mappings for ${mode} mode";
type = types.attrsOf mapOption;
default = { };
};
in
{
options = {
maps = mkOption {
type = types.submodule {
options = {
normal = mapOptions "normal";
insert = mapOptions "insert";
select = mapOptions "select";
visual = mapOptions "visual and select";
terminal = mapOptions "terminal";
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
visualOnly = mapOptions "visual only";
operator = mapOptions "operator-pending";
insertCommand = mapOptions "insert and command-line";
lang = mapOptions "insert, command-line and lang-arg";
command = mapOptions "command-line";
};
};
default = { };
description = ''
Custom keybindings for any mode.
For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp.
'';
example = ''
maps = {
normalVisualOp.";" = ":"; # Same as noremap ; :
normal."<leader>m" = {
silent = true;
action = "<cmd>make<CR>";
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
};
'';
};
};
config =
let
mappings =
(helpers.genMaps "" config.maps.normalVisualOp) ++
(helpers.genMaps "n" config.maps.normal) ++
(helpers.genMaps "i" config.maps.insert) ++
(helpers.genMaps "v" config.maps.visual) ++
(helpers.genMaps "x" config.maps.visualOnly) ++
(helpers.genMaps "s" config.maps.select) ++
(helpers.genMaps "t" config.maps.terminal) ++
(helpers.genMaps "o" config.maps.operator) ++
(helpers.genMaps "l" config.maps.lang) ++
(helpers.genMaps "!" config.maps.insertCommand) ++
(helpers.genMaps "c" config.maps.command);
in
{
# TODO: Use vim.keymap.set if on nvim >= 0.7
extraConfigLua = optionalString (mappings != [ ]) ''
-- Set up keybinds {{{
do
local __nixvim_binds = ${helpers.toLuaObject mappings}
for i, map in ipairs(__nixvim_binds) do
vim.api.nvim_set_keymap(map.mode, map.key, map.action, map.config)
end
end
-- }}}
'';
};
}

41
modules/options.nix Normal file
View file

@ -0,0 +1,41 @@
{ config, lib, helpers, ... }:
with lib;
{
options = {
options = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "The configuration options, e.g. line numbers";
};
globals = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "Global variables";
};
};
config = {
extraConfigLuaPre = optionalString (config.globals != { }) ''
-- Set up globals {{{
do
local nixvim_globals = ${helpers.toLuaObject config.globals}
for k,v in pairs(nixvim_globals) do
vim.g[k] = v
end
end
-- }}}
'' + optionalString (config.options != { }) ''
-- Set up options {{{
do
local nixvim_options = ${helpers.toLuaObject config.options}
for k,v in pairs(nixvim_options) do
vim.o[k] = v
end
end
-- }}}
'';
};
}

109
modules/output.nix Normal file
View file

@ -0,0 +1,109 @@
{ pkgs, config, lib, ... }:
with lib;
let
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 = {
package = mkOption {
type = types.package;
default = pkgs.neovim-unwrapped;
description = "Neovim to use for nixvim";
};
extraPlugins = mkOption {
type = with types; listOf (either package pluginWithConfigType);
default = [ ];
description = "List of vim plugins to install";
};
extraPackages = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra packages to be made available to neovim";
};
extraConfigLua = mkOption {
type = types.lines;
default = "";
description = "Extra contents for init.lua";
};
extraConfigLuaPre = mkOption {
type = types.lines;
default = "";
description = "Extra contents for init.lua before everything else";
};
extraConfigLuaPost = mkOption {
type = types.lines;
default = "";
description = "Extra contents for init.lua after everything else";
};
extraConfigVim = mkOption {
type = types.lines;
default = "";
description = "Extra contents for init.vim";
};
output = mkOption {
type = types.package;
description = "Final package built by nixvim";
readOnly = true;
visible = false;
};
};
config =
let
customRC = config.extraConfigVim + (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPre != "" || config.extraConfigLuaPost != "") ''
lua <<EOF
${config.extraConfigLuaPre}
${config.extraConfigLua}
${config.extraConfigLuaPost}
EOF
'');
defaultPlugin = {
plugin = null;
config = "";
optional = false;
};
normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins;
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
inherit customRC;
plugins = normalizedPlugins;
};
extraWrapperArgs = optionalString (config.extraPackages != [ ])
''--prefix PATH : "${makeBinPath config.extraPackages}"'';
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // {
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
});
in
{
output = wrappedNeovim;
};
}

6
modules/plugins.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
../plugins/default.nix
];
}

View file

@ -1,10 +1,10 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.barbar; cfg = config.plugins.barbar;
in in
{ {
options.programs.nixvim.plugins.barbar = { options.plugins.barbar = {
enable = mkEnableOption "Enable barbar.nvim"; enable = mkEnableOption "Enable barbar.nvim";
animations = mkOption { animations = mkOption {
@ -48,7 +48,7 @@ in
# }; # };
}; };
config.programs.nixvim = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
barbar-nvim nvim-web-devicons barbar-nvim nvim-web-devicons
]; ];

View file

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.bufferline; cfg = config.plugins.bufferline;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
highlight = mkOption { highlight = mkOption {
@ -24,7 +24,7 @@ let
in in
{ {
options = { options = {
programs.nixvim.plugins.bufferline = { plugins.bufferline = {
enable = mkEnableOption "Enable bufferline"; enable = mkEnableOption "Enable bufferline";
numbers = mkOption { numbers = mkOption {
type = types.nullOr types.lines; type = types.nullOr types.lines;
@ -221,7 +221,8 @@ in
}; };
}; };
config = let config =
let
setupOptions = { setupOptions = {
options = { options = {
numbers = cfg.numbers; numbers = cfg.numbers;
@ -315,8 +316,8 @@ in
}; };
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
bufferline-nvim bufferline-nvim
nvim-web-devicons nvim-web-devicons
@ -326,5 +327,4 @@ in
require('bufferline').setup${helpers.toLuaObject setupOptions} require('bufferline').setup${helpers.toLuaObject setupOptions}
''; '';
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.base16; cfg = config.colorschemes.base16;
themes = import ./base16-list.nix; themes = import ./base16-list.nix;
in { in
{
options = { options = {
programs.nixvim.colorschemes.base16 = { colorschemes.base16 = {
enable = mkEnableOption "Enable base16"; enable = mkEnableOption "Enable base16";
useTruecolor = mkOption { useTruecolor = mkOption {
@ -28,7 +29,6 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "base16-${cfg.colorscheme}"; colorscheme = "base16-${cfg.colorscheme}";
extraPlugins = [ pkgs.vimPlugins.base16-vim ]; extraPlugins = [ pkgs.vimPlugins.base16-vim ];
@ -37,5 +37,4 @@ in {
options.termguicolors = mkIf cfg.useTruecolor true; options.termguicolors = mkIf cfg.useTruecolor true;
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.gruvbox; cfg = config.colorschemes.gruvbox;
colors = types.enum [ "bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4" ]; colors = types.enum [ "bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4" ];
in { in
{
options = { options = {
programs.nixvim.colorschemes.gruvbox = { colorschemes.gruvbox = {
enable = mkEnableOption "Enable gruvbox"; enable = mkEnableOption "Enable gruvbox";
italics = mkEnableOption "Enable italics"; italics = mkEnableOption "Enable italics";
@ -111,7 +112,6 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "gruvbox"; colorscheme = "gruvbox";
extraPlugins = [ pkgs.vimPlugins.gruvbox-nvim ]; extraPlugins = [ pkgs.vimPlugins.gruvbox-nvim ];
@ -139,5 +139,4 @@ in {
gruvbox_improved_warnings = mkIf (cfg.improvedWarnings) 1; gruvbox_improved_warnings = mkIf (cfg.improvedWarnings) 1;
}; };
}; };
};
} }

View file

@ -1,11 +1,11 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.nord; cfg = config.colorschemes.nord;
in in
{ {
options = { options = {
programs.nixvim.colorschemes.nord = { colorschemes.nord = {
enable = mkEnableOption "Enable nord"; enable = mkEnableOption "Enable nord";
contrast = mkEnableOption contrast = mkEnableOption
@ -32,7 +32,6 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "nord"; colorscheme = "nord";
extraPlugins = [ pkgs.vimPlugins.nord-nvim ]; extraPlugins = [ pkgs.vimPlugins.nord-nvim ];
@ -45,5 +44,4 @@ in
nord_italic = mkIf (cfg.italic != null) cfg.italic; nord_italic = mkIf (cfg.italic != null) cfg.italic;
}; };
}; };
};
} }

View file

@ -1,16 +1,16 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.one; cfg = config.colorschemes.one;
in { in
{
options = { options = {
programs.nixvim.colorschemes.one = { colorschemes.one = {
enable = mkEnableOption "Enable vim-one"; enable = mkEnableOption "Enable vim-one";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "one"; colorscheme = "one";
extraPlugins = [ pkgs.vimPlugins.vim-one ]; extraPlugins = [ pkgs.vimPlugins.vim-one ];
@ -18,5 +18,4 @@ in {
termguicolors = true; termguicolors = true;
}; };
}; };
};
} }

View file

@ -1,16 +1,16 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.onedark; cfg = config.colorschemes.onedark;
in { in
{
options = { options = {
programs.nixvim.colorschemes.onedark = { colorschemes.onedark = {
enable = mkEnableOption "Enable onedark"; enable = mkEnableOption "Enable onedark";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "onedark"; colorscheme = "onedark";
extraPlugins = [ pkgs.vimPlugins.onedark-vim ]; extraPlugins = [ pkgs.vimPlugins.onedark-vim ];
@ -18,5 +18,4 @@ in {
termguicolors = true; termguicolors = true;
}; };
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.colorschemes.tokyonight; cfg = config.colorschemes.tokyonight;
style = types.enum [ "storm" "night" "day" ]; style = types.enum [ "storm" "night" "day" ];
in { in
{
options = { options = {
programs.nixvim.colorschemes.tokyonight = { colorschemes.tokyonight = {
enable = mkEnableOption "Enable tokyonight"; enable = mkEnableOption "Enable tokyonight";
style = mkOption { style = mkOption {
type = types.nullOr style; type = types.nullOr style;
@ -33,7 +34,6 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
colorscheme = "tokyonight"; colorscheme = "tokyonight";
extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ]; extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ];
options = { termguicolors = true; }; options = { termguicolors = true; };
@ -55,5 +55,4 @@ in {
tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1; tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1;
}; };
}; };
};
} }

View file

@ -1,13 +1,14 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.coq-nvim; cfg = config.plugins.coq-nvim;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
plugins = import ../plugin-defs.nix { inherit pkgs; }; plugins = import ../plugin-defs.nix { inherit pkgs; };
in { in
{
options = { options = {
programs.nixvim.plugins.coq-nvim = { plugins.coq-nvim = {
enable = mkEnableOption "Enable coq-nvim"; enable = mkEnableOption "Enable coq-nvim";
installArtifacts = mkEnableOption "Install coq-artifacts"; installArtifacts = mkEnableOption "Install coq-artifacts";
@ -25,13 +26,14 @@ in {
}; };
}; };
}; };
config = let config =
let
settings = { settings = {
auto_start = cfg.autoStart; auto_start = cfg.autoStart;
"keymap.recommended" = cfg.recommendedKeymaps; "keymap.recommended" = cfg.recommendedKeymaps;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ extraPlugins = [
plugins.coq-nvim plugins.coq-nvim
] ++ optional cfg.installArtifacts plugins.coq-artifacts; ] ++ optional cfg.installArtifacts plugins.coq-artifacts;
@ -43,5 +45,4 @@ in {
setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ]; setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ];
}; };
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }@args: { pkgs, config, lib, ... }@args:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.nvim-cmp; cfg = config.plugins.nvim-cmp;
helpers = import ../../helpers.nix { lib = lib; }; helpers = import ../../helpers.nix { lib = lib; };
mkNullOrOption = helpers.mkNullOrOption; mkNullOrOption = helpers.mkNullOrOption;
cmpLib = import ./cmp-helpers.nix args; cmpLib = import ./cmp-helpers.nix args;
@ -14,7 +14,7 @@ let
''${functionName}(${parameterString})''; ''${functionName}(${parameterString})'';
in in
{ {
options.programs.nixvim.plugins.nvim-cmp = { options.plugins.nvim-cmp = {
enable = mkEnableOption "Enable nvim-cmp"; enable = mkEnableOption "Enable nvim-cmp";
performance = mkOption { performance = mkOption {
@ -392,7 +392,6 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.nvim-cmp ]; extraPlugins = [ pkgs.vimPlugins.nvim-cmp ];
extraConfigLua = '' extraConfigLua = ''
@ -419,5 +418,4 @@ in
in in
mkIf cfg.auto_enable_sources attrs_enabled; mkIf cfg.auto_enable_sources attrs_enabled;
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.gitgutter; cfg = config.plugins.gitgutter;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in { in
{
options = { options = {
programs.nixvim.plugins.gitgutter = { plugins.gitgutter = {
enable = mkEnableOption "Enable gitgutter"; enable = mkEnableOption "Enable gitgutter";
recommendedSettings = mkOption { recommendedSettings = mkOption {
@ -51,13 +52,15 @@ in {
}; };
signs = mkOption { signs = mkOption {
type = let type =
let
signOption = desc: mkOption { signOption = desc: mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Sign for ${desc}"; description = "Sign for ${desc}";
}; };
in types.submodule { in
types.submodule {
options = { options = {
added = signOption "added lines"; added = signOption "added lines";
modified = signOption "modified lines"; modified = signOption "modified lines";
@ -91,7 +94,8 @@ in {
}; };
grep = mkOption { grep = mkOption {
type = types.nullOr (types.oneOf [ (types.submodule { type = types.nullOr (types.oneOf [
(types.submodule {
options = { options = {
command = mkOption { command = mkOption {
type = types.str; type = types.str;
@ -103,7 +107,9 @@ in {
description = "The package of the grep alternative to use"; description = "The package of the grep alternative to use";
}; };
}; };
}) types.str]); })
types.str
]);
default = null; default = null;
description = "A non-standard grep to use instead of the default"; description = "A non-standard grep to use instead of the default";
}; };
@ -158,11 +164,12 @@ in {
}; };
}; };
config = let config =
let
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ]; grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ];
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep; grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.gitgutter ]; extraPlugins = [ pkgs.vimPlugins.gitgutter ];
options = mkIf cfg.recommendedSettings { options = mkIf cfg.recommendedSettings {
@ -205,5 +212,4 @@ in {
gitgutter_terminal_report_focus = mkIf (!cfg.terminalReportFocus) 0; gitgutter_terminal_report_focus = mkIf (!cfg.terminalReportFocus) 0;
}; };
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.neogit; cfg = config.plugins.neogit;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
sectionDefaultsModule = types.submodule { sectionDefaultsModule = types.submodule {
@ -15,7 +15,7 @@ let
in in
{ {
options = { options = {
programs.nixvim.plugins.neogit = { plugins.neogit = {
enable = mkEnableOption "Enable neogit"; enable = mkEnableOption "Enable neogit";
disableSigns = mkOption { disableSigns = mkOption {
@ -201,7 +201,8 @@ in
}; };
}; };
config = let config =
let
setupOptions = with cfg; helpers.toLuaObject { setupOptions = with cfg; helpers.toLuaObject {
inherit kind integrations signs sections mappings; inherit kind integrations signs sections mappings;
disable_signs = disableSigns; disable_signs = disableSigns;
@ -213,8 +214,8 @@ in
use_magit_keybindings = useMagitKeybindings; use_magit_keybindings = useMagitKeybindings;
commit_popup = commitPopup; commit_popup = commitPopup;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
neogit neogit
plenary-nvim plenary-nvim
@ -224,5 +225,4 @@ in
require('neogit').setup(${setupOptions}) require('neogit').setup(${setupOptions})
''; '';
}; };
};
} }

View file

@ -71,7 +71,7 @@ rec {
options ? {}, options ? {},
... ...
}: let }: let
cfg = config.programs.nixvim.plugins.${name}; cfg = config.plugins.${name};
# TODO support nested options! # TODO support nested options!
pluginOptions = mapAttrs (k: v: v.option) options; pluginOptions = mapAttrs (k: v: v.option) options;
globals = mapAttrs' (name: opt: { globals = mapAttrs' (name: opt: {
@ -79,11 +79,11 @@ rec {
value = if cfg.${name} != null then opt.value cfg.${name} else null; value = if cfg.${name} != null then opt.value cfg.${name} else null;
}) options; }) options;
in { in {
options.programs.nixvim.plugins.${name} = { options.plugins.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
} // pluginOptions; } // pluginOptions;
config.programs.nixvim = mkIf cfg.enable { config = mkIf cfg.enable {
inherit extraPlugins globals; inherit extraPlugins globals;
}; };
}; };

View file

@ -1,19 +1,20 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.treesitter; cfg = config.plugins.treesitter;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.treesitter = { plugins.treesitter = {
enable = mkEnableOption "Enable tree-sitter syntax highlighting"; enable = mkEnableOption "Enable tree-sitter syntax highlighting";
nixGrammars = mkOption { nixGrammars = mkOption {
type = types.bool; type = types.bool;
default = false; default = true;
description = "Install grammars with Nix (beta)"; description = "Install grammars with Nix";
}; };
ensureInstalled = mkOption { ensureInstalled = mkOption {
type = with types; oneOf [ (enum [ "all" ]) (listOf str) ]; type = with types; oneOf [ (enum [ "all" ]) (listOf str) ];
default = "all"; default = "all";
@ -92,7 +93,6 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
programs.nixvim = {
extraConfigLua = '' extraConfigLua = ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
''; '';
@ -107,6 +107,5 @@ in
foldexpr = "nvim_treesitter#foldexpr()"; foldexpr = "nvim_treesitter#foldexpr()";
}; };
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.null-ls; cfg = config.plugins.null-ls;
helpers = (import ../helpers.nix { inherit lib; }); helpers = (import ../helpers.nix { inherit lib; });
in in
{ {
@ -9,7 +9,7 @@ in
./servers.nix ./servers.nix
]; ];
options.programs.nixvim.plugins.null-ls = { options.plugins.null-ls = {
enable = mkEnableOption "Enable null-ls"; enable = mkEnableOption "Enable null-ls";
debug = mkOption { debug = mkOption {
@ -30,18 +30,18 @@ in
# }; # };
}; };
config = let config =
let
options = { options = {
debug = cfg.debug; debug = cfg.debug;
sources = cfg.sourcesItems; sources = cfg.sourcesItems;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ null-ls-nvim ]; extraPlugins = with pkgs.vimPlugins; [ null-ls-nvim ];
extraConfigLua = '' extraConfigLua = ''
require("null-ls").setup(${helpers.toLuaObject options}) require("null-ls").setup(${helpers.toLuaObject options})
''; '';
}; };
};
} }

View file

@ -1,21 +1,21 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
{ {
mkServer = { mkServer =
name, { name
sourceType, , sourceType
description ? "Enable ${name} source, for null-ls.", , description ? "Enable ${name} source, for null-ls."
packages ? [], , packages ? [ ]
... }: , ...
}:
# returns a module # returns a module
{ pkgs, config, lib, ... }@args: { pkgs, config, lib, ... }@args:
with lib; with lib;
let let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
cfg = config.programs.nixvim.plugins.null-ls.sources.${sourceType}.${name}; cfg = config.plugins.null-ls.sources.${sourceType}.${name};
in in
{ {
options.programs.nixvim.plugins.null-ls.sources.${sourceType}.${name} = { options.plugins.null-ls.sources.${sourceType}.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
# TODO: withArgs can exist outside of the module in a generalized manner # TODO: withArgs can exist outside of the module in a generalized manner
@ -31,16 +31,16 @@
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPackages = packages; extraPackages = packages;
# Add source to list of sources # Add source to list of sources
plugins.null-ls.sourcesItems = let plugins.null-ls.sourcesItems =
let
sourceItem = "${sourceType}.${name}"; sourceItem = "${sourceType}.${name}";
withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}"; withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}''; finalString = ''require("null-ls").builtins.${withArgs}'';
in [ (helpers.mkRaw finalString) ]; in
}; [ (helpers.mkRaw finalString) ];
}; };
}; };
} }

View file

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lsp; cfg = config.plugins.lsp;
helpers = (import ../helpers.nix { inherit lib; }); helpers = (import ../helpers.nix { inherit lib; });
in in
{ {
@ -10,11 +10,13 @@ in
]; ];
options = { options = {
programs.nixvim.plugins.lsp = { plugins.lsp = {
enable = mkEnableOption "Enable neovim's built-in LSP"; enable = mkEnableOption "Enable neovim's built-in LSP";
enabledServers = mkOption { enabledServers = mkOption {
type = with types; listOf (oneOf [str (submodule { type = with types; listOf (oneOf [
str
(submodule {
options = { options = {
name = mkOption { name = mkOption {
type = str; type = str;
@ -26,7 +28,8 @@ in
description = "Extra options for the server"; description = "Extra options for the server";
}; };
}; };
})]); })
]);
description = "A list of enabled LSP servers. Don't use this directly."; description = "A list of enabled LSP servers. Don't use this directly.";
default = [ ]; default = [ ];
}; };
@ -51,12 +54,13 @@ in
}; };
}; };
config = let config =
let
runWrappers = wrappers: s: runWrappers = wrappers: s:
if wrappers == [ ] then s if wrappers == [ ] then s
else (head wrappers) (runWrappers (tail wrappers) s); else (head wrappers) (runWrappers (tail wrappers) s);
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ]; extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ];
# Enable all LSP servers # Enable all LSP servers
@ -85,5 +89,4 @@ in
-- }}} -- }}}
''; '';
}; };
};
} }

View file

@ -1,29 +1,30 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
{ {
mkLsp = { mkLsp =
name, { name
description ? "Enable ${name}.", , description ? "Enable ${name}."
serverName ? name, , serverName ? name
packages ? [ pkgs.${name} ], , packages ? [ pkgs.${name} ]
... }: , ...
}:
# returns a module # returns a module
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lsp.servers.${name}; cfg = config.plugins.lsp.servers.${name};
in in
{ {
options = { options = {
programs.nixvim.plugins.lsp.servers.${name} = { plugins.lsp.servers.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim.extraPackages = packages; extraPackages = packages;
programs.nixvim.plugins.lsp.enabledServers = [ serverName ]; plugins.lsp.enabledServers = [ serverName ];
}; };
}; };
} }

View file

@ -1,17 +1,17 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lsp-lines; cfg = config.plugins.lsp-lines;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.lsp-lines = { plugins.lsp-lines = {
enable = mkEnableOption "lsp_lines.nvim"; enable = mkEnableOption "lsp_lines.nvim";
}; };
}; };
config.programs.nixvim = config =
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.lsp_lines-nvim ]; extraPlugins = [ pkgs.vimPlugins.lsp_lines-nvim ];

View file

@ -1,12 +1,12 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lspsaga; cfg = config.plugins.lspsaga;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.lspsaga = { plugins.lspsaga = {
enable = mkEnableOption "Enable lspsava.nvim"; enable = mkEnableOption "Enable lspsava.nvim";
signs = { signs = {
@ -141,7 +141,7 @@ in
}; };
}; };
config.programs.nixvim = let config = let
notDefault = default: opt: if (opt != default) then opt else null; notDefault = default: opt: if (opt != default) then opt else null;
notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != {}) then opt else null; notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != {}) then opt else null;
notNull = opt: opt; notNull = opt: opt;

View file

@ -1,22 +1,26 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.packer; cfg = config.plugins.packer;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
in { in
{
options = { options = {
programs.nixvim.plugins.packer = { plugins.packer = {
enable = mkEnableOption "Enable packer.nvim"; enable = mkEnableOption "Enable packer.nvim";
plugins = mkOption { plugins = mkOption {
type = types.listOf (types.oneOf [types.str (with types; let type = types.listOf (types.oneOf [
types.str
(with types; let
mkOpt = type: desc: mkOption { mkOpt = type: desc: mkOption {
type = nullOr type; type = nullOr type;
default = null; default = null;
description = desc; description = desc;
}; };
function = attrsOf str; function = attrsOf str;
in types.submodule { in
types.submodule {
options = { options = {
name = mkOption { name = mkOption {
type = str; type = str;
@ -47,7 +51,8 @@ in {
cond = mkOpt (oneOf [ str function (listOf (oneOf [ str function ])) ]) "Conditional test to load this plugin"; cond = mkOpt (oneOf [ str function (listOf (oneOf [ str function ])) ]) "Conditional test to load this plugin";
module = mkOpt (oneOf [ str (listOf str) ]) "Patterns of module names which load this plugin"; module = mkOpt (oneOf [ str (listOf str) ]) "Patterns of module names which load this plugin";
}; };
})]); })
]);
default = [ ]; default = [ ];
description = "List of plugins"; description = "List of plugins";
}; };
@ -55,20 +60,23 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ (pkgs.vimPlugins.packer-nvim.overrideAttrs (_: { pname = "packer.nvim"; })) ]; extraPlugins = [ (pkgs.vimPlugins.packer-nvim.overrideAttrs (_: { pname = "packer.nvim"; })) ];
extraPackages = [ pkgs.git ]; extraPackages = [ pkgs.git ];
extraConfigLua = let extraConfigLua =
plugins = map (plugin: if isAttrs plugin then let
plugins = map
(plugin:
if isAttrs plugin then
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin
else plugin) cfg.plugins; else plugin)
cfg.plugins;
packedPlugins = if length plugins == 1 then head plugins else plugins; packedPlugins = if length plugins == 1 then head plugins else plugins;
in mkIf (cfg.plugins != []) '' in
mkIf (cfg.plugins != [ ]) ''
require('packer').startup(function() require('packer').startup(function()
use ${helpers.toLuaObject packedPlugins} use ${helpers.toLuaObject packedPlugins}
end) end)
''; '';
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.airline; cfg = config.plugins.airline;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
sectionType = with types; nullOr (oneOf [ str (listOf str) ]); sectionType = with types; nullOr (oneOf [ str (listOf str) ]);
@ -10,9 +10,10 @@ let
type = sectionType; type = sectionType;
description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*."; description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*.";
}; };
in { in
{
options = { options = {
programs.nixvim.plugins.airline = { plugins.airline = {
enable = mkEnableOption "Enable airline"; enable = mkEnableOption "Enable airline";
extensions = mkOption { extensions = mkOption {
@ -49,17 +50,18 @@ in {
}; };
theme = mkOption { theme = mkOption {
default = config.programs.nixvim.colorscheme; default = config.colorscheme;
type = with types; nullOr str; type = with types; nullOr str;
description = "The theme to use for vim-airline. If set, vim-airline-themes will be installed."; description = "The theme to use for vim-airline. If set, vim-airline-themes will be installed.";
}; };
}; };
}; };
config = let config =
let
sections = { }; sections = { };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
vim-airline vim-airline
] ++ optional (!isNull cfg.theme) vim-airline-themes; ] ++ optional (!isNull cfg.theme) vim-airline-themes;
@ -72,5 +74,4 @@ in {
airline_theme = mkIf (!isNull cfg.theme) cfg.theme; airline_theme = mkIf (!isNull cfg.theme) cfg.theme;
} // sections; } // sections;
}; };
};
} }

View file

@ -1,16 +1,17 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lightline; cfg = config.plugins.lightline;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in { in
{
options = { options = {
programs.nixvim.plugins.lightline = { plugins.lightline = {
enable = mkEnableOption "Enable lightline"; enable = mkEnableOption "Enable lightline";
colorscheme = mkOption { colorscheme = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = config.programs.nixvim.colorscheme; default = config.colorscheme;
description = "The colorscheme to use for lightline. Defaults to .colorscheme."; description = "The colorscheme to use for lightline. Defaults to .colorscheme.";
example = "gruvbox"; example = "gruvbox";
}; };
@ -24,7 +25,7 @@ in {
You should define the functions themselves in extraConfig You should define the functions themselves in extraConfig
''; '';
example = '' example = ''
programs.nixvim.plugins.lightline = { plugins.lightline = {
enable = true; enable = true;
componentFunction = { componentFunction = {
readonly = "LightlineReadonly"; readonly = "LightlineReadonly";
@ -48,9 +49,11 @@ in {
active = mkOption { active = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule { type = types.nullOr (types.submodule {
options = let options =
let
listType = with types; nullOr (listOf (listOf str)); listType = with types; nullOr (listOf (listOf str));
in { in
{
left = mkOption { left = mkOption {
type = listType; type = listType;
description = "List of components that will show up on the left side of the bar"; description = "List of components that will show up on the left side of the bar";
@ -74,14 +77,14 @@ in {
}; };
}; };
config = let config =
let
configAttrs = filterAttrs (_: v: v != null) { configAttrs = filterAttrs (_: v: v != null) {
inherit (cfg) colorscheme active component componentFunction modeMap; inherit (cfg) colorscheme active component componentFunction modeMap;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.lightline-vim ]; extraPlugins = [ pkgs.vimPlugins.lightline-vim ];
globals.lightline = mkIf (configAttrs != { }) configAttrs; globals.lightline = mkIf (configAttrs != { }) configAttrs;
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.lualine; cfg = config.plugins.lualine;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
separators = mkOption { separators = mkOption {
type = types.nullOr (types.submodule { type = types.nullOr (types.submodule {
@ -43,13 +43,14 @@ let
}); });
default = null; default = null;
}; };
in { in
{
options = { options = {
programs.nixvim.plugins.lualine = { plugins.lualine = {
enable = mkEnableOption "Enable lualine"; enable = mkEnableOption "Enable lualine";
theme = mkOption { theme = mkOption {
default = config.programs.nixvim.colorscheme; default = config.colorscheme;
type = types.nullOr types.str; type = types.nullOr types.str;
description = "The theme to use for lualine-nvim."; description = "The theme to use for lualine-nvim.";
}; };
@ -109,7 +110,8 @@ in {
}; };
}; };
}; };
config = let config =
let
setupOptions = { setupOptions = {
options = { options = {
theme = cfg.theme; theme = cfg.theme;
@ -123,11 +125,10 @@ in {
tabline = cfg.tabline; tabline = cfg.tabline;
extensions = cfg.extensions; extensions = cfg.extensions;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.lualine-nvim ]; extraPlugins = [ pkgs.vimPlugins.lualine-nvim ];
extraConfigLua = extraConfigLua =
''require("lualine").setup(${helpers.toLuaObject setupOptions})''; ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.telescope; cfg = config.plugins.telescope;
helpers = (import ../helpers.nix { inherit lib; }); helpers = (import ../helpers.nix { inherit lib; });
in in
{ {
@ -14,13 +14,13 @@ in
# TODO:add support for aditional filetypes. This requires autocommands! # TODO:add support for aditional filetypes. This requires autocommands!
options.programs.nixvim.plugins.telescope = { options.plugins.telescope = {
enable = mkEnableOption "Enable telescope.nvim"; enable = mkEnableOption "Enable telescope.nvim";
highlightTheme = mkOption { highlightTheme = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
description = "The colorscheme to use for syntax highlighting"; description = "The colorscheme to use for syntax highlighting";
default = config.programs.nixvim.colorscheme; default = config.colorscheme;
}; };
enabledExtensions = mkOption { enabledExtensions = mkOption {
@ -37,7 +37,6 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPackages = [ pkgs.bat ]; extraPackages = [ pkgs.bat ];
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
@ -64,5 +63,4 @@ in
end end
''; '';
}; };
};
} }

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.telescope.extensions.frecency; cfg = config.plugins.telescope.extensions.frecency;
in in
{ {
options.programs.nixvim.plugins.telescope.extensions.frecency = { options.plugins.telescope.extensions.frecency = {
enable = mkEnableOption "Enable frecency"; enable = mkEnableOption "Enable frecency";
dbRoot = mkOption { dbRoot = mkOption {
@ -55,13 +55,13 @@ in
devicons_disabled = cfg.deviconsDisabled; devicons_disabled = cfg.deviconsDisabled;
}; };
in mkIf cfg.enable { in mkIf cfg.enable {
programs.nixvim.extraPackages = [ pkgs.sqlite ]; extraPackages = [ pkgs.sqlite ];
programs.nixvim.extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
telescope-frecency-nvim telescope-frecency-nvim
sqlite-lua sqlite-lua
]; ];
programs.nixvim.plugins.telescope.enabledExtensions = [ "frecency" ]; plugins.telescope.enabledExtensions = [ "frecency" ];
programs.nixvim.plugins.telescope.extensionConfig."frecency" = configuration; plugins.telescope.extensionConfig."frecency" = configuration;
}; };
} }

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.telescope.extensions.fzf-native; cfg = config.plugins.telescope.extensions.fzf-native;
in in
{ {
options.programs.nixvim.plugins.telescope.extensions.fzf-native = { options.plugins.telescope.extensions.fzf-native = {
enable = mkEnableOption "Enable fzf-native"; enable = mkEnableOption "Enable fzf-native";
fuzzy = mkOption { fuzzy = mkOption {
@ -36,9 +36,9 @@ in
case_mode = cfg.caseMode; case_mode = cfg.caseMode;
}; };
in mkIf cfg.enable { in mkIf cfg.enable {
programs.nixvim.extraPlugins = [ pkgs.vimPlugins.telescope-fzf-native-nvim ]; extraPlugins = [ pkgs.vimPlugins.telescope-fzf-native-nvim ];
programs.nixvim.plugins.telescope.enabledExtensions = [ "fzf" ]; plugins.telescope.enabledExtensions = [ "fzf" ];
programs.nixvim.plugins.telescope.extensionConfig."fzf" = configuration; plugins.telescope.extensionConfig."fzf" = configuration;
}; };
} }

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ...}: { pkgs, config, lib, ...}:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.telescope.extensions.fzy-native; cfg = config.plugins.telescope.extensions.fzy-native;
in in
{ {
options.programs.nixvim.plugins.telescope.extensions.fzy-native = { options.plugins.telescope.extensions.fzy-native = {
enable = mkEnableOption "Enable fzy-native"; enable = mkEnableOption "Enable fzy-native";
overrideGenericSorter = mkOption { overrideGenericSorter = mkOption {
@ -25,9 +25,9 @@ in
override_file_sorter = cfg.overrideFileSorter; override_file_sorter = cfg.overrideFileSorter;
}; };
in mkIf cfg.enable { in mkIf cfg.enable {
programs.nixvim.extraPlugins = [ pkgs.vimPlugins.telescope-fzy-native-nvim ]; extraPlugins = [ pkgs.vimPlugins.telescope-fzy-native-nvim ];
programs.nixvim.plugins.telescope.enabledExtensions = [ "fzy_native" ]; plugins.telescope.enabledExtensions = [ "fzy_native" ];
programs.nixvim.plugins.telescope.extensionConfig."fzy_native" = configuration; plugins.telescope.extensionConfig."fzy_native" = configuration;
}; };
} }

View file

@ -1,10 +1,10 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.telescope.extensions.media_files; cfg = config.plugins.telescope.extensions.media_files;
in in
{ {
options.programs.nixvim.plugins.telescope.extensions.media_files = { options.plugins.telescope.extensions.media_files = {
enable = mkEnableOption "Enable media_files extension for telescope"; enable = mkEnableOption "Enable media_files extension for telescope";
filetypes = mkOption { filetypes = mkOption {
@ -20,7 +20,6 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
plugins.telescope.enabledExtensions = [ "media_files" ]; plugins.telescope.enabledExtensions = [ "media_files" ];
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
@ -33,6 +32,4 @@ in
ueberzug ueberzug
]; ];
}; };
};
} }

View file

@ -1,12 +1,12 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.comment-nvim; cfg = config.plugins.comment-nvim;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.comment-nvim = { plugins.comment-nvim = {
enable = mkEnableOption "Enable comment-nvim"; enable = mkEnableOption "Enable comment-nvim";
padding = mkOption { padding = mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
@ -85,7 +85,8 @@ in
}; };
}; };
config = let config =
let
setupOptions = { setupOptions = {
padding = cfg.padding; padding = cfg.padding;
sticky = cfg.sticky; sticky = cfg.sticky;
@ -94,11 +95,10 @@ in
opleader = cfg.opleader; opleader = cfg.opleader;
mappings = cfg.mappings; mappings = cfg.mappings;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.comment-nvim ]; extraPlugins = [ pkgs.vimPlugins.comment-nvim ];
extraConfigLua = extraConfigLua =
''require("Comment").setup${helpers.toLuaObject setupOptions}''; ''require("Comment").setup${helpers.toLuaObject setupOptions}'';
}; };
};
} }

View file

@ -1,20 +1,18 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.commentary; cfg = config.plugins.commentary;
in in
{ {
# TODO Add support for aditional filetypes. This requires autocommands! # TODO Add support for aditional filetypes. This requires autocommands!
options = { options = {
programs.nixvim.plugins.commentary = { plugins.commentary = {
enable = mkEnableOption "Enable commentary"; enable = mkEnableOption "Enable commentary";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.vim-commentary ]; extraPlugins = [ pkgs.vimPlugins.vim-commentary ];
}; };
};
} }

View file

@ -1,13 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.dashboard; cfg = config.plugins.dashboard;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.dashboard = { plugins.dashboard = {
enable = mkEnableOption "Enable dashboard"; enable = mkEnableOption "Enable dashboard";
header = mkOption { header = mkOption {
@ -124,8 +124,8 @@ in
}; };
filteredOptions = filterAttrs (_: v: !isNull v) options; filteredOptions = filterAttrs (_: v: !isNull v) options;
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ]; extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ];
extraConfigLua = '' extraConfigLua = ''
local dashboard = require("dashboard") local dashboard = require("dashboard")
@ -135,5 +135,4 @@ in
filteredOptions)} filteredOptions)}
''; '';
}; };
};
} }

View file

@ -1,20 +1,18 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.easyescape; cfg = config.plugins.easyescape;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.easyescape = { plugins.easyescape = {
enable = mkEnableOption "Enable easyescape"; enable = mkEnableOption "Enable easyescape";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
vim-easyescape vim-easyescape
]; ];
}; };
};
} }

View file

@ -1,12 +1,12 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.floaterm; cfg = config.plugins.floaterm;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in in
{ {
options = { options = {
programs.nixvim.plugins.floaterm = { plugins.floaterm = {
enable = mkEnableOption "Enable floaterm"; enable = mkEnableOption "Enable floaterm";
shell = mkOption { shell = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -64,7 +64,6 @@ in
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
vim-floaterm vim-floaterm
]; ];
@ -82,5 +81,4 @@ in
floaterm_autoInsert = mkIf (!isNull cfg.autoInsert) cfg.autoInsert; floaterm_autoInsert = mkIf (!isNull cfg.autoInsert) cfg.autoInsert;
}; };
}; };
};
} }

View file

@ -1,18 +1,17 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.comment-nvim; cfg = config.plugins.comment-nvim;
defs = import ../plugin-defs.nix { inherit pkgs; }; defs = import ../plugin-defs.nix { inherit pkgs; };
in in
{ {
options = { options = {
programs.nixvim.plugins.intellitab = { plugins.intellitab = {
enable = mkEnableOption "intellitab.nvim"; enable = mkEnableOption "intellitab.nvim";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ defs.intellitab-nvim ]; extraPlugins = [ defs.intellitab-nvim ];
maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>"; maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>";
@ -20,5 +19,4 @@ in
indent = true; indent = true;
}; };
}; };
};
} }

View file

@ -2,11 +2,12 @@
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.mark-radar; cfg = config.plugins.mark-radar;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
defs = import ../plugin-defs.nix { inherit pkgs; }; defs = import ../plugin-defs.nix { inherit pkgs; };
in { in
options.programs.nixvim.plugins.mark-radar = { {
options.plugins.mark-radar = {
enable = mkEnableOption "Enable mark-radar"; enable = mkEnableOption "Enable mark-radar";
highlight_background = mkOption { highlight_background = mkOption {
@ -30,19 +31,19 @@ in {
}; };
}; };
config = let config =
let
opts = helpers.toLuaObject { opts = helpers.toLuaObject {
inherit (cfg) highlight_group background_highlight_group; inherit (cfg) highlight_group background_highlight_group;
set_default_mappings = cfg.set_default_keybinds; set_default_mappings = cfg.set_default_keybinds;
background_highlight = cfg.highlight_background; background_highlight = cfg.highlight_background;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ defs.mark-radar ]; extraPlugins = [ defs.mark-radar ];
extraConfigLua = '' extraConfigLua = ''
require("mark-radar").setup(${opts}) require("mark-radar").setup(${opts})
''; '';
}; };
};
} }

View file

@ -1,7 +1,7 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.notify; cfg = config.plugins.notify;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
icon = mkOption { icon = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -9,7 +9,7 @@ let
}; };
in in
{ {
options.programs.nixvim.plugins.notify = { options.plugins.notify = {
enable = mkEnableOption "Enable notify"; enable = mkEnableOption "Enable notify";
stages = mkOption { stages = mkOption {
@ -47,7 +47,8 @@ in
}; };
}; };
config = let config =
let
setupOptions = with cfg; { setupOptions = with cfg; {
stages = stages; stages = stages;
timeout = timeout; timeout = timeout;
@ -61,13 +62,12 @@ in
TRACE = trace; TRACE = trace;
}; };
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.nvim-notify ]; extraPlugins = [ pkgs.vimPlugins.nvim-notify ];
extraConfigLua = '' extraConfigLua = ''
vim.notify = require('notify'); vim.notify = require('notify');
require('notify').setup(${helpers.toLuaObject setupOptions}) require('notify').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };
};
} }

View file

@ -1,11 +1,11 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.nvim-autopairs; cfg = config.plugins.nvim-autopairs;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
in in
{ {
options.programs.nixvim.plugins.nvim-autopairs = { options.plugins.nvim-autopairs = {
enable = mkEnableOption "Enable nvim-autopairs"; enable = mkEnableOption "Enable nvim-autopairs";
pairs = mkOption { pairs = mkOption {
@ -39,7 +39,8 @@ in
}; };
}; };
config = let config =
let
options = { options = {
pairs_map = cfg.pairs; pairs_map = cfg.pairs;
disable_filetype = cfg.disabledFiletypes; disable_filetype = cfg.disabledFiletypes;
@ -47,13 +48,12 @@ in
html_break_line_filetype = cfg.htmlFiletypes; html_break_line_filetype = cfg.htmlFiletypes;
ignored_next_char = cfg.ignoredNextChar; ignored_next_char = cfg.ignoredNextChar;
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.nvim-autopairs ]; extraPlugins = [ pkgs.vimPlugins.nvim-autopairs ];
extraConfigLua = '' extraConfigLua = ''
require('nvim-autopairs').setup(${helpers.toLuaObject options}) require('nvim-autopairs').setup(${helpers.toLuaObject options})
''; '';
}; };
};
} }

View file

@ -1,11 +1,11 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.nvim-tree; cfg = config.plugins.nvim-tree;
helpers = import ../helpers.nix { lib = lib; }; helpers = import ../helpers.nix { lib = lib; };
in in
{ {
options.programs.nixvim.plugins.nvim-tree = { options.plugins.nvim-tree = {
enable = mkEnableOption "Enable nvim-tree"; enable = mkEnableOption "Enable nvim-tree";
disableNetrw = mkOption { disableNetrw = mkOption {
@ -72,13 +72,15 @@ in
description = "Enable diagnostics"; description = "Enable diagnostics";
}; };
icons = let icons =
let
diagnosticOption = desc: mkOption { diagnosticOption = desc: mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = desc; description = desc;
}; };
in { in
{
hint = diagnosticOption "Hints"; hint = diagnosticOption "Hints";
info = diagnosticOption "Info"; info = diagnosticOption "Info";
warning = diagnosticOption "Warning"; warning = diagnosticOption "Warning";
@ -201,7 +203,8 @@ in
}; };
}; };
config = let config =
let
options = { options = {
disable_netrw = cfg.disableNetrw; disable_netrw = cfg.disableNetrw;
hijack_netrw = cfg.hijackNetrw; hijack_netrw = cfg.hijackNetrw;
@ -243,15 +246,15 @@ in
require_confirm = cfg.trash.requireConfirm; require_confirm = cfg.trash.requireConfirm;
}; };
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
nvim-tree-lua nvim-web-devicons nvim-tree-lua
nvim-web-devicons
]; ];
extraConfigLua = '' extraConfigLua = ''
require('nvim-tree').setup(${helpers.toLuaObject options}) require('nvim-tree').setup(${helpers.toLuaObject options})
''; '';
}; };
};
} }

View file

@ -1,10 +1,11 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.specs; cfg = config.plugins.specs;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in { in
options.programs.nixvim.plugins.specs = { {
options.plugins.specs = {
enable = mkEnableOption "Enable specs-nvim"; enable = mkEnableOption "Enable specs-nvim";
show_jumps = mkOption { show_jumps = mkOption {
@ -104,7 +105,8 @@ in {
}; };
}; };
config = let config =
let
setup = helpers.toLuaObject { setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump; inherit (cfg) show_jumps min_jump;
ignore_filetypes = attrsets.listToAttrs ignore_filetypes = attrsets.listToAttrs
@ -127,13 +129,12 @@ in {
''require("specs").${cfg.resizer.builtin}''); ''require("specs").${cfg.resizer.builtin}'');
}; };
}; };
in mkIf cfg.enable { in
programs.nixvim = { mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.specs-nvim ]; extraPlugins = [ pkgs.vimPlugins.specs-nvim ];
extraConfigLua = '' extraConfigLua = ''
require('specs').setup(${setup}) require('specs').setup(${setup})
''; '';
}; };
};
} }

View file

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib; with lib;
let let
cfg = config.programs.nixvim.plugins.undotree; cfg = config.plugins.undotree;
helpers = import ../helpers.nix { inherit lib; }; helpers = import ../helpers.nix { inherit lib; };
in { in
{
options = { options = {
programs.nixvim.plugins.undotree = { plugins.undotree = {
enable = mkEnableOption "Enable undotree"; enable = mkEnableOption "Enable undotree";
windowLayout = mkOption { windowLayout = mkOption {
@ -107,7 +108,6 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.undotree ]; extraPlugins = [ pkgs.vimPlugins.undotree ];
globals = { globals = {
@ -129,5 +129,4 @@ in {
undotree_CursorLine = mkIf (!cfg.showCursorLine) 0; undotree_CursorLine = mkIf (!cfg.showCursorLine) 0;
}; };
}; };
};
} }

104
tests/flake.lock generated Normal file
View file

@ -0,0 +1,104 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1661353537,
"narHash": "sha256-1E2IGPajOsrkR49mM5h55OtYnU0dGyre6gl60NXKITE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0e304ff0d9db453a4b230e9386418fd974d5804a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1661353537,
"narHash": "sha256-1E2IGPajOsrkR49mM5h55OtYnU0dGyre6gl60NXKITE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0e304ff0d9db453a4b230e9386418fd974d5804a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixvim": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2",
"nmdSrc": "nmdSrc"
},
"locked": {
"lastModified": 0,
"narHash": "sha256-TGzzj1r1lqxquirvC3yzhuh2fYamEjWIrKG1RMtwsSA=",
"path": "/nix/store/pql62xd29lxl70icdqc97qiarqkalwga-source",
"type": "path"
},
"original": {
"path": "/nix/store/pql62xd29lxl70icdqc97qiarqkalwga-source",
"type": "path"
}
},
"nmdSrc": {
"flake": false,
"locked": {
"lastModified": 1654807200,
"narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=",
"owner": "rycee",
"repo": "nmd",
"rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29",
"type": "gitlab"
},
"original": {
"owner": "rycee",
"repo": "nmd",
"type": "gitlab"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim"
}
}
},
"root": "root",
"version": 7
}

82
tests/flake.nix Normal file
View file

@ -0,0 +1,82 @@
{
description = "A set of test configurations for nixvim";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixvim.url = "./..";
outputs = { self, nixvim, nixpkgs, flake-utils, ... }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
build = nixvim.build pkgs;
in
rec {
# A plain nixvim configuration
packages = {
plain = build { };
# Should print "Hello!" when starting up
hello = build {
extraConfigLua = "print(\"Hello!\")";
};
simple-plugin = build {
extraPlugins = [ pkgs.vimPlugins.vim-surround ];
};
gruvbox = build {
extraPlugins = [ pkgs.vimPlugins.gruvbox ];
colorscheme = "gruvbox";
};
gruvbox-module = build {
colorschemes.gruvbox.enable = true;
};
treesitter = build {
plugins.treesitter.enable = true;
};
treesitter-nonix = build {
plugins.treesitter = {
enable = true;
nixGrammars = false;
};
};
};
})) // {
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
environment.systemPackages = [
(nixvim.build pkgs { colorschemes.gruvbox.enable = true; })
];
})
];
};
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
({ pkgs, ... }: {
boot.isContainer = true;
# Let 'nixos-version --json' know about the Git revision
# of this flake.
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
imports = [
nixvim.nixosModules.x86_64-linux.nixvim
];
programs.nixvim = {
enable = true;
colorschemes.gruvbox.enable = true;
};
})
];
};
};
}