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";
}; };
@ -39,12 +34,15 @@ let
documentsDirectory = ./.; documentsDirectory = ./.;
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));
nixosModules.nixvim = import ./nixvim.nix { nixos = true; }; modules = pkgs: nixvimModules ++ [
homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; }; (rec {
_file = ./flake.nix;
# This is a simple container for testing key = _file;
nixosConfigurations.container = nixpkgs.lib.nixosSystem { config = {
system = "x86_64-linux"; _module.args = {
modules = [ pkgs = mkForce pkgs;
({ pkgs, ... }: { lib = pkgs.lib;
boot.isContainer = true; helpers = import ./plugins/helpers.nix { lib = pkgs.lib; };
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;
@ -118,7 +118,7 @@ in
}; };
showBufferIcons = mkOption { showBufferIcons = mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
}; };
showBufferCloseIcons = mkOption { showBufferCloseIcons = mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
@ -154,7 +154,7 @@ in
}; };
highlights = mkOption { highlights = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({...}: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
fill = highlight; fill = highlight;
background = highlight; background = highlight;
@ -221,102 +221,103 @@ in
}; };
}; };
config = let config =
setupOptions = { let
options = { setupOptions = {
numbers = cfg.numbers; options = {
close_command = cfg.closeCommand; numbers = cfg.numbers;
right_mouse_command = cfg.rightMouseCommand; close_command = cfg.closeCommand;
left_mouse_command = cfg.leftMouseCommand; right_mouse_command = cfg.rightMouseCommand;
middle_mouse_command = cfg.middleMouseCommand; left_mouse_command = cfg.leftMouseCommand;
indicator_icon = cfg.indicatorIcon; middle_mouse_command = cfg.middleMouseCommand;
buffer_close_icon = cfg.bufferCloseIcon; indicator_icon = cfg.indicatorIcon;
modified_icon = cfg.modifiedIcon; buffer_close_icon = cfg.bufferCloseIcon;
close_icon = cfg.closeIcon; modified_icon = cfg.modifiedIcon;
left_trunc_marker = cfg.leftTruncMarker; close_icon = cfg.closeIcon;
right_trunc_marker = cfg.rightTruncMarker; left_trunc_marker = cfg.leftTruncMarker;
name_formatter = cfg.nameFormatter; right_trunc_marker = cfg.rightTruncMarker;
max_name_length = cfg.maxNameLength; name_formatter = cfg.nameFormatter;
max_prefix_length = cfg.maxPrefixLength; max_name_length = cfg.maxNameLength;
tab_size = cfg.tabSize; max_prefix_length = cfg.maxPrefixLength;
diagnostics = cfg.diagnostics; tab_size = cfg.tabSize;
diagnostics_update_in_insert = cfg.diagnosticsUpdateInInsert; diagnostics = cfg.diagnostics;
diagnostics_indicator = cfg.diagnosticsIndicator; diagnostics_update_in_insert = cfg.diagnosticsUpdateInInsert;
custom_filter = cfg.customFilter; diagnostics_indicator = cfg.diagnosticsIndicator;
show_buffer_icons = cfg.showBufferIcons; custom_filter = cfg.customFilter;
show_buffer_close_icons = cfg.showBufferCloseIcons; show_buffer_icons = cfg.showBufferIcons;
show_close_icon = cfg.showCloseIcon; show_buffer_close_icons = cfg.showBufferCloseIcons;
show_tab_indicators = cfg.showTabIndicators; show_close_icon = cfg.showCloseIcon;
persist_buffer_sort = cfg.persistBufferSort; show_tab_indicators = cfg.showTabIndicators;
separator_style = cfg.separatorStyle; persist_buffer_sort = cfg.persistBufferSort;
enforce_regular_tabs = cfg.enforceRegularTabs; separator_style = cfg.separatorStyle;
always_show_bufferline = cfg.alwaysShowBufferline; enforce_regular_tabs = cfg.enforceRegularTabs;
sort_by = cfg.sortBy; always_show_bufferline = cfg.alwaysShowBufferline;
sort_by = cfg.sortBy;
};
highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; {
fill = fill;
background = background;
tab = tab;
tab_selected = tabSelected;
tab_close = tabClose;
close_button = closeButton;
close_button_visible = closeButtonVisible;
close_button_selected = closeButtonSelected;
buffer_visible = bufferVisible;
buffer_selected = bufferSelected;
diagnostic = diagnostic;
diagnostic_visible = diagnosticVisible;
diagnostic_selected = diagnosticSelected;
info = info;
info_visible = infoVisible;
info_selected = infoSelected;
info_diagnostic = infoDiagnostic;
info_diagnostic_visible = infoDiagnosticVisible;
info_diagnostic_selected = infoDiagnosticSelected;
warning = warning;
warning_visible = warningVisible;
warning_selected = warningSelected;
warning_diagnostic = warningDiagnostic;
warning_diagnostic_visible = warningDiagnosticVisible;
warning_diagnostic_selected = warningDiagnosticSelected;
error = error;
error_visible = errorVisible;
error_selected = errorSelected;
error_dagnostic = errorDiagnostic;
error_diagnostic_visible = errorDiagnosticVisible;
error_diagnostic_selected = errorDiagnosticSelected;
modified = modified;
modified_visible = modifiedVisible;
modified_selected = modifiedSelected;
duplicate = duplicate;
duplicate_visible = duplicateVisible;
duplicate_selected = duplicateSelected;
separator = separator;
separator_visible = separatorVisible;
separator_selected = separatorSelected;
indicator_selected = indicatorSelected;
pick = pick;
pick_visible = pickVisible;
pick_selected = pickSelected;
};
}; };
highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; { in
fill = fill; mkIf cfg.enable {
background = background;
tab = tab;
tab_selected = tabSelected;
tab_close = tabClose;
close_button = closeButton;
close_button_visible = closeButtonVisible;
close_button_selected = closeButtonSelected;
buffer_visible = bufferVisible;
buffer_selected = bufferSelected;
diagnostic = diagnostic;
diagnostic_visible = diagnosticVisible;
diagnostic_selected = diagnosticSelected;
info = info;
info_visible = infoVisible;
info_selected = infoSelected;
info_diagnostic = infoDiagnostic;
info_diagnostic_visible = infoDiagnosticVisible;
info_diagnostic_selected = infoDiagnosticSelected;
warning = warning;
warning_visible = warningVisible;
warning_selected = warningSelected;
warning_diagnostic = warningDiagnostic;
warning_diagnostic_visible = warningDiagnosticVisible;
warning_diagnostic_selected = warningDiagnosticSelected;
error = error;
error_visible = errorVisible;
error_selected = errorSelected;
error_dagnostic = errorDiagnostic;
error_diagnostic_visible = errorDiagnosticVisible;
error_diagnostic_selected = errorDiagnosticSelected;
modified = modified;
modified_visible = modifiedVisible;
modified_selected = modifiedSelected;
duplicate = duplicate;
duplicate_visible = duplicateVisible;
duplicate_selected = duplicateSelected;
separator = separator;
separator_visible = separatorVisible;
separator_selected = separatorSelected;
indicator_selected = indicatorSelected;
pick = pick;
pick_visible = pickVisible;
pick_selected = pickSelected;
};
};
in mkIf cfg.enable {
programs.nixvim = {
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,14 +29,12 @@ 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 ];
plugins.airline.theme = mkIf (cfg.setUpBar) "base16"; plugins.airline.theme = mkIf (cfg.setUpBar) "base16";
plugins.lightline.colorscheme = null; plugins.lightline.colorscheme = null;
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,33 +112,31 @@ 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 ];
globals = { globals = {
gruvbox_bold = mkIf (!cfg.bold) 0; gruvbox_bold = mkIf (!cfg.bold) 0;
gruvbox_italic = mkIf (cfg.italics) 1; gruvbox_italic = mkIf (cfg.italics) 1;
gruvbox_underline = mkIf (cfg.underline) 1; gruvbox_underline = mkIf (cfg.underline) 1;
gruvbox_undercurl = mkIf (cfg.undercurl) 1; gruvbox_undercurl = mkIf (cfg.undercurl) 1;
gruvbox_transparent_bg = mkIf (cfg.transparentBg) 0; gruvbox_transparent_bg = mkIf (cfg.transparentBg) 0;
gruvbox_contrast_dark = mkIf (!isNull cfg.contrastDark) cfg.contrastDark; gruvbox_contrast_dark = mkIf (!isNull cfg.contrastDark) cfg.contrastDark;
gruvbox_contrast_light = mkIf (!isNull cfg.contrastLight) cfg.contrastLight; gruvbox_contrast_light = mkIf (!isNull cfg.contrastLight) cfg.contrastLight;
gruvbox_hls_cursor = mkIf (!isNull cfg.highlightSearchCursor) cfg.highlightSearchCursor; gruvbox_hls_cursor = mkIf (!isNull cfg.highlightSearchCursor) cfg.highlightSearchCursor;
gruvbox_number_column = mkIf (!isNull cfg.numberColumn) cfg.numberColumn; gruvbox_number_column = mkIf (!isNull cfg.numberColumn) cfg.numberColumn;
gruvbox_sign_column = mkIf (!isNull cfg.signColumn) cfg.signColumn; gruvbox_sign_column = mkIf (!isNull cfg.signColumn) cfg.signColumn;
gruvbox_color_column = mkIf (!isNull cfg.colorColumn) cfg.colorColumn; gruvbox_color_column = mkIf (!isNull cfg.colorColumn) cfg.colorColumn;
gruvbox_vert_split = mkIf (!isNull cfg.vertSplitColor) cfg.vertSplitColor; gruvbox_vert_split = mkIf (!isNull cfg.vertSplitColor) cfg.vertSplitColor;
gruvbox_italicize_comments = mkIf (!cfg.italicizeComments) 0; gruvbox_italicize_comments = mkIf (!cfg.italicizeComments) 0;
gruvbox_italicize_strings = mkIf (cfg.italicizeStrings) 1; gruvbox_italicize_strings = mkIf (cfg.italicizeStrings) 1;
gruvbox_invert_selection = mkIf (!cfg.invertSelection) 0; gruvbox_invert_selection = mkIf (!cfg.invertSelection) 0;
gruvbox_invert_signs = mkIf (cfg.invertSigns) 1; gruvbox_invert_signs = mkIf (cfg.invertSigns) 1;
gruvbox_invert_indent_guides = mkIf (cfg.invertIndentGuides) 1; gruvbox_invert_indent_guides = mkIf (cfg.invertIndentGuides) 1;
gruvbox_invert_tabline = mkIf (cfg.invertTabline) 1; gruvbox_invert_tabline = mkIf (cfg.invertTabline) 1;
gruvbox_improved_strings = mkIf (cfg.improvedStrings) 1; gruvbox_improved_strings = mkIf (cfg.improvedStrings) 1;
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,18 +32,16 @@ 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 ];
globals = { globals = {
nord_contrast = mkIf cfg.contrast 1; nord_contrast = mkIf cfg.contrast 1;
nord_borders = mkIf cfg.borders 1; nord_borders = mkIf cfg.borders 1;
nord_disable_background = mkIf cfg.disable_background 1; nord_disable_background = mkIf cfg.disable_background 1;
nord_cursoline_transparent = mkIf cfg.cursorline_transparent 1; nord_cursoline_transparent = mkIf cfg.cursorline_transparent 1;
nord_enable_sidebar_background = mkIf cfg.enable_sidebar_background 1; nord_enable_sidebar_background = mkIf cfg.enable_sidebar_background 1;
nord_italic = mkIf (cfg.italic != null) cfg.italic; nord_italic = mkIf (cfg.italic != null) cfg.italic;
};
}; };
}; };
} }

View file

@ -1,22 +1,21 @@
{ 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 ];
options = { options = {
termguicolors = true; termguicolors = true;
};
}; };
}; };
} }

View file

@ -1,22 +1,21 @@
{ 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 ];
options = { options = {
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,27 +34,25 @@ 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; }; globals = {
globals = { tokyonight_style = mkIf (!isNull cfg.style) cfg.style;
tokyonight_style = mkIf (!isNull cfg.style) cfg.style; tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0;
tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0;
tokyonight_italic_comments = mkIf (!cfg.italicComments) 0; tokyonight_italic_comments = mkIf (!cfg.italicComments) 0;
tokyonight_italic_keywords = mkIf (!cfg.italicKeywords) 0; tokyonight_italic_keywords = mkIf (!cfg.italicKeywords) 0;
tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1; tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1;
tokyonight_italic_variables = mkIf (cfg.italicVariables) 1; tokyonight_italic_variables = mkIf (cfg.italicVariables) 1;
tokyonight_transparent = mkIf (cfg.transparent) 1; tokyonight_transparent = mkIf (cfg.transparent) 1;
tokyonight_hide_inactive_statusline = tokyonight_hide_inactive_statusline =
mkIf (cfg.hideInactiveStatusline) 1; mkIf (cfg.hideInactiveStatusline) 1;
tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1; tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1;
tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0; tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0;
tokyonight_dark_float = mkIf (!cfg.darkFloat) 0; tokyonight_dark_float = mkIf (!cfg.darkFloat) 0;
tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1; tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1;
};
}; };
}; };
} }

View file

@ -1,19 +1,20 @@
{ 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";
autoStart = mkOption { autoStart = mkOption {
type = with types; nullOr (oneOf [bool (enum ["shut-up"])]); type = with types; nullOr (oneOf [ bool (enum [ "shut-up" ]) ]);
default = null; default = null;
description = "Auto-start or shut up"; description = "Auto-start or shut up";
}; };
@ -25,13 +26,14 @@ in {
}; };
}; };
}; };
config = let config =
settings = { let
auto_start = cfg.autoStart; settings = {
"keymap.recommended" = cfg.recommendedKeymaps; auto_start = cfg.autoStart;
}; "keymap.recommended" = cfg.recommendedKeymaps;
in mkIf cfg.enable { };
programs.nixvim = { in
mkIf cfg.enable {
extraPlugins = [ extraPlugins = [
plugins.coq-nvim plugins.coq-nvim
] ++ optional cfg.installArtifacts plugins.coq-artifacts; ] ++ optional cfg.installArtifacts plugins.coq-artifacts;
@ -40,8 +42,7 @@ in {
vim.g.coq_settings = ${helpers.toLuaObject settings} vim.g.coq_settings = ${helpers.toLuaObject settings}
local coq = require 'coq' local coq = require 'coq'
''; '';
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,32 +392,30 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
programs.nixvim = { extraPlugins = [ pkgs.vimPlugins.nvim-cmp ];
extraPlugins = [ pkgs.vimPlugins.nvim-cmp ];
extraConfigLua = '' extraConfigLua = ''
local cmp = require('cmp') local cmp = require('cmp')
cmp.setup(${helpers.toLuaObject options}) cmp.setup(${helpers.toLuaObject options})
''; '';
# If auto_enable_sources is set to true, figure out which are provided by the user # If auto_enable_sources is set to true, figure out which are provided by the user
# and enable the corresponding plugins. # and enable the corresponding plugins.
plugins = plugins =
let let
flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources; flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources;
# Take only the names from the sources provided by the user # Take only the names from the sources provided by the user
found_sources = lists.unique (lists.map (source: source.name) flattened_sources); found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
# A list of known source names # A list of known source names
known_source_names = attrNames cmpLib.pluginAndSourceNames; known_source_names = attrNames cmpLib.pluginAndSourceNames;
attrs_enabled = listToAttrs (map attrs_enabled = listToAttrs (map
(name: { (name: {
name = cmpLib.pluginAndSourceNames.${name}; name = cmpLib.pluginAndSourceNames.${name};
value.enable = mkIf (elem name found_sources) true; value.enable = mkIf (elem name found_sources) true;
}) })
known_source_names); known_source_names);
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,24 +52,26 @@ in {
}; };
signs = mkOption { signs = mkOption {
type = let type =
signOption = desc: mkOption { let
type = types.nullOr types.str; signOption = desc: mkOption {
default = null; type = types.nullOr types.str;
description = "Sign for ${desc}"; default = null;
description = "Sign for ${desc}";
};
in
types.submodule {
options = {
added = signOption "added lines";
modified = signOption "modified lines";
removed = signOption "removed lines";
modifiedAbove = signOption "modified line above";
removedFirstLine = signOption "a removed first line";
removedAboveAndBelow = signOption "lines removed above and below";
modifiedRemoved = signOption "modified and removed lines";
};
}; };
in types.submodule { default = { };
options = {
added = signOption "added lines";
modified = signOption "modified lines";
removed = signOption "removed lines";
modifiedAbove = signOption "modified line above";
removedFirstLine = signOption "a removed first line";
removedAboveAndBelow = signOption "lines removed above and below";
modifiedRemoved = signOption "modified and removed lines";
};
};
default = {};
description = "Custom signs for the sign column"; description = "Custom signs for the sign column";
}; };
@ -91,19 +94,22 @@ in {
}; };
grep = mkOption { grep = mkOption {
type = types.nullOr (types.oneOf [ (types.submodule { type = types.nullOr (types.oneOf [
options = { (types.submodule {
command = mkOption { options = {
type = types.str; command = mkOption {
description = "The command to use as a grep alternative"; type = types.str;
}; description = "The command to use as a grep alternative";
};
package = mkOption { package = mkOption {
type = types.package; type = types.package;
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 =
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else []; let
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep; grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ];
in mkIf cfg.enable { grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
programs.nixvim = { in
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,20 +201,21 @@ in
}; };
}; };
config = let config =
setupOptions = with cfg; helpers.toLuaObject { let
inherit kind integrations signs sections mappings; setupOptions = with cfg; helpers.toLuaObject {
disable_signs = disableSigns; inherit kind integrations signs sections mappings;
disable_hint = disableHint; disable_signs = disableSigns;
disable_context_highlighting = disableContextHighlighting; disable_hint = disableHint;
disable_commit_confirmation = disableCommitConfirmation; disable_context_highlighting = disableContextHighlighting;
auto_refresh = autoRefresh; disable_commit_confirmation = disableCommitConfirmation;
disable_builtin_notifications = disableBuiltinNotifications; auto_refresh = autoRefresh;
use_magit_keybindings = useMagitKeybindings; disable_builtin_notifications = disableBuiltinNotifications;
commit_popup = commitPopup; use_magit_keybindings = useMagitKeybindings;
}; commit_popup = commitPopup;
in mkIf cfg.enable { };
programs.nixvim = { in
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,20 +93,18 @@ 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}) '';
'';
extraPlugins = with pkgs; if cfg.nixGrammars then extraPlugins = with pkgs; if cfg.nixGrammars then
[ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ] [ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ]
else [ vimPlugins.nvim-treesitter ]; else [ vimPlugins.nvim-treesitter ];
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; extraPackages = [ pkgs.tree-sitter pkgs.nodejs ];
options = mkIf cfg.folding { options = mkIf cfg.folding {
foldmethod = "expr"; foldmethod = "expr";
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 =
options = { let
debug = cfg.debug; options = {
sources = cfg.sourcesItems; debug = cfg.debug;
}; sources = cfg.sourcesItems;
in mkIf cfg.enable { };
programs.nixvim = { in
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,46 +1,46 @@
{ 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 }:
{ pkgs, config, lib, ... }@args: # returns a module
with lib; { pkgs, config, lib, ... }@args:
let with lib;
helpers = import ../helpers.nix args; let
cfg = config.programs.nixvim.plugins.null-ls.sources.${sourceType}.${name}; helpers = import ../helpers.nix args;
in cfg = config.plugins.null-ls.sources.${sourceType}.${name};
{ in
options.programs.nixvim.plugins.null-ls.sources.${sourceType}.${name} = { {
enable = mkEnableOption description; options.plugins.null-ls.sources.${sourceType}.${name} = {
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
withArgs = mkOption { withArgs = mkOption {
default = null; default = null;
type = with types; nullOr str; type = with types; nullOr str;
description = ''Raw Lua code to be called with the with function''; description = ''Raw Lua code to be called with the with function'';
# Not sure that it makes sense to have the same example for all servers # Not sure that it makes sense to have the same example for all servers
# example = '' # example = ''
# '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\' # '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\'
# ''; # '';
};
};
config = mkIf cfg.enable {
programs.nixvim = {
extraPackages = packages;
# Add source to list of sources
plugins.null-ls.sourcesItems = let
sourceItem = "${sourceType}.${name}";
withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}'';
in [ (helpers.mkRaw finalString) ];
};
}; };
}; };
config = mkIf cfg.enable {
extraPackages = packages;
# Add source to list of sources
plugins.null-ls.sourcesItems =
let
sourceItem = "${sourceType}.${name}";
withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}'';
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,25 +10,28 @@ 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 [
options = { str
name = mkOption { (submodule {
type = str; options = {
description = "The server's name"; name = mkOption {
}; type = str;
description = "The server's name";
};
extraOptions = mkOption { extraOptions = mkOption {
type = attrs; type = attrs;
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 = [ ];
}; };
onAttach = mkOption { onAttach = mkOption {
@ -40,7 +43,7 @@ in
setupWrappers = mkOption { setupWrappers = mkOption {
type = with types; listOf (functionTo str); type = with types; listOf (functionTo str);
description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code."; description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code.";
default = []; default = [ ];
}; };
preConfig = mkOption { preConfig = mkOption {
@ -51,12 +54,13 @@ in
}; };
}; };
config = let config =
runWrappers = wrappers: s: let
if wrappers == [] then s runWrappers = wrappers: s:
else (head wrappers) (runWrappers (tail wrappers) s); if wrappers == [ ] then s
in mkIf cfg.enable { else (head wrappers) (runWrappers (tail wrappers) s);
programs.nixvim = { in
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 }:
{ pkgs, config, lib, ... }: # returns a module
with lib; { pkgs, config, lib, ... }:
let with lib;
cfg = config.programs.nixvim.plugins.lsp.servers.${name}; let
in cfg = config.plugins.lsp.servers.${name};
{ in
options = { {
programs.nixvim.plugins.lsp.servers.${name} = { options = {
enable = mkEnableOption description; plugins.lsp.servers.${name} = {
}; enable = mkEnableOption description;
};
config = mkIf cfg.enable {
programs.nixvim.extraPackages = packages;
programs.nixvim.plugins.lsp.enabledServers = [ serverName ];
}; };
}; };
config = mkIf cfg.enable {
extraPackages = packages;
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,74 +1,82 @@
{ 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 [
mkOpt = type: desc: mkOption { types.str
type = nullOr type; (with types; let
default = null; mkOpt = type: desc: mkOption {
description = desc; type = nullOr type;
}; default = null;
function = attrsOf str; description = desc;
in types.submodule {
options = {
name = mkOption {
type = str;
description = "Name of the plugin to install";
}; };
function = attrsOf str;
in
types.submodule {
options = {
name = mkOption {
type = str;
description = "Name of the plugin to install";
};
disable = mkOpt bool "Mark plugin as inactive"; disable = mkOpt bool "Mark plugin as inactive";
as = mkOpt bool "Specifies an alias under which to install the plugin"; as = mkOpt bool "Specifies an alias under which to install the plugin";
installer = mkOpt function "A custom installer"; installer = mkOpt function "A custom installer";
updater = mkOpt function "A custom updater"; updater = mkOpt function "A custom updater";
after = mkOpt (oneOf [str (listOf any)]) "Plugins to load after this plugin"; after = mkOpt (oneOf [ str (listOf any) ]) "Plugins to load after this plugin";
rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath"; rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath";
opt = mkOpt str "Marks a plugin as optional"; opt = mkOpt str "Marks a plugin as optional";
branch = mkOpt str "Git branch to use"; branch = mkOpt str "Git branch to use";
tag = mkOpt str "Git tag to use"; tag = mkOpt str "Git tag to use";
commit = mkOpt str "Git commit to use"; commit = mkOpt str "Git commit to use";
lock = mkOpt bool "Skip this plugin in updates"; lock = mkOpt bool "Skip this plugin in updates";
run = mkOpt (oneOf [str function]) "Post-install hook"; run = mkOpt (oneOf [ str function ]) "Post-install hook";
requires = mkOpt (oneOf [str (listOf any)]) "Plugin dependencies"; requires = mkOpt (oneOf [ str (listOf any) ]) "Plugin dependencies";
rocks = mkOpt (oneOf [str (listOf any)]) "Luarocks dependencies"; rocks = mkOpt (oneOf [ str (listOf any) ]) "Luarocks dependencies";
config = mkOpt (oneOf [str function]) "Code to run after this plugin is loaded"; config = mkOpt (oneOf [ str function ]) "Code to run after this plugin is loaded";
setup = mkOpt (oneOf [str function]) "Code to be run before this plugin is loaded"; setup = mkOpt (oneOf [ str function ]) "Code to be run before this plugin is loaded";
cmd = mkOpt (oneOf [str (listOf str)]) "Commands which load this plugin"; cmd = mkOpt (oneOf [ str (listOf str) ]) "Commands which load this plugin";
ft = mkOpt (oneOf [str (listOf str)]) "Filetypes which load this plugin"; ft = mkOpt (oneOf [ str (listOf str) ]) "Filetypes which load this plugin";
keys = mkOpt (oneOf [str (listOf str)]) "Keymaps which load this plugin"; keys = mkOpt (oneOf [ str (listOf str) ]) "Keymaps which load this plugin";
event = mkOpt (oneOf [str (listOf str)]) "Autocommand events which load this plugin"; event = mkOpt (oneOf [ str (listOf str) ]) "Autocommand events which load this plugin";
fn = mkOpt (oneOf [str (listOf str)]) "Functions which load this plugin"; fn = mkOpt (oneOf [ str (listOf str) ]) "Functions which load this plugin";
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";
}; };
}; };
}; };
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
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin plugins = map
else plugin) cfg.plugins; (plugin:
if isAttrs plugin then
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin
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,18 +1,19 @@
{ 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) ]);
sectionOption = mkOption { sectionOption = mkOption {
default = null; default = null;
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 =
sections = {}; let
in mkIf cfg.enable { sections = { };
programs.nixvim = { in
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,21 +49,23 @@ in {
active = mkOption { active = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule { type = types.nullOr (types.submodule {
options = let options =
listType = with types; nullOr (listOf (listOf str)); let
in { listType = with types; nullOr (listOf (listOf str));
left = mkOption { in
type = listType; {
description = "List of components that will show up on the left side of the bar"; left = mkOption {
default = null; type = listType;
}; description = "List of components that will show up on the left side of the bar";
default = null;
};
right = mkOption { right = mkOption {
type = listType; type = listType;
description = "List of components that will show up on the right side of the bar"; description = "List of components that will show up on the right side of the bar";
default = null; default = null;
};
}; };
};
}); });
}; };
@ -74,14 +77,14 @@ in {
}; };
}; };
config = let config =
configAttrs = filterAttrs (_: v: v != null) { let
inherit (cfg) colorscheme active component componentFunction modeMap; configAttrs = filterAttrs (_: v: v != null) {
}; inherit (cfg) colorscheme active component componentFunction modeMap;
in mkIf cfg.enable { };
programs.nixvim = { in
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,25 +110,25 @@ in {
}; };
}; };
}; };
config = let config =
setupOptions = { let
options = { setupOptions = {
theme = cfg.theme; options = {
section_separators = cfg.sectionSeparators; theme = cfg.theme;
component_separators = cfg.componentSeparators; section_separators = cfg.sectionSeparators;
disabled_filetypes = cfg.disabledFiletypes; component_separators = cfg.componentSeparators;
always_divide_middle = cfg.alwaysDivideMiddle; disabled_filetypes = cfg.disabledFiletypes;
}; always_divide_middle = cfg.alwaysDivideMiddle;
};
sections = cfg.sections; sections = cfg.sections;
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,32 +37,30 @@ 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; [
telescope-nvim telescope-nvim
plenary-nvim plenary-nvim
popup-nvim popup-nvim
]; ];
extraConfigVim = mkIf (cfg.highlightTheme != null) '' extraConfigVim = mkIf (cfg.highlightTheme != null) ''
let $BAT_THEME = '${cfg.highlightTheme}' let $BAT_THEME = '${cfg.highlightTheme}'
''; '';
extraConfigLua = '' extraConfigLua = ''
do do
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
require('telescope').setup{ require('telescope').setup{
extensions = ${helpers.toLuaObject cfg.extensionConfig} extensions = ${helpers.toLuaObject cfg.extensionConfig}
} }
for i, extension in ipairs(__telescopeExtensions) do for i, extension in ipairs(__telescopeExtensions) do
require('telescope').load_extension(extension) require('telescope').load_extension(extension)
end
end 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,19 +20,16 @@ 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; [
popup-nvim popup-nvim
plenary-nvim plenary-nvim
telescope-media-files-nvim telescope-media-files-nvim
]; ];
extraPackages = with pkgs; [
ueberzug
];
};
extraPackages = with pkgs; [
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;
@ -24,7 +24,7 @@ in
default = null; default = null;
}; };
toggler = mkOption { toggler = mkOption {
type = types.nullOr (types.submodule ({...}: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
line = mkOption { line = mkOption {
type = types.str; type = types.str;
@ -42,7 +42,7 @@ in
default = null; default = null;
}; };
opleader = mkOption { opleader = mkOption {
type = types.nullOr (types.submodule ({...}: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
line = mkOption { line = mkOption {
type = types.str; type = types.str;
@ -60,7 +60,7 @@ in
default = null; default = null;
}; };
mappings = mkOption { mappings = mkOption {
type = types.nullOr (types.submodule ({...}: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
basic = mkOption { basic = mkOption {
type = types.bool; type = types.bool;
@ -85,20 +85,20 @@ in
}; };
}; };
config = let config =
setupOptions = { let
padding = cfg.padding; setupOptions = {
sticky = cfg.sticky; padding = cfg.padding;
ignore = cfg.ignore; sticky = cfg.sticky;
toggler = cfg.toggler; ignore = cfg.ignore;
opleader = cfg.opleader; toggler = cfg.toggler;
mappings = cfg.mappings; opleader = cfg.opleader;
}; mappings = cfg.mappings;
in mkIf cfg.enable { };
programs.nixvim = { in
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,23 +64,21 @@ in
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = { extraPlugins = with pkgs.vimPlugins; [
extraPlugins = with pkgs.vimPlugins; [ vim-floaterm
vim-floaterm ];
]; globals = {
globals = { floaterm_shell = mkIf (!isNull cfg.shell) cfg.shell;
floaterm_shell = mkIf (!isNull cfg.shell) cfg.shell; floaterm_title = mkIf (!isNull cfg.title) cfg.title;
floaterm_title = mkIf (!isNull cfg.title) cfg.title; floaterm_wintype = mkIf (!isNull cfg.winType) cfg.winType;
floaterm_wintype = mkIf (!isNull cfg.winType) cfg.winType; floaterm_width = mkIf (!isNull cfg.winWidth) cfg.winWidth;
floaterm_width = mkIf (!isNull cfg.winWidth) cfg.winWidth; floaterm_height = mkIf (!isNull cfg.winHeight) cfg.winHeight;
floaterm_height = mkIf (!isNull cfg.winHeight) cfg.winHeight; floaterm_borderchars = mkIf (!isNull cfg.borderChars) cfg.borderChars;
floaterm_borderchars = mkIf (!isNull cfg.borderChars) cfg.borderChars; floaterm_rootmarkers = mkIf (!isNull cfg.rootMarkers) cfg.rootMarkers;
floaterm_rootmarkers = mkIf (!isNull cfg.rootMarkers) cfg.rootMarkers; floaterm_opener = mkIf (!isNull cfg.opener) cfg.opener;
floaterm_opener = mkIf (!isNull cfg.opener) cfg.opener; floaterm_autoclose = mkIf (!isNull cfg.autoClose) cfg.autoClose;
floaterm_autoclose = mkIf (!isNull cfg.autoClose) cfg.autoClose; floaterm_autohide = mkIf (!isNull cfg.autoHide) cfg.autoHide;
floaterm_autohide = mkIf (!isNull cfg.autoHide) cfg.autoHide; floaterm_autoInsert = mkIf (!isNull cfg.autoInsert) cfg.autoInsert;
floaterm_autoInsert = mkIf (!isNull cfg.autoInsert) cfg.autoInsert;
};
}; };
}; };
} }

View file

@ -1,24 +1,22 @@
{ 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>";
plugins.treesitter = { plugins.treesitter = {
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 =
opts = helpers.toLuaObject { let
inherit (cfg) highlight_group background_highlight_group; opts = helpers.toLuaObject {
set_default_mappings = cfg.set_default_keybinds; inherit (cfg) highlight_group background_highlight_group;
background_highlight = cfg.highlight_background; set_default_mappings = cfg.set_default_keybinds;
}; background_highlight = cfg.highlight_background;
in mkIf cfg.enable { };
programs.nixvim = { in
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,15 +1,15 @@
{ 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;
default = null; default = null;
}; };
in in
{ {
options.programs.nixvim.plugins.notify = { options.plugins.notify = {
enable = mkEnableOption "Enable notify"; enable = mkEnableOption "Enable notify";
stages = mkOption { stages = mkOption {
@ -43,31 +43,31 @@ in
}; };
}); });
description = "Icons for the different levels"; description = "Icons for the different levels";
default = {}; default = { };
}; };
}; };
config = let config =
setupOptions = with cfg; { let
stages = stages; setupOptions = with cfg; {
timeout = timeout; stages = stages;
background_color = backgroundColor; timeout = timeout;
minimum_width = minimumWidth; background_color = backgroundColor;
icons = with icons; { minimum_width = minimumWidth;
ERROR = error; icons = with icons; {
WARN = warn; ERROR = error;
INFO = info; WARN = warn;
DEBUG = debug; INFO = info;
TRACE = trace; DEBUG = debug;
TRACE = trace;
};
}; };
}; in
in mkIf cfg.enable { mkIf cfg.enable {
programs.nixvim = {
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,21 +39,21 @@ in
}; };
}; };
config = let config =
options = { let
pairs_map = cfg.pairs; options = {
disable_filetype = cfg.disabledFiletypes; pairs_map = cfg.pairs;
break_line_filetype = cfg.breakLineFiletypes; disable_filetype = cfg.disabledFiletypes;
html_break_line_filetype = cfg.htmlFiletypes; break_line_filetype = cfg.breakLineFiletypes;
ignored_next_char = cfg.ignoredNextChar; html_break_line_filetype = cfg.htmlFiletypes;
}; ignored_next_char = cfg.ignoredNextChar;
in mkIf cfg.enable { };
programs.nixvim = { in
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 {
@ -14,7 +14,7 @@ in
description = "Disable netrw"; description = "Disable netrw";
}; };
hijackNetrw = mkOption { hijackNetrw = mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
description = "Hijack netrw"; description = "Hijack netrw";
@ -72,18 +72,20 @@ in
description = "Enable diagnostics"; description = "Enable diagnostics";
}; };
icons = let icons =
diagnosticOption = desc: mkOption { let
type = types.nullOr types.str; diagnosticOption = desc: mkOption {
default = null; type = types.nullOr types.str;
description = desc; default = null;
description = desc;
};
in
{
hint = diagnosticOption "Hints";
info = diagnosticOption "Info";
warning = diagnosticOption "Warning";
error = diagnosticOption "Error";
}; };
in {
hint = diagnosticOption "Hints";
info = diagnosticOption "Info";
warning = diagnosticOption "Warning";
error = diagnosticOption "Error";
};
}; };
updateFocusedFile = { updateFocusedFile = {
@ -201,57 +203,58 @@ in
}; };
}; };
config = let config =
options = { let
disable_netrw = cfg.disableNetrw; options = {
hijack_netrw = cfg.hijackNetrw; disable_netrw = cfg.disableNetrw;
open_on_setup = cfg.openOnSetup; hijack_netrw = cfg.hijackNetrw;
ignore_ft_on_setup = cfg.ignoreFtOnSetup; open_on_setup = cfg.openOnSetup;
auto_close = cfg.autoClose; ignore_ft_on_setup = cfg.ignoreFtOnSetup;
open_on_tab = cfg.openOnTab; auto_close = cfg.autoClose;
hijack_cursor = cfg.hijackCursor; open_on_tab = cfg.openOnTab;
update_cwd = cfg.updateCwd; hijack_cursor = cfg.hijackCursor;
update_to_buf_dir = { update_cwd = cfg.updateCwd;
enable = cfg.updateToBufDir.enable; update_to_buf_dir = {
auto_open = cfg.updateToBufDir.autoOpen; enable = cfg.updateToBufDir.enable;
}; auto_open = cfg.updateToBufDir.autoOpen;
diagnostics = cfg.diagnostics; };
updateFocusedFile = { diagnostics = cfg.diagnostics;
enable = cfg.updateFocusedFile.enable; updateFocusedFile = {
update_cwd = cfg.updateFocusedFile.updateCwd; enable = cfg.updateFocusedFile.enable;
ignore_list = cfg.updateFocusedFile.ignoreList; update_cwd = cfg.updateFocusedFile.updateCwd;
}; ignore_list = cfg.updateFocusedFile.ignoreList;
system_open = cfg.systemOpen; };
filters = cfg.filters; system_open = cfg.systemOpen;
git = cfg.git; filters = cfg.filters;
view = { git = cfg.git;
width = cfg.view.width; view = {
height = cfg.view.height; width = cfg.view.width;
hide_root_folder = cfg.view.hideRootFolder; height = cfg.view.height;
side = cfg.view.side; hide_root_folder = cfg.view.hideRootFolder;
auto_resize = cfg.view.autoResize; side = cfg.view.side;
mappings = { auto_resize = cfg.view.autoResize;
custom_only = cfg.view.mappings.customOnly; mappings = {
list = cfg.view.mappings.list; custom_only = cfg.view.mappings.customOnly;
list = cfg.view.mappings.list;
};
number = cfg.view.number;
relativenumber = cfg.view.relativenumber;
signcolumn = cfg.view.signcolumn;
};
trash = {
cmd = cfg.trash.cmd;
require_confirm = cfg.trash.requireConfirm;
}; };
number = cfg.view.number;
relativenumber = cfg.view.relativenumber;
signcolumn = cfg.view.signcolumn;
}; };
trash = { in
cmd = cfg.trash.cmd; mkIf cfg.enable {
require_confirm = cfg.trash.requireConfirm;
};
};
in mkIf cfg.enable {
programs.nixvim = {
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,36 +105,36 @@ in {
}; };
}; };
config = let config =
setup = helpers.toLuaObject { let
inherit (cfg) show_jumps min_jump; setup = helpers.toLuaObject {
ignore_filetypes = attrsets.listToAttrs inherit (cfg) show_jumps min_jump;
(lib.lists.map (x: attrsets.nameValuePair x true) ignore_filetypes = attrsets.listToAttrs
cfg.ignored_filetypes); (lib.lists.map (x: attrsets.nameValuePair x true)
ignore_buftypes = attrsets.listToAttrs cfg.ignored_filetypes);
(lib.lists.map (x: attrsets.nameValuePair x true) ignore_buftypes = attrsets.listToAttrs
cfg.ignored_buffertypes); (lib.lists.map (x: attrsets.nameValuePair x true)
popup = { cfg.ignored_buffertypes);
inherit (cfg) blend width; popup = {
delay_ms = cfg.delay; inherit (cfg) blend width;
inc_ms = cfg.increment; delay_ms = cfg.delay;
fader = helpers.mkRaw (if cfg.fader.builtin == null then inc_ms = cfg.increment;
cfg.fader.custom fader = helpers.mkRaw (if cfg.fader.builtin == null then
else cfg.fader.custom
''require("specs").${cfg.fader.builtin}''); else
resizer = helpers.mkRaw (if cfg.resizer.builtin == null then ''require("specs").${cfg.fader.builtin}'');
cfg.resizer.custom resizer = helpers.mkRaw (if cfg.resizer.builtin == null then
else cfg.resizer.custom
''require("specs").${cfg.resizer.builtin}''); else
''require("specs").${cfg.resizer.builtin}'');
};
}; };
}; in
in mkIf cfg.enable { mkIf cfg.enable {
programs.nixvim = {
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,27 +108,25 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nixvim = { extraPlugins = [ pkgs.vimPlugins.undotree ];
extraPlugins = [ pkgs.vimPlugins.undotree ];
globals = { globals = {
undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout; undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout;
undotree_ShortIndicators = mkIf cfg.shortIndicators 1; undotree_ShortIndicators = mkIf cfg.shortIndicators 1;
undotree_SplitWidth = mkIf (cfg.windowWidth != null) cfg.windowWidth; undotree_SplitWidth = mkIf (cfg.windowWidth != null) cfg.windowWidth;
undotree_DiffpanelHeight = mkIf (cfg.diffHeight != null) cfg.diffHeight; undotree_DiffpanelHeight = mkIf (cfg.diffHeight != null) cfg.diffHeight;
undotree_DiffAutoOpen = mkIf (!cfg.autoOpenDiff) 0; undotree_DiffAutoOpen = mkIf (!cfg.autoOpenDiff) 0;
undotree_SetFocusWhenToggle = mkIf cfg.focusOnToggle 1; undotree_SetFocusWhenToggle = mkIf cfg.focusOnToggle 1;
undotree_TreeNodeShape = mkIf (cfg.treeNodeShape != null) cfg.treeNodeShape; undotree_TreeNodeShape = mkIf (cfg.treeNodeShape != null) cfg.treeNodeShape;
undotree_DiffCommand = mkIf (cfg.diffCommand != null) cfg.diffCommand; undotree_DiffCommand = mkIf (cfg.diffCommand != null) cfg.diffCommand;
undotree_RelativeTimestamp = mkIf (!cfg.relativeTimestamp) 0; undotree_RelativeTimestamp = mkIf (!cfg.relativeTimestamp) 0;
undotree_HighlightChangedText = mkIf (!cfg.highlightChangedText) 0; undotree_HighlightChangedText = mkIf (!cfg.highlightChangedText) 0;
undotree_HighlightChangedWithSign = mkIf (!cfg.highlightChangesWithSign) 0; undotree_HighlightChangedWithSign = mkIf (!cfg.highlightChangesWithSign) 0;
undotree_HighlightSyntaxAdd = mkIf (cfg.highlightSyntaxAdd != null) cfg.highlightSyntaxAdd; undotree_HighlightSyntaxAdd = mkIf (cfg.highlightSyntaxAdd != null) cfg.highlightSyntaxAdd;
undotree_HighlightSyntaxChange = mkIf (cfg.highlightSyntaxChange != null) cfg.highlightSyntaxAdd; undotree_HighlightSyntaxChange = mkIf (cfg.highlightSyntaxChange != null) cfg.highlightSyntaxAdd;
undotree_HighlightSyntaxDel = mkIf (cfg.highlightSyntaxDel != null) cfg.highlightSyntaxDel; undotree_HighlightSyntaxDel = mkIf (cfg.highlightSyntaxDel != null) cfg.highlightSyntaxDel;
undotree_HelpLine = mkIf (!cfg.showHelpLine) 0; undotree_HelpLine = mkIf (!cfg.showHelpLine) 0;
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;
};
})
];
};
};
}