2023-04-20 22:41:37 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-04-13 08:40:47 +01:00
|
|
|
helpers,
|
2023-04-20 22:41:37 +02:00
|
|
|
...
|
|
|
|
}:
|
2024-02-09 21:20:07 +01:00
|
|
|
with lib;
|
|
|
|
{
|
2023-04-20 22:41:37 +02:00
|
|
|
options = {
|
|
|
|
viAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2023-09-18 21:38:58 +07:00
|
|
|
Symlink `vi` to `nvim` binary.
|
2023-04-20 22:41:37 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vimAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2023-09-18 21:38:58 +07:00
|
|
|
Symlink `vim` to `nvim` binary.
|
2023-04-20 22:41:37 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-07 09:45:32 +02:00
|
|
|
withRuby = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enable Ruby provider.";
|
|
|
|
};
|
|
|
|
|
2024-03-04 05:59:53 +08:00
|
|
|
withNodeJs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable Node provider.";
|
|
|
|
};
|
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.neovim-unwrapped;
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "Neovim to use for NixVim.";
|
2023-04-20 22:41:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
wrapRc = mkOption {
|
|
|
|
type = types.bool;
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "Should the config be included in the wrapper script.";
|
2023-04-20 22:41:37 +02:00
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "Wrapped Neovim.";
|
2023-04-20 22:41:37 +02:00
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
|
2023-12-07 13:40:40 +01:00
|
|
|
initPath = mkOption {
|
|
|
|
type = types.str;
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "The path to the `init.lua` file.";
|
2023-12-07 13:40:40 +01:00
|
|
|
readOnly = true;
|
|
|
|
visible = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
printInitPackage = mkOption {
|
|
|
|
type = types.package;
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "A tool to show the content of the generated `init.lua` file.";
|
2023-12-07 13:40:40 +01:00
|
|
|
readOnly = true;
|
|
|
|
visible = false;
|
|
|
|
};
|
2023-04-20 22:41:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
defaultPlugin = {
|
|
|
|
plugin = null;
|
|
|
|
config = "";
|
|
|
|
optional = false;
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
normalizedPlugins = map (
|
|
|
|
x: defaultPlugin // (if x ? plugin then x else { plugin = x; })
|
|
|
|
) config.extraPlugins;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
neovimConfig = pkgs.neovimUtils.makeNeovimConfig (
|
|
|
|
{
|
2024-01-06 19:17:32 +01:00
|
|
|
inherit (config)
|
2024-01-06 14:59:00 -05:00
|
|
|
extraPython3Packages
|
2024-01-06 19:17:32 +01:00
|
|
|
viAlias
|
|
|
|
vimAlias
|
2024-05-07 09:45:32 +02:00
|
|
|
withRuby
|
2024-03-04 05:59:53 +08:00
|
|
|
withNodeJs
|
2024-01-06 19:17:32 +01:00
|
|
|
;
|
2023-04-20 22:41:37 +02:00
|
|
|
# inherit customRC;
|
|
|
|
plugins = normalizedPlugins;
|
|
|
|
}
|
|
|
|
# Necessary to make sure the runtime path is set properly in NixOS 22.05,
|
|
|
|
# or more generally before the commit:
|
|
|
|
# cda1f8ae468 - neovim: pass packpath via the wrapper
|
|
|
|
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
|
|
|
|
configure.packages = {
|
|
|
|
nixvim = {
|
|
|
|
start = map (x: x.plugin) normalizedPlugins;
|
|
|
|
opt = [ ];
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-04-20 22:41:37 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
customRC =
|
2024-05-25 23:46:59 +01:00
|
|
|
let
|
|
|
|
hasContent = str: (builtins.match "[[:space:]]*" str) == null;
|
|
|
|
in
|
|
|
|
(optionalString (hasContent neovimConfig.neovimRcContent) ''
|
2023-04-20 22:41:37 +02:00
|
|
|
vim.cmd([[
|
|
|
|
${neovimConfig.neovimRcContent}
|
|
|
|
]])
|
2024-05-25 23:46:59 +01:00
|
|
|
'')
|
2023-04-20 22:41:37 +02:00
|
|
|
+ config.content;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-04-13 08:40:47 +01:00
|
|
|
init = helpers.writeLua "init.lua" customRC;
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
extraWrapperArgs = builtins.concatStringsSep " " (
|
|
|
|
(optional (config.extraPackages != [ ]) ''--prefix PATH : "${makeBinPath config.extraPackages}"'')
|
2023-12-07 13:40:40 +01:00
|
|
|
++ (optional config.wrapRc ''--add-flags -u --add-flags "${init}"'')
|
2023-04-20 22:41:37 +02:00
|
|
|
);
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (
|
|
|
|
neovimConfig
|
|
|
|
// {
|
|
|
|
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
|
|
|
|
wrapRc = false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
in
|
|
|
|
{
|
|
|
|
type = lib.mkForce "lua";
|
|
|
|
finalPackage = wrappedNeovim;
|
2024-05-25 21:56:39 +01:00
|
|
|
initPath = "${init}";
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2023-12-07 13:40:40 +01:00
|
|
|
printInitPackage = pkgs.writeShellApplication {
|
|
|
|
name = "nixvim-print-init";
|
2024-05-25 21:56:39 +01:00
|
|
|
runtimeInputs = [ pkgs.bat ];
|
2023-12-07 13:40:40 +01:00
|
|
|
text = ''
|
2024-05-25 21:56:39 +01:00
|
|
|
bat --language=lua "${init}"
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 10:50:24 +01:00
|
|
|
extraConfigLuaPre = lib.optionalString config.wrapRc ''
|
|
|
|
-- Ignore the user lua configuration
|
2024-01-03 22:24:59 +01:00
|
|
|
vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim
|
|
|
|
vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after
|
|
|
|
vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- ~/.local/share/nvim/site
|
2023-12-07 13:40:40 +01:00
|
|
|
'';
|
|
|
|
|
2024-01-02 10:50:24 +01:00
|
|
|
extraPlugins = if config.wrapRc then [ config.filesPlugin ] else [ ];
|
2023-04-20 22:41:37 +02:00
|
|
|
};
|
|
|
|
}
|