Skip to content

Fix nvim :zz zoxide mapping to correctly change directory#903

Open
ryo246912 wants to merge 1 commit intomainfrom
fix/nvim-zoxide-mapping-fzf-lua-12308758324455625214
Open

Fix nvim :zz zoxide mapping to correctly change directory#903
ryo246912 wants to merge 1 commit intomainfrom
fix/nvim-zoxide-mapping-fzf-lua-12308758324455625214

Conversation

@ryo246912
Copy link
Copy Markdown
Owner

@ryo246912 ryo246912 commented Apr 25, 2026

The user reported that :zz in Neovim was only listing directories but not changing to them. I investigated the configuration and found that zoxide.vim was used for :Zi (mapped to :zz), which seemed to have issues or was incomplete. Since fzf-lua is already used in the repository and has native zoxide support, I switched the mapping to use fzf-lua's zoxide picker, which correctly performs a 'cd' after selection. I also removed the now-redundant zoxide.vim plugin configuration.


PR created automatically by Jules for task 12308758324455625214 started by @ryo246912

変更内容概要

Neovim の :zz コマンドと <leader>z キーマップを、zoxide.vim から fzf-lua の zoxide picker に置き換えました。

  • dot_config/nvim/lua/plugins/filer.lua: zoxide.vim プラグインの設定を削除
  • dot_config/nvim/lua/plugins/fzf.lua: fzf-lua の zoxide picker を使用した 2 つの新しいマッピングを追加
    • <leader>z(ノーマルモード): fzf.zoxide を呼び出してディレクトリ検索
    • :zz(コマンドラインモード): lua require('fzf-lua').zoxide() を実行

変更理由

既存の zoxide.vim を使用した :Zi コマンドは、ディレクトリのリストを表示するのみで、選択後にディレクトリが変わらない問題がありました。fzf-lua は既に導入済みであり、zoxide のネイティブサポートがあるため、同じ機能を zoxide.vim から fzf-lua に統一することで、選択後に自動的にディレクトリが変わる正常な動作を実現できます。

確認した項目

  • fzf.lua で <leader>z:zz の 2 つのマッピングが新たに追加されていることを確認
  • 両方のマッピングが同じ fzf-lua の zoxide picker を使用していることを確認
  • filer.lua から zoxide.vim 関連の設定が完全に削除されていることを確認

Replaced nanotee/zoxide.vim's :Zi mapping with fzf-lua's zoxide picker
for the :zz command. This ensures that selecting a directory correctly
triggers a directory change (cd), addressing the issue where it only
displayed a list without navigating.

- Removed nanotee/zoxide.vim from plugins/filer.lua
- Added fzf-lua.zoxide mapping to :zz and <leader>z in plugins/fzf.lua
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the :zz command in Neovim failed to change directories correctly. By replacing the problematic zoxide.vim plugin with fzf-lua's built-in zoxide support, the configuration is simplified and the directory navigation functionality is restored to expected behavior.

Highlights

  • Plugin Removal: Removed the nanotee/zoxide.vim plugin as it was causing issues with directory navigation.
  • Mapping Migration: Updated the :zz command mapping to utilize fzf-lua's native zoxide integration for reliable directory changing.
  • New Keybinding: Added a new z keybinding to trigger the zoxide directory search via fzf-lua.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

このプルリクエストでは、zoxide.vim プラグインを廃止し、fzf-lua を使用した zoxide 連携機能に移行しています。レビューでは、コマンドラインマッピング zz が他のコマンド入力を妨げる可能性への対策として、コマンドラインの先頭でのみ動作する条件付きマッピングへの改善が提案されています。また、プラグイン削除に伴い失われるディレクトリ移動の自動記録機能を補完するための DirChanged オートコマンドの活用についても指摘されています。

I am having trouble creating individual review comments. Click here to see my feedback.

dot_config/nvim/lua/plugins/fzf.lua (98-99)

medium

cnoremap zz は、コマンドライン上のどの位置でも zz が入力されると発火するため、例えば :help zz:!grep zz といった他のコマンドの入力を妨げる可能性があります。他のマッピングと同様に keymap ( vim.keymap.set ) を使用し、コマンドラインの先頭( : の直後)でのみ動作するように条件判定を追加することを推奨します。

      -- :zz で zoxide を起動 (コマンドラインの先頭でのみ有効化)
      keymap("c", "zz", function()
        return (vim.fn.getcmdtype() == ":" and vim.fn.getcmdline() == "")
          and "<C-u>lua require('fzf-lua').zoxide()<CR>"
          or "zz"
      end, { expr = true })
References
  1. 既存ユーザー環境を壊す変更(他のコマンド入力の妨げ)を優先して確認する方針に基づいています。 (link)

dot_config/nvim/lua/plugins/filer.lua (125-134)

medium

