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

@ -1,11 +1,12 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.programs.nixvim.plugins.gitgutter;
cfg = config.plugins.gitgutter;
helpers = import ../helpers.nix { inherit lib; };
in {
in
{
options = {
programs.nixvim.plugins.gitgutter = {
plugins.gitgutter = {
enable = mkEnableOption "Enable gitgutter";
recommendedSettings = mkOption {
@ -51,24 +52,26 @@ in {
};
signs = mkOption {
type = let
signOption = desc: mkOption {
type = types.nullOr types.str;
default = null;
description = "Sign for ${desc}";
type =
let
signOption = desc: mkOption {
type = types.nullOr types.str;
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 {
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 = {};
default = { };
description = "Custom signs for the sign column";
};
@ -91,19 +94,22 @@ in {
};
grep = mkOption {
type = types.nullOr (types.oneOf [ (types.submodule {
options = {
command = mkOption {
type = types.str;
description = "The command to use as a grep alternative";
};
type = types.nullOr (types.oneOf [
(types.submodule {
options = {
command = mkOption {
type = types.str;
description = "The command to use as a grep alternative";
};
package = mkOption {
type = types.package;
description = "The package of the grep alternative to use";
package = mkOption {
type = types.package;
description = "The package of the grep alternative to use";
};
};
};
}) types.str]);
})
types.str
]);
default = null;
description = "A non-standard grep to use instead of the default";
};
@ -158,11 +164,12 @@ in {
};
};
config = let
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [];
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
in mkIf cfg.enable {
programs.nixvim = {
config =
let
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ];
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.gitgutter ];
options = mkIf cfg.recommendedSettings {
@ -205,5 +212,4 @@ in {
gitgutter_terminal_report_focus = mkIf (!cfg.terminalReportFocus) 0;
};
};
};
}

View file

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