mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
Add gitgutter
This commit is contained in:
parent
1b4f79b137
commit
a0fe9e6ca4
3 changed files with 149 additions and 16 deletions
|
@ -43,6 +43,8 @@
|
|||
enable = true;
|
||||
powerline = true;
|
||||
};
|
||||
|
||||
plugins.gitgutter.enable = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
|
|
13
nixvim.nix
13
nixvim.nix
|
@ -107,6 +107,13 @@ in
|
|||
description = "Extra contents for init.vim";
|
||||
};
|
||||
|
||||
extraPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
example = "[ pkgs.shfmt ]";
|
||||
description = "Extra packages to be made available to neovim";
|
||||
};
|
||||
|
||||
configure = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
|
@ -176,8 +183,12 @@ in
|
|||
withRuby = false;
|
||||
};
|
||||
|
||||
extraWrapperArgs = optionalString (cfg.extraPackages != [])
|
||||
''--prefix PATH : "${makeBinPath cfg.extraPackages}"'';
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs;
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " "
|
||||
+ extraWrapperArgs;
|
||||
});
|
||||
|
||||
mappings =
|
||||
|
|
|
@ -49,10 +49,119 @@ in {
|
|||
default = false;
|
||||
description = "Make the background colors match the sign column";
|
||||
};
|
||||
|
||||
signs = mkOption {
|
||||
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";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = "Custom signs for the sign column";
|
||||
};
|
||||
|
||||
diffRelativeToWorkingTree = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Make diffs relative to the working tree instead of the index";
|
||||
};
|
||||
|
||||
extraGitArgs = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = "Extra arguments to pass to git";
|
||||
};
|
||||
|
||||
extraDiffArgs = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = "Extra arguments to pass to git diff";
|
||||
};
|
||||
|
||||
grep = mkOption {
|
||||
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";
|
||||
};
|
||||
};
|
||||
} types.str]);
|
||||
default = null;
|
||||
description = "A non-standard grep to use instead of the default";
|
||||
};
|
||||
|
||||
enableByDefault = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enable gitgutter by default";
|
||||
};
|
||||
|
||||
signsByDefault = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Show signs by default";
|
||||
};
|
||||
|
||||
highlightLines = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Highlight lines by default";
|
||||
};
|
||||
|
||||
highlightLineNumbers = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Highlight line numbers by default";
|
||||
};
|
||||
|
||||
runAsync = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Disable this to run git diff syncrhonously instead of asynchronously";
|
||||
};
|
||||
|
||||
previewWinFloating = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Preview hunks on floating windows";
|
||||
};
|
||||
|
||||
useLocationList = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Load chunks into windows's location list instead of the quickfix list";
|
||||
};
|
||||
|
||||
terminalReportFocus = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Let the terminal report its focus status";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
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 = {
|
||||
extraPlugins = [ pkgs.vimPlugins.gitgutter ];
|
||||
|
||||
|
@ -61,6 +170,8 @@ in {
|
|||
foldtext = "gitgutter#fold#foldtext";
|
||||
};
|
||||
|
||||
extraPackages = [ pkgs.git ] ++ grepPackage;
|
||||
|
||||
globals = {
|
||||
gitgutter_max_signs = mkIf (!isNull cfg.maxSigns) cfg.maxSigns;
|
||||
gitgutter_show_msg_on_hunk_jumping = mkIf (!cfg.showMessageOnHunkJumping) 0;
|
||||
|
@ -69,20 +180,29 @@ in {
|
|||
gitgutter_sign_priority = mkIf (!isNull cfg.signPriority) cfg.signPriority;
|
||||
gitgutter_set_sign_backgrounds = mkIf (cfg.matchBackgrounds) 1;
|
||||
|
||||
# TODO these config options:
|
||||
# gitgutter_sign_*
|
||||
# gitgutter_diff_relative_to
|
||||
# gitgutter_diff_base
|
||||
# gitgutter_git_args
|
||||
# gitgutter_diff_args
|
||||
# gitgutter_grep
|
||||
# gitgutter_enabled
|
||||
# gitgutter_signs
|
||||
# gitgutter_highlight_lines
|
||||
# gitgutter_highlight_linenrs
|
||||
# gitgutter_async
|
||||
# gitgutter_preview_win_floating
|
||||
# gitgutter_use_location_list
|
||||
gitgutter_sign_added = mkIf (!isNull cfg.signs.added) cfg.signs.added;
|
||||
gitgutter_sign_modified = mkIf (!isNull cfg.signs.modified) cfg.signs.modified;
|
||||
gitgutter_sign_removed = mkIf (!isNull cfg.signs.removed) cfg.signs.removed;
|
||||
gitgutter_sign_removed_first_line = mkIf (!isNull cfg.signs.removedFirstLine) cfg.signs.removedFirstLine;
|
||||
gitgutter_sign_removed_above_and_bellow = mkIf (!isNull cfg.signs.removedAboveAndBelow) cfg.signs.removedAboveAndBelow;
|
||||
gitgutter_sign_modified_above = mkIf (!isNull cfg.signs.modifiedAbove) cfg.signs.modifiedAbove;
|
||||
|
||||
gitgutter_diff_relative_to = mkIf (cfg.diffRelativeToWorkingTree) "working_tree";
|
||||
gitgutter_git_args = mkIf (cfg.extraGitArgs != "") cfg.extraGitArgs;
|
||||
gitgutter_diff_args = mkIf (cfg.extraDiffArgs != "") cfg.extraDiffArgs;
|
||||
|
||||
gitgutter_grep = mkIf (!isNull grepCommand) grepCommand;
|
||||
|
||||
gitgutter_enabled = mkIf (!cfg.enableByDefault) 0;
|
||||
gitgutter_signs = mkIf (!cfg.signsByDefault) 0;
|
||||
|
||||
gitgutter_highlight_lines = mkIf (!cfg.highlightLines) 0;
|
||||
gitgutter_highlight_linenrs = mkIf (!cfg.highlightLineNumbers) 0;
|
||||
gitgutter_async = mkIf (!cfg.runAsync) 0;
|
||||
gitgutter_preview_win_floating = mkIf (cfg.previewWinFloating) 1;
|
||||
gitgutter_use_location_list = mkIf (cfg.useLocationList) 1;
|
||||
|
||||
gitgutter_terminal_report_focus = mkIf (!cfg.terminalReportFocus) 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue