zap-zsh / zap

:zap: Zap is a minimal zsh plugin manager
https://www.zapzsh.com/
GNU General Public License v3.0
942 stars 33 forks source link

Add additional descriptor to distinguish local plugins (conflict with GitHub name) #159

Closed gennaro-tedesco closed 1 year ago

gennaro-tedesco commented 1 year ago

If the feature request is for a plugin or theme, specify it here.

No response

If the feature solves a problem you have, specify it here.

Currently the syntax to install a remote plugin is:

plug "<github-name>/repository-name"

which ideally automatically resolves to ZAP_GIT_PREFIX and pulls the corresponding code from the hosting service. Likewise, to install local plugins, as per the README

A file descriptor which points to a directory is treated as a plugin, versus a regular file

# Example sourcing of local files
plug "$HOME/.config/zsh/aliases.zsh"

This mechanism however generates a conflict when, accidentally, the <github-name> corresponds to a folder name on the local machine, and it seems that in such a case Zap defaults to looking in the local directories and if nothing is found, the plugin is skipped or not activated (or whichever other exception mechanism is in place, I have not checked the code yet).

Describe the proposed feature.

Example

A classical example is when trying to install your own plugins hosted under your name. And sometimes the $HOME directory on your computer has the same name, thus bypassing the installation of the remote plugin.

Question

How can one go around this? Ideally I would propose to add an additional qualifier to indicate that you are explicitly sourcing a local plugin, something along the lines of

plug "<name>/folder" "local=true"

or the like.

Describe alternatives you've considered

No response

Additional context

No response

Related Issues

No response

wintermi commented 1 year ago

You are correct, a check for a local directory is made before attempting to clone a Git repository. If you were to execute the following command within a terminal window:

plug "zsh-plugin"

and there was a directory relative to your current path called "zsh-plugin", it will assume that you are attempting to load a local directory as a plugin.

Ideally an absolute local path should be provided, though in its current form it is not required.

There is however a quick fix that would resolve the immediate issue with relative directories being picked up instead of cloning a Git repository.

I would prefer to make this change before considering adding additional argument support to plug. As if we were to add argument support, then I would prefer a larger design discussion be had.

wintermi commented 1 year ago

@gennaro-tedesco - Please update to version 1.2.1 and restart your terminal sessions. If you experience the same issue please reopen.

gennaro-tedesco commented 1 year ago

I confirm it works with the latest commit, thank you for the quick effort!!

P. S.

Please update to version 1.2.1

zap version only shows the latest commit, the version number is not included, is it?

wintermi commented 1 year ago

Please execute zap update self which will update your version of Zap that includes the version number.

You could also execute the following to perform a clean install of Zap and all your existing plugins:

zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-v1 --keep