mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/git-worktree: migrate to mkNeovimPlugin
This commit is contained in:
parent
4ae6136d12
commit
c7a600c3f3
3 changed files with 60 additions and 63 deletions
|
@ -5,64 +5,59 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.plugins.git-worktree;
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
in
|
in
|
||||||
{
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
options = {
|
name = "git-worktree";
|
||||||
plugins.git-worktree = {
|
packPathName = "git-worktree.nvim";
|
||||||
enable = lib.mkEnableOption "git-worktree";
|
package = "git-worktree-nvim";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "git-worktree" {
|
maintainers = [ lib.maintainers.khaneliman ];
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
|
||||||
"git-worktree-nvim"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
gitPackage = lib.mkPackageOption pkgs "git" {
|
settingsOptions = {
|
||||||
nullable = true;
|
change_directory_command = defaultNullOpts.mkStr "cd" ''
|
||||||
};
|
|
||||||
|
|
||||||
enableTelescope = lib.mkEnableOption "telescope integration";
|
|
||||||
|
|
||||||
changeDirectoryCommand = lib.nixvim.defaultNullOpts.mkStr "cd" ''
|
|
||||||
The vim command used to change to the new worktree directory.
|
The vim command used to change to the new worktree directory.
|
||||||
Set this to `tcd` if you want to only change the `pwd` for the current vim Tab.
|
Set this to `tcd` if you want to only change the `pwd` for the current vim Tab.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
updateOnChange = lib.nixvim.defaultNullOpts.mkBool true ''
|
update_on_change = defaultNullOpts.mkBool true ''
|
||||||
If set to true updates the current buffer to point to the new work tree if the file is found in the new project.
|
If set to true updates the current buffer to point to the new work tree if the file is found in the new project.
|
||||||
Otherwise, the following command will be run.
|
Otherwise, the following command will be run.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
updateOnChangeCommand = lib.nixvim.defaultNullOpts.mkStr "e ." ''
|
update_on_change_command = defaultNullOpts.mkStr "e ." ''
|
||||||
The vim command to run during the `update_on_change` event.
|
The vim command to run during the `update_on_change` event.
|
||||||
Note, that this command will only be run when the current file is not found in the new worktree.
|
Note, that this command will only be run when the current file is not found in the new worktree.
|
||||||
This option defaults to `e .` which opens the root directory of the new worktree.
|
This option defaults to `e .` which opens the root directory of the new worktree.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
clearJumpsOnChange = lib.nixvim.defaultNullOpts.mkBool true ''
|
clear_jumps_on_change = defaultNullOpts.mkBool true ''
|
||||||
If set to true every time you switch branches, your jumplist will be cleared so that you don't
|
If set to true every time you switch branches, your jumplist will be cleared so that you don't
|
||||||
accidentally go backward to a different branch and edit the wrong files.
|
accidentally go backward to a different branch and edit the wrong files.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autopush = lib.nixvim.defaultNullOpts.mkBool false ''
|
autopush = defaultNullOpts.mkBool false ''
|
||||||
When creating a new worktree, it will push the branch to the upstream then perform a `git rebase`.
|
When creating a new worktree, it will push the branch to the upstream then perform a `git rebase`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
change_directory_command = "z";
|
||||||
|
update_on_change = false;
|
||||||
|
clear_jumps_on_change = false;
|
||||||
|
autopush = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
extraOptions = {
|
||||||
let
|
enableTelescope = lib.mkEnableOption "telescope integration";
|
||||||
setupOptions = with cfg; {
|
|
||||||
enabled = cfg.enable;
|
gitPackage = lib.mkPackageOption pkgs "git" {
|
||||||
change_directory_command = cfg.changeDirectoryCommand;
|
nullable = true;
|
||||||
update_on_change = cfg.updateOnChange;
|
|
||||||
update_on_change_command = cfg.updateOnChangeCommand;
|
|
||||||
clearjumps_on_change = cfg.clearJumpsOnChange;
|
|
||||||
inherit autopush;
|
|
||||||
};
|
};
|
||||||
in
|
};
|
||||||
|
|
||||||
|
extraConfig =
|
||||||
|
cfg:
|
||||||
lib.mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
|
@ -71,20 +66,10 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; [
|
|
||||||
cfg.package
|
|
||||||
plenary-nvim
|
|
||||||
];
|
|
||||||
|
|
||||||
extraPackages = [ cfg.gitPackage ];
|
extraPackages = [ cfg.gitPackage ];
|
||||||
|
|
||||||
extraConfigLua =
|
plugins.telescope.enabledExtensions = lib.mkIf cfg.enableTelescope [ "git_worktree" ];
|
||||||
let
|
|
||||||
telescopeCfg = ''require("telescope").load_extension("git_worktree")'';
|
|
||||||
in
|
|
||||||
''
|
|
||||||
require('git-worktree').setup(${lib.nixvim.toLuaObject setupOptions})
|
|
||||||
${if cfg.enableTelescope then telescopeCfg else ""}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inherit (import ./deprecations.nix) optionsRenamedToSettings;
|
||||||
}
|
}
|
||||||
|
|
9
plugins/by-name/git-worktree/deprecations.nix
Normal file
9
plugins/by-name/git-worktree/deprecations.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"changeDirectoryCommand"
|
||||||
|
"updateOnChange"
|
||||||
|
"updateOnChangeCommand"
|
||||||
|
"clearJumpsOnChange"
|
||||||
|
"autopush"
|
||||||
|
];
|
||||||
|
}
|
|
@ -12,10 +12,13 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
enableTelescope = true;
|
enableTelescope = true;
|
||||||
changeDirectoryCommand = "tcd";
|
|
||||||
updateOnChange = true;
|
settings = {
|
||||||
updateOnChangeCommand = "e .";
|
change_directory_command = "tcd";
|
||||||
clearJumpsOnChange = true;
|
update_on_change = true;
|
||||||
|
update_on_change_command = "e .";
|
||||||
|
clear_jumps_on_change = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins.web-devicons.enable = true;
|
plugins.web-devicons.enable = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue