mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/gitmessenger: migrate to mkVimPlugin
This commit is contained in:
parent
ad87ec831b
commit
9062a66ee9
3 changed files with 154 additions and 89 deletions
|
@ -71,7 +71,6 @@ KNOWN_PATHS: dict[
|
||||||
"plugins/by-name/chadtree/default.nix": (State.OLD, Kind.NEOVIM, False),
|
"plugins/by-name/chadtree/default.nix": (State.OLD, Kind.NEOVIM, False),
|
||||||
"plugins/by-name/coq-thirdparty/default.nix": (State.OLD, Kind.NEOVIM, False),
|
"plugins/by-name/coq-thirdparty/default.nix": (State.OLD, Kind.NEOVIM, False),
|
||||||
"plugins/by-name/dap/default.nix": (State.OLD, Kind.NEOVIM, False),
|
"plugins/by-name/dap/default.nix": (State.OLD, Kind.NEOVIM, False),
|
||||||
"plugins/by-name/gitmessenger/default.nix": (State.OLD, Kind.VIM, False),
|
|
||||||
"plugins/by-name/intellitab/default.nix": (
|
"plugins/by-name/intellitab/default.nix": (
|
||||||
State.OLD,
|
State.OLD,
|
||||||
Kind.VIM,
|
Kind.VIM,
|
||||||
|
|
|
@ -1,127 +1,158 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
let
|
||||||
{
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
meta.maintainers = [ maintainers.traxys ];
|
inherit (lib) types;
|
||||||
|
in
|
||||||
|
lib.nixvim.vim-plugin.mkVimPlugin {
|
||||||
|
name = "gitmessenger";
|
||||||
|
packPathName = "git-messenger.vim";
|
||||||
|
package = "git-messenger-vim";
|
||||||
|
globalPrefix = "git_messenger_";
|
||||||
|
|
||||||
options.plugins.gitmessenger = {
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
enable = mkEnableOption "gitmessenger";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "git-messenger" {
|
extraOptions = {
|
||||||
default = [
|
gitPackage = lib.mkPackageOption pkgs "git" {
|
||||||
"vimPlugins"
|
nullable = true;
|
||||||
"git-messenger-vim"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
closeOnCursorMoved = helpers.defaultNullOpts.mkBool true ''
|
extraConfig = cfg: {
|
||||||
|
extraPackages = [ cfg.gitPackage ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: Added 2024-12-16; remove after 25.05
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"closeOnCursorMoved"
|
||||||
|
"includeDiff"
|
||||||
|
"gitCommand"
|
||||||
|
"noDefaultMappings"
|
||||||
|
"intoPopupAfterShow"
|
||||||
|
"alwaysIntoPopup"
|
||||||
|
"extraBlameArgs"
|
||||||
|
"previewMods"
|
||||||
|
"maxPopupHeight"
|
||||||
|
"maxPopupWidth"
|
||||||
|
"dateFormat"
|
||||||
|
"concealWordDiffMarker"
|
||||||
|
"floatingWinOps"
|
||||||
|
"popupContentMargins"
|
||||||
|
];
|
||||||
|
|
||||||
|
settingsOptions = {
|
||||||
|
close_on_cursor_moved = defaultNullOpts.mkBool true ''
|
||||||
A popup window is no longer closed automatically when moving a cursor after the window is
|
A popup window is no longer closed automatically when moving a cursor after the window is
|
||||||
shown up.
|
shown up.
|
||||||
'';
|
'';
|
||||||
includeDiff =
|
|
||||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
include_diff =
|
||||||
|
defaultNullOpts.mkEnumFirstDefault
|
||||||
[
|
[
|
||||||
"none"
|
"none"
|
||||||
"current"
|
"current"
|
||||||
"all"
|
"all"
|
||||||
]
|
]
|
||||||
''
|
''
|
||||||
When this value is not set to "none", a popup window includes diff hunks of the commit at
|
When this value is not set to `"none"`, a popup window includes diff hunks of the commit
|
||||||
showing up. "current" includes diff hunks of only current file in the commit. "all" includes
|
at showing up.
|
||||||
all diff hunks in the commit.
|
`"current"` includes diff hunks of only current file in the commit.
|
||||||
|
`"all"` includes all diff hunks in the commit.
|
||||||
|
|
||||||
Please note that typing d/D or r/R in popup window toggle showing diff hunks even if this
|
Please note that typing `d`/`D` or `r`/`R` in popup window toggle showing diff hunks even
|
||||||
value is set to "none".
|
if this value is set to `"none"`.
|
||||||
'';
|
'';
|
||||||
gitCommand = helpers.defaultNullOpts.mkStr "git" "git command to retrieve commit messages.";
|
|
||||||
noDefaultMappings = helpers.defaultNullOpts.mkBool false "When this value is set, it does not define any key mappings";
|
git_command = defaultNullOpts.mkStr "git" ''
|
||||||
intoPopupAfterShow = helpers.defaultNullOpts.mkBool true ''
|
`git` command to retrieve commit messages.
|
||||||
When this value is set to v:false, running :GitMessenger or <plug>(git-messenger) again after
|
|
||||||
showing a popup does not move the cursor in the window.
|
If your `git` executable is not in `$PATH` directories, please specify the path to the
|
||||||
|
executable.
|
||||||
'';
|
'';
|
||||||
alwaysIntoPopup = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
When this value is set to v:true, the cursor goes into a popup window when running
|
no_default_mappings = defaultNullOpts.mkBool false ''
|
||||||
:GitMessenger or <Plug>(git-messenger).
|
When this value is set, it does not define any key mappings.
|
||||||
'';
|
'';
|
||||||
extraBlameArgs = helpers.defaultNullOpts.mkStr "" ''
|
|
||||||
|
into_popup_after_show = defaultNullOpts.mkBool true ''
|
||||||
|
When this value is set to `false`, running `:GitMessenger` or `<plug>(git-messenger)` again
|
||||||
|
after showing a popup does not move the cursor in the window.
|
||||||
|
'';
|
||||||
|
|
||||||
|
always_into_popup = defaultNullOpts.mkBool false ''
|
||||||
|
When this value is set to `true`, the cursor goes into a popup window when running
|
||||||
|
`:GitMessenger` or `<Plug>(git-messenger)`.
|
||||||
|
'';
|
||||||
|
|
||||||
|
extra_blame_args = defaultNullOpts.mkStr "" ''
|
||||||
When this variable is set the contents will be appended to the git blame command. Use it to
|
When this variable is set the contents will be appended to the git blame command. Use it to
|
||||||
add options (like -w).
|
add options (like -w).
|
||||||
'';
|
'';
|
||||||
previewMods = helpers.defaultNullOpts.mkStr "" ''
|
|
||||||
|
preview_mods = defaultNullOpts.mkStr "" ''
|
||||||
This variable is effective only when opening preview window (on Neovim (0.3.0 or earlier)
|
This variable is effective only when opening preview window (on Neovim (0.3.0 or earlier)
|
||||||
or Vim).
|
or Vim).
|
||||||
|
|
||||||
Command modifiers for opening preview window. The value will be passed as prefix of :pedit
|
Command modifiers for opening preview window.
|
||||||
command. For example, setting "botright" to the variable opens a preview window at bottom of
|
The value will be passed as prefix of `:pedit` command.
|
||||||
the current window. Please see :help <mods> for more details.
|
|
||||||
|
For example, setting `"botright"` to the variable opens a preview window at bottom of the
|
||||||
|
current window.
|
||||||
|
Please see `:help <mods>` for more details.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
maxPopupHeight = mkOption {
|
max_popup_height = defaultNullOpts.mkUnsignedInt null ''
|
||||||
type = types.nullOr types.int;
|
Max lines of popup window in an integer value.
|
||||||
default = null;
|
Setting `null` means no limit.
|
||||||
|
'';
|
||||||
|
|
||||||
|
max_popup_width = defaultNullOpts.mkUnsignedInt null ''
|
||||||
|
Max characters of popup window in an integer value.
|
||||||
|
Setting `null` means no limit.
|
||||||
|
'';
|
||||||
|
|
||||||
|
date_format = defaultNullOpts.mkStr "%c" ''
|
||||||
|
String value to format dates in popup window.
|
||||||
|
|
||||||
|
Please see `:help strftime()` to know the details of the format.
|
||||||
|
'';
|
||||||
|
|
||||||
|
conceal_word_diff_marker = defaultNullOpts.mkBool true ''
|
||||||
|
When this value is set to `true`, markers for word diffs like `[-, -]`, `{+, +}` are
|
||||||
|
concealed.
|
||||||
|
Set `false` when you don't want to hide them.
|
||||||
|
|
||||||
|
Note: Word diff is enabled by typing `r` in a popup window.
|
||||||
|
'';
|
||||||
|
|
||||||
|
floating_win_opts = defaultNullOpts.mkAttrsOf' {
|
||||||
|
type = types.anything;
|
||||||
|
pluginDefault = { };
|
||||||
|
example = {
|
||||||
|
border = "single";
|
||||||
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Max lines of popup window in an integer value. Setting null means no limit.
|
Options passed to `nvim_open_win()` on opening a popup window.
|
||||||
|
|
||||||
|
This is useful when you want to override some window options.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
maxPopupWidth = mkOption {
|
popup_content_margins = defaultNullOpts.mkBool true ''
|
||||||
type = types.nullOr types.int;
|
Setting `true` means adding margins in popup window.
|
||||||
default = null;
|
Blank lines at the top and bottom of popup content are inserted.
|
||||||
description = ''
|
And every line is indented with one whitespace character.
|
||||||
Max characters of popup window in an integer value. Setting null means no limit.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
dateFormat = helpers.defaultNullOpts.mkStr "%c" ''
|
Setting `false` to this variable removes all the margins.
|
||||||
String value to format dates in popup window. Please see :help strftime() to know the details
|
|
||||||
of the format.
|
|
||||||
'';
|
|
||||||
|
|
||||||
concealWordDiffMarker = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
When this value is set to v:true, markers for word diffs like [-, -], {+, +} are concealed.
|
|
||||||
Set false when you don't want to hide them.
|
|
||||||
|
|
||||||
Note: Word diff is enabled by typing "r" in a popup window.
|
|
||||||
'';
|
|
||||||
|
|
||||||
floatingWinOps = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
|
|
||||||
Options passed to nvim_open_win() on opening a popup window. This is useful when you want to
|
|
||||||
override some window options.
|
|
||||||
'';
|
|
||||||
|
|
||||||
popupContentMargins = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Setting true means adding margins in popup window. Blank lines at the top and bottom of popup
|
|
||||||
content are inserted. And every line is indented with one whitespace character. Setting false
|
|
||||||
to this variable removes all the margins.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
settingsExample = {
|
||||||
let
|
extra_blame_args = "-w";
|
||||||
cfg = config.plugins.gitmessenger;
|
include_diff = "current";
|
||||||
in
|
floating_win_opts.border = "single";
|
||||||
mkIf cfg.enable {
|
};
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
globals = {
|
|
||||||
git_messenger_close_on_cursor_moved = cfg.closeOnCursorMoved;
|
|
||||||
git_messenger_include_diff = cfg.includeDiff;
|
|
||||||
git_messenger_git_command = cfg.gitCommand;
|
|
||||||
git_messenger_no_default_mappings = cfg.noDefaultMappings;
|
|
||||||
git_messenger_into_popup_after_show = cfg.intoPopupAfterShow;
|
|
||||||
git_messenger_always_into_popup = cfg.alwaysIntoPopup;
|
|
||||||
git_messenger_extra_blame_args = cfg.extraBlameArgs;
|
|
||||||
git_messenger_preview_mods = cfg.previewMods;
|
|
||||||
git_messenger_max_popup_height = cfg.maxPopupHeight;
|
|
||||||
git_messenger_max_popup_width = cfg.maxPopupWidth;
|
|
||||||
git_messenger_date_format = cfg.dateFormat;
|
|
||||||
git_messenger_conceal_word_diff_marker = cfg.concealWordDiffMarker;
|
|
||||||
git_messenger_floating_win_opts = cfg.floatingWinOps;
|
|
||||||
git_messenger_popup_content_margins = cfg.popupContentMargins;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,39 @@
|
||||||
empty = {
|
empty = {
|
||||||
plugins.gitmessenger.enable = true;
|
plugins.gitmessenger.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.gitmessenger = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
close_on_cursor_moved = true;
|
||||||
|
include_diff = "none";
|
||||||
|
git_command = "git";
|
||||||
|
no_default_mappings = false;
|
||||||
|
into_popup_after_show = true;
|
||||||
|
always_into_popup = false;
|
||||||
|
extra_blame_args = "";
|
||||||
|
preview_mods = "";
|
||||||
|
max_popup_height = null;
|
||||||
|
max_popup_width = null;
|
||||||
|
date_format = "%c";
|
||||||
|
conceal_word_diff_marker = true;
|
||||||
|
floating_win_opts = { };
|
||||||
|
popup_content_margins = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.gitmessenger = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
extra_blame_args = "-w";
|
||||||
|
include_diff = "current";
|
||||||
|
floating_win_opts.border = "single";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue