Skip to content

themery#26

Merged
Vilos92 merged 5 commits into
mainfrom
custom-themery
Jun 22, 2026
Merged

themery#26
Vilos92 merged 5 commits into
mainfrom
custom-themery

Conversation

@Vilos92

@Vilos92 Vilos92 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Replaced the Themery theme picker with a Telescope-based picker that previews themes live while browsing.
    • Theme selection now persists in a local theme.json, auto-reloading on changes and migrating once from prior Themery state.
    • Improved Alacritty↔Neovim theme sync via alacritty-theme-select.
  • Improvements

    • Theme cancel/confirm behavior is clearer: cancel restores the original theme; confirm saves the new one.
    • /nvim-ctx now requests asynchronously with a timeout, with updated nvim-ctx command documentation.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1521b9eb-87b5-4fa4-a87b-3c77d9037d56

📥 Commits

Reviewing files that changed from the base of the PR and between 327607b and 9e7903b.

📒 Files selected for processing (1)
  • .cursor/rules/greg-workflow-preferences.mdc
✅ Files skipped from review due to trivial changes (1)
  • .cursor/rules/greg-workflow-preferences.mdc

📝 Walkthrough

Walkthrough

Replaces the Themery plugin with a custom Telescope-based theme picker integrated with Alacritty, adds formal skill documentation for the /nvim-ctx command, and implements timeout-safe execution for Neovim RPC requests. theme.lua is rewritten to include a simplified theme list, Alacritty name mapping, JSON-based persistence with Themery migration, and an open_picker() Telescope function with live preview and confirm/cancel flows. alacritty-theme-select now syncs theme selection back to Neovim's theme.json with bidirectional name translation. pack.lua swaps themery.nvim for telescope.nvim, starter.lua updates the Theme button to call the new picker, and nvim-ctx adds timeout enforcement with error reporting.

Changes

Telescope Theme Picker with Alacritty Sync

Layer / File(s) Summary
Plugin dependency swap
nvim/.config/nvim/lua/greg/pack.lua
Removes zaldih/themery.nvim and adds nvim-telescope/telescope.nvim and ThePrimeagen/harpoon to the plugin list.
Theme list, Alacritty mapping, and persistence
nvim/.config/nvim/after/plugin/theme.lua
Replaces the Themery theme table with a plain themes list of colorscheme names, adds alacritty_map for bidirectional name remapping (e.g., tokyonight_*tokyonight-*, rose-pinerose-pine-moon), defines apply_alacritty(scheme) for invoking Alacritty theme changes, and implements save_theme()/load_theme() backed by theme.json with one-time migration from Themery's state file.
Telescope picker, entry points, and autocommands
nvim/.config/nvim/after/plugin/theme.lua, nvim/.config/nvim/after/plugin/starter.lua
Implements open_picker() with Telescope live preview on selection change and explicit confirm/cancel keymaps; exports vim.g.theme_picker, registers a ColorScheme autocommand to call apply_alacritty() on colorscheme changes, loads persisted theme at startup, adds a uv filesystem watcher to detect external theme.json modifications, rebinds <leader>t to open_picker, and updates the Mini Starter Theme button to invoke the picker function.
Alacritty-Neovim bidirectional theme sync
alacritty/.local/bin/alacritty-theme-select
Extends alacritty-theme-select with a new sync_nvim() function that translates Alacritty theme names using the same mapping rules and persists the mapped colorscheme to ~/.local/share/nvim/theme.json atomically. The fzf preview now translates and syncs theme names during preview navigation, the success path calls sync_nvim() after applying the selection, and the empty-selection branch re-applies the current theme, syncs it, and exits with status 1 to enable Neovim's filesystem watcher to detect the JSON change.

nvim-ctx Skill Definition and Timeout Handling

Layer / File(s) Summary
nvim-ctx skill specification
claude/.claude/skills/nvim-ctx/SKILL.md
Documents the /nvim-ctx command, specifying argument parsing for --session <name>, expected JSON output fields (file path, line range, selected text or full buffer), failure handling instructions (request user to paste code if context cannot be fetched), and conditional post-fetch behavior (apply instructions directly if provided, or report findings and wait for guidance).
Timeout and error handling for Neovim RPC
zsh/.local/bin/nvim-ctx
Updates the script to execute Neovim server requests asynchronously with a ~5-second timeout enforced via a background kill watcher. The script waits for the background request to complete, ensures the watcher is cleaned up, and exits with status 1 and an error message to stderr when the request fails or times out.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant open_picker
    participant Telescope
    participant vim_colorscheme
    participant save_theme
    participant apply_alacritty
    participant alacritty_select
    participant fzf
    participant sync_nvim
    participant theme_json

    User->>open_picker: <leader>t or Mini Starter Theme
    open_picker->>vim_colorscheme: read colors_name (save original)
    open_picker->>Telescope: open themes picker
    User->>Telescope: navigate entries (live)
    Telescope->>vim_colorscheme: set colorscheme (preview)
    alt Confirm <CR>
        Telescope->>vim_colorscheme: apply selected scheme
        Telescope->>save_theme: write theme.json
        vim_colorscheme-->>apply_alacritty: ColorScheme autocmd
        apply_alacritty->>apply_alacritty: map name and invoke alacritty-theme
    else Cancel <Esc>
        Telescope->>vim_colorscheme: restore original colors_name
        vim_colorscheme-->>apply_alacritty: ColorScheme autocmd
        apply_alacritty->>apply_alacritty: map name and invoke alacritty-theme
    end

    par Alacritty Side
        User->>alacritty_select: run alacritty-theme-select
        alacritty_select->>fzf: open theme list
        User->>fzf: select theme
        fzf->>sync_nvim: translate name
        sync_nvim->>theme_json: write mapped colorscheme
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 Themery fades like morning dew,
Telescope's brilliance shines brand new.
JSON whispers which colors remain,
Alacritty listens—no theme-sync pain.
nvim-ctx waits with patience and care,
Two editors dancing through cyberspace air! 🌈

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'themery' is vague and generic, referring only to a tool name without indicating the nature of the change (removal, replacement, or refactoring). Use a more descriptive title like 'Replace Themery with Telescope-based theme picker' to clearly convey that the PR removes Themery and implements a new theme picker system.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch custom-themery

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
nvim/.config/nvim/after/plugin/theme.lua (1)

138-142: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider deferring Alacritty sync until theme is confirmed.

The ColorScheme autocmd fires on every navigation in the picker since apply_selected() changes the colorscheme for live preview. This spawns alacritty-theme potentially dozens of times during a single browse session.

If real-time Alacritty preview is desired, current behavior is correct. Otherwise, consider calling apply_alacritty only from save_theme() or within confirm() to avoid subprocess spawns during browsing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nvim/.config/nvim/after/plugin/theme.lua` around lines 138 - 142, The
ColorScheme autocmd callback is firing excessively during theme picker
navigation because apply_selected() changes the colorscheme for live preview,
causing apply_alacritty to spawn repeatedly. To fix this, remove the call to
apply_alacritty from the ColorScheme autocmd callback function, and instead call
apply_alacritty directly from the save_theme() or confirm() functions where the
user explicitly confirms and saves their theme selection. This will ensure the
Alacritty theme only syncs when the user confirms their choice rather than on
every preview navigation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@nvim/.config/nvim/after/plugin/theme.lua`:
- Around line 138-142: The ColorScheme autocmd callback is firing excessively
during theme picker navigation because apply_selected() changes the colorscheme
for live preview, causing apply_alacritty to spawn repeatedly. To fix this,
remove the call to apply_alacritty from the ColorScheme autocmd callback
function, and instead call apply_alacritty directly from the save_theme() or
confirm() functions where the user explicitly confirms and saves their theme
selection. This will ensure the Alacritty theme only syncs when the user
confirms their choice rather than on every preview navigation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 142cd5f4-c291-4bc9-958e-5c1d8b9fb4ed

📥 Commits

Reviewing files that changed from the base of the PR and between ae2d505 and caf96e6.

📒 Files selected for processing (3)
  • nvim/.config/nvim/after/plugin/starter.lua
  • nvim/.config/nvim/after/plugin/theme.lua
  • nvim/.config/nvim/lua/greg/pack.lua
💤 Files with no reviewable changes (1)
  • nvim/.config/nvim/lua/greg/pack.lua

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@alacritty/.local/bin/alacritty-theme-select`:
- Line 3: The NVIM_STATE writes at lines 22-23 and 35 are not resilient because
they directly write to the file without ensuring the parent directory exists,
and they use non-atomic truncation-in-place writes with `>`. To fix this, before
any write operations to NVIM_STATE, ensure the parent directory
~/.local/share/nvim exists by creating it with mkdir -p. Then replace the direct
`>` redirections with atomic writes: write to a temporary file in the same
directory, then use mv to atomically replace the original file. This prevents
failures when the directory doesn't exist and ensures Neovim's file watcher
never sees invalid JSON.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f416c2ce-2f57-4dd4-9661-e232b3a9dfdc

📥 Commits

Reviewing files that changed from the base of the PR and between caf96e6 and ff7c4ff.

📒 Files selected for processing (2)
  • alacritty/.local/bin/alacritty-theme-select
  • nvim/.config/nvim/after/plugin/theme.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • nvim/.config/nvim/after/plugin/theme.lua

@@ -1,18 +1,47 @@
#!/bin/sh

NVIM_STATE="$HOME/.local/share/nvim/theme.json"

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 | ⚡ Quick win

Make theme.json writes resilient (ensure directory + atomic replace).

Line 22 and Line 35 write directly to "$NVIM_STATE" with >. If ~/.local/share/nvim doesn’t exist, sync fails; and truncate-in-place can briefly expose invalid JSON to Neovim’s file watcher.

Suggested fix
 NVIM_STATE="$HOME/.local/share/nvim/theme.json"
+mkdir -p "$(dirname "$NVIM_STATE")"
+
+write_nvim_state() {
+  _tmp="$(mktemp "${NVIM_STATE}.tmp.XXXXXX")" || return 1
+  printf '{"colorscheme":"%s"}' "$1" > "$_tmp" && mv "$_tmp" "$NVIM_STATE"
+}
@@
-                printf '{"colorscheme":"%s"}' "$_s" > "$NVIM_STATE";;
+                write_nvim_state "$_s";;
@@
-      printf '{"colorscheme":"%s"}' "$_s" > "$NVIM_STATE"
+      write_nvim_state "$_s"
       ;;

Also applies to: 22-23, 35-35

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@alacritty/.local/bin/alacritty-theme-select` at line 3, The NVIM_STATE writes
at lines 22-23 and 35 are not resilient because they directly write to the file
without ensuring the parent directory exists, and they use non-atomic
truncation-in-place writes with `>`. To fix this, before any write operations to
NVIM_STATE, ensure the parent directory ~/.local/share/nvim exists by creating
it with mkdir -p. Then replace the direct `>` redirections with atomic writes:
write to a temporary file in the same directory, then use mv to atomically
replace the original file. This prevents failures when the directory doesn't
exist and ensures Neovim's file watcher never sees invalid JSON.

@Vilos92 Vilos92 merged commit 919c1a8 into main Jun 22, 2026
4 checks passed
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