zoxide.vim を削除したことで、vim.g.zoxide_hook = "pwd" による Vim 内でのディレクトリ移動( cd 等)を zoxide データベースに自動登録する機能が失われます。Vim での移動履歴も zoxide に反映させたい場合は、DirChanged オートコマンド等を利用して zoxide add を呼び出す設定を別途追加することを検討してください。

References
  1. 既存ユーザー環境を壊す変更(機能の消失)を優先して確認する方針に基づいています。 (link)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

Walkthrough

このプルリクエストではNeovimの設定におけるZoxideを使用したディレクトリ操作の実装を変更しています。従来のnanotee/zoxide.vimプラグイン設定(zoxideフック、zzコマンドマッピングを含む)を削除し、代わりにFZF-Luaプラグインのネイティブなzoxideピッカー機能を使用する実装に切り替えています。新たに<leader>zノーマルモードのショートカットと:zzコマンドラインエイリアスが追加されることで、同等の機能を提供する変更となっています。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRのタイトルは、nanotee/zoxide.vimを削除してfzf-luaのzoxideピッカーに置き換えることで、:zzコマンドの動作を修正するというメインの変更を正確に反映しており、明確かつ具体的です。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nvim-zoxide-mapping-fzf-lua-12308758324455625214

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 12285323-3d2f-4a12-a310-a95229b55832

📥 Commits

Reviewing files that changed from the base of the PR and between 77bfca7 and 80610b2.

📒 Files selected for processing (2)
  • dot_config/nvim/lua/plugins/filer.lua
  • dot_config/nvim/lua/plugins/fzf.lua
💤 Files with no reviewable changes (1)
  • dot_config/nvim/lua/plugins/filer.lua

Comment on lines +96 to +97
-- zoxideを使用してディレクトリ移動
keymap("n", "<leader>z", fzf.zoxide, { noremap = true, silent = true, desc = "Zoxide ディレクトリ検索" })
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# _ZO_DATA_DIR の設定箇所を一覧化し、nvim 起動経路に確実に伝播するか確認する
rg -nP '_ZO_DATA_DIR' -C2

Repository: ryo246912/dotfiles

Length of output: 1752


🏁 Script executed:

#!/bin/bash
# Check all shell startup files for _ZO_DATA_DIR export and zoxide initialization
echo "=== Checking shell startup files ===" 
for file in dot_config/zsh/.zshenv dot_config/zsh/.zprofile dot_config/zsh/.zshrc dot_config/zsh/.zlogin; do
  if [ -f "$file" ]; then
    echo "--- $file ---"
    rg -n '_ZO_DATA_DIR|zoxide' "$file" -A 2 -B 2
  fi
done

Repository: ryo246912/dotfiles

Length of output: 99


🏁 Script executed:

#!/bin/bash
# Check if Neovim config references or handles environment variables related to zoxide
echo "=== Checking Neovim config for zoxide/env var handling ===" 
rg -n 'zoxide|_ZO_DATA_DIR|os.getenv|os.environ' dot_config/nvim/ -A 2

Repository: ryo246912/dotfiles

Length of output: 600


🏁 Script executed:

#!/bin/bash
# Check if there's any shell wrapper or launcher config for Neovim
echo "=== Checking for nvim launchers or wrappers ===" 
fd -t f 'nvim' . --exclude=.git --exclude=node_modules | head -20
rg -l 'nvim|NEOVIM' --type sh --type bash . | head -10

Repository: ryo246912/dotfiles

Length of output: 157


🏁 Script executed:

#!/bin/bash
# Find actual zsh configuration files
echo "=== Zsh config structure ===" 
find dot_config/zsh -type f -name ".*" | head -20
ls -la dot_config/zsh/

Repository: ryo246912/dotfiles

Length of output: 750


🏁 Script executed:

#!/bin/bash
# Check how mise.zsh gets sourced/initialized
echo "=== How mise.zsh is sourced ===" 
rg -n 'mise.zsh|lazy' dot_config/zsh/ -t zsh

Repository: ryo246912/dotfiles

Length of output: 739


🏁 Script executed:

#!/bin/bash
# Look for main zsh init files that might not be in lazy directory
echo "=== All zsh files ===" 
find dot_config/zsh -type f | xargs basename -a | sort | uniq

Repository: ryo246912/dotfiles

Length of output: 300


🏁 Script executed:

#!/bin/bash
# Check the zshenv template and main zshrc for environment variable setup
echo "=== dot_zshenv.tmpl content ===" 
cat -n dot_config/zsh/dot_zshenv.tmpl

echo ""
echo "=== dot_zshrc content ===" 
cat -n dot_config/zsh/dot_zshrc

echo ""
echo "=== lazy.zsh content ===" 
cat -n dot_config/zsh/lazy.zsh

Repository: ryo246912/dotfiles

Length of output: 6034


🏁 Script executed:

#!/bin/bash
# Check main.zsh which might source lazy files
echo "=== main.zsh content ===" 
cat -n dot_config/zsh/main.zsh

Repository: ryo246912/dotfiles

Length of output: 1457


🏁 Script executed:

#!/bin/bash
# Check if zoxide has any special initialization or requirements in Neovim
echo "=== Check fzf-lua documentation or code for zoxide requirements ===" 
rg -n 'zoxide' dot_config/nvim/ -B 3 -A 3

# Check if there's any mention of environment setup in Neovim config
echo ""
echo "=== Check for any shell integration or env setup in Neovim ===" 
rg -n 'shell|env|spawn|system' dot_config/nvim/init.lua -i | head -20

Repository: ryo246912/dotfiles

Length of output: 977


🏁 Script executed:

#!/bin/bash
# Verify: is _ZO_DATA_DIR needed in zshenv or is lazy loading sufficient?
# Check if mise.zsh is always sourced before zoxide is used
echo "=== When is zoxide actually used/called ===" 
rg -rn 'zoxide|_ZO_DATA_DIR' dot_config/ --exclude-dir=nvim | grep -v 'Binary'

echo ""
echo "=== Check if there are any early uses of zoxide (before lazy loading) ===" 
rg -n 'j ' dot_config/zsh/*.zsh | grep -v lazy | head -10

Repository: ryo246912/dotfiles

Length of output: 615


<leader>z マッピングは適切です

fzf.zoxide 呼び出しは fzf-lua のネイティブピッカーで、選択後に cd を実行する仕様のため、PR 目的(選択後にディレクトリ変更されない問題の解消)と整合しています。

補足として、本リポジトリでは zoxide のデータディレクトリを ~/.local/state/zoxide にカスタマイズしており、_ZO_DATA_DIR は lazy ロード時の mise.zsh および tmux.conf で設定されています。ただし、zshenv では設定されていないため、GUI ランチャーなど shell 初期化が完全に実行されない環境から nvim を起動した場合、デフォルトの ~/.local/share/zoxide を参照する可能性があります。

-- zoxideを使用してディレクトリ移動
keymap("n", "<leader>z", fzf.zoxide, { noremap = true, silent = true, desc = "Zoxide ディレクトリ検索" })
-- :zz で zoxide を起動
vim.cmd("cnoremap zz <C-u>lua require('fzf-lua').zoxide()<CR>")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

fzf-lua zoxide picker cd behavior and cnoreabbrev expr command alias pattern in Neovim

💡 Result:

In fzf-lua, the zoxide picker (:FzfLua zoxide) lists recent directories from zoxide query --list --score, formatted with scores excluded from fuzzy matching via fzf_opts --nth=2... . Default enter action is actions.cd, which extracts the directory path, optionally detects git root if enabled, then executes vim.cmd with "cd", "lcd", "tcd", or "tcd" based on zoxide.scope ("global" default for :cd, "local" for :lcd, "win" for :lcd, "tab" for :tcd). It also runs zoxide add to increment the score and prints confirmation. To create a Neovim command-line alias like "z" for :FzfLua zoxide using cnoreabbrev , use a pattern that checks command type and line start: cnoreabbrev z ((getcmdtype ==# ':' && getcmdline =~# '^z\s*$') ? 'FzfLua zoxide' : 'z') This expands ":z " to ":FzfLua zoxide " only when "z" is the full command followed by space/end, avoiding interference with other uses like ":Zz" or searches. More robust versions check getcmdpos <= len("z")+1 for beginning-of-line matching, as in common alias functions from Vim/Neovim configs.

Citations:


cnoremap zz はコマンドライン中の zz 部分一致でも発火します

cnoremap はコマンドラインの「キー入力シーケンス」を置換するため、:zz 単体だけでなく zz を含む任意の入力(例::buzz:e fizz.txt:s/foo/zz/ など)でもマッピングが発動します。さらに <C-u> でコマンドラインが消去されるため、ユーザーが途中まで入力した別のコマンドが破壊される副作用があります。

:zz 専用のエイリアスにする場合は、cnoreabbrev <expr> でコマンドライン全体が zz のときだけ展開するのが安全かつ標準的です。

♻️ 提案(cnoreabbrev による厳密マッチ)
-      vim.cmd("cnoremap zz <C-u>lua require('fzf-lua').zoxide()<CR>")
+      vim.cmd("cnoreabbrev <expr> zz (getcmdtype() == ':' && getcmdline() ==# 'zz') ? \"lua require('fzf-lua').zoxide()\" : 'zz'")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
vim.cmd("cnoremap zz <C-u>lua require('fzf-lua').zoxide()<CR>")
vim.cmd("cnoreabbrev <expr> zz (getcmdtype() == ':' && getcmdline() ==# 'zz') ? \"lua require('fzf-lua').zoxide()\" : 'zz'")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant