Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: _local prefixed plugins incorrectly shown as unloaded in zinit plugins command #576

Open
1 task done
JS-Zheng opened this issue Sep 10, 2023 · 2 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@JS-Zheng
Copy link

JS-Zheng commented Sep 10, 2023

What happened?

When using the zinit plugins command, it should list both loaded and unloaded plugins. However, I've noticed that all _local prefixed plugins that are loaded are displayed as unloaded. Interestingly, local plugins with free-style names (without the _local prefix) are displayed correctly.

Expected Behavior:

The _local prefixed plugin that was loaded should be displayed as loaded.

Actual Behavior:

The _local prefixed plugin is displayed as unloaded, even though it was loaded.

Steps to reproduce

  1. Load a plugin with a _local prefix.
  2. Run the zinit plugins command.

Relevant output

My .zshrc:
zinit wait lucid depth"1" for              \
    blockf completions                     \
        "_local---eza"                     \
        "_local---iterm2"                  \
        "_local---lf"                      \
        "_local---pyenv"                   \
        "_local---fuck"                    \
    if'((ZRC_HAS_zoxide == 1))'            \
        "_local---zoxide"                  \
    MichaelAquilina/zsh-you-should-use     \
    jeffreytse/zsh-vi-mode                 \
    atload'_zsh_autosuggest_start'         \
        zsh-users/zsh-autosuggestions      \
    if'(( ZRC_HAS_fzf == 1 ))'             \
        "_local---fzf"                     \
    blockf atpull'zinit creinstall -q .'   \
        zsh-users/zsh-completions          \
    atinit'zicompinit; zicdreplay'         \
        zsh-users/zsh-syntax-highlighting


zinit plugins output:
==> Plugins
L %/Users/js-zheng/.local/opt/zinit
L MichaelAquilina/zsh-you-should-use
L eza
L jeffreytse/zsh-vi-mode
U local/fuck
U local/fzf
U local/iterm2
U local/lf
U local/p10k
U local/pyenv
U local/zoxide
L romkatv/powerlevel10k
L zsh-users/zsh-autosuggestions
L zsh-users/zsh-completions
L zsh-users/zsh-syntax-highlighting

Loaded: L | Unloaded: U

Screenshots and recordings

No response

Operating System & Version

OS: darwin21.3.0 | Vendor: apple | Machine: x86_64 | CPU: x86_64 | Processor: i386 | Hardware: x86_64

Zsh version

zsh 5.9 (x86_64-apple-darwin21.3.0)

Terminal emulator

xterm-256color

If using WSL on Windows, which version of WSL

None

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@JS-Zheng JS-Zheng added the bug Something isn't working label Sep 10, 2023
@vladdoster
Copy link
Member

vladdoster commented Sep 23, 2023

@JS-Zheng,

Can you share more of your zinit configuration? I understand the issue, but confused about the snippet.

@JS-Zheng
Copy link
Author

Of course!

I'm sorry, I missed this notification.
I apologize for the late response. 🥲

Here is my .zshrc

# ==============================================================================
#  Zinit [[[
# ==============================================================================
export ZINIT_HOME="$OPT_DIR/zinit"
source "${ZINIT_HOME}/zinit.zsh"

# Theme
zinit lucid depth"1" for \
    "_local---p10k" \
    romkatv/powerlevel10k

# Workaround for MFS/NFS
zinit lucid is-snippet for \
"$ZSH_CONFIG_DIR/history.zsh"

# Snippets
zinit wait lucid is-snippet for      \
    "$ZSH_CONFIG_DIR/basis.zsh"      \
    "$ZSH_CONFIG_DIR/general.zsh"    \
    "$ZSH_CONFIG_DIR/completion.zsh" \
    "$ZSH_CONFIG_DIR/dir.zsh"        \
    "$ZSH_CONFIG_DIR/vim.zsh"        \
    "$ZSH_CONFIG_DIR/misc.zsh"

# Plugins
zinit wait lucid depth"1" for              \
    blockf completions                     \
    if'(( ZRC_HAS_eza == 1 ))'             \
        "_local---eza"                     \
    if'[[ "$OSTYPE" == "darwin"* ]]'       \
        "_local---iterm2"                  \
    if'(( ZRC_HAS_lf == 1 ))'              \
        "_local---lf"                      \
    if'(( ZRC_HAS_pyenv == 1 ))'           \
        "_local---pyenv"                   \
    if'(( ZRC_HAS_thefuck == 1 ))'         \
        "_local---fuck"                    \
    if'((ZRC_HAS_zoxide == 1))'            \
        "_local---zoxide"                  \
    MichaelAquilina/zsh-you-should-use     \
    jeffreytse/zsh-vi-mode                 \
    atload'_zsh_autosuggest_start'         \
        zsh-users/zsh-autosuggestions      \
    if'(( ZRC_HAS_fzf == 1 ))'             \
        "_local---fzf"                     \
    blockf atpull'zinit creinstall -q .'   \
        zsh-users/zsh-completions          \
    atinit'zicompinit; zicdreplay'         \
        zsh-users/zsh-syntax-highlighting


# ]]]

Example of a local plugin:
~/.local/share/zinit/plugins/_local---lf/my-lf.plugin.zsh

lf()
{
    local tmp_dir="$(mktemp -d)"
    trap 'command rm -rf -- '"$tmp_dir" EXIT

    local lf_last_dir="$tmp_dir/lf_last_dir"

    # Use `command` to avoid using alias
    LF_LAST_DIR="$lf_last_dir" command lf "$@"

    # check if the file exists
    if [[ ! -f "$lf_last_dir" ]]; then
        return
    fi

    local dir="$(<"$lf_last_dir")"

    # check if a valid directory
    if [[ ! -d "$dir" ]]; then
        return
    fi

    # change the working directory if necessary
    if [[ "$dir" != "$PWD" ]]; then
        cd -- "$dir"
    fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants