-
Notifications
You must be signed in to change notification settings - Fork 0
themery #26
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
Merged
Merged
themery #26
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,48 @@ | ||
| #!/bin/sh | ||
|
|
||
| NVIM_STATE="$HOME/.local/share/nvim/theme.json" | ||
|
|
||
| current_theme=$(grep import "$ALACRITTY_PATH"/theme.toml | sed 's/.*\///;s/\.toml.*//') | ||
|
|
||
| # Alacritty and nvim use different names for some themes, so we translate before syncing. | ||
| # tokyonight_* -> tokyonight-* (alacritty uses underscores, nvim uses dashes) | ||
| # rose-pine -> rose-pine-moon (base variant has no nvim equivalent, moon is closest) | ||
| new_theme=$( | ||
| find "$ALACRITTY_THEME_DIR_PATH" -maxdepth 1 -type f -name '*.toml' -exec basename {} .toml \; \ | ||
| | sort \ | ||
| | fzf --tmux 60% \ | ||
| --preview "alacritty-theme {} > /dev/null && bat --color=always \"$ALACRITTY_THEME_DIR_PATH\"/{}.toml" | ||
| --preview " | ||
| alacritty-theme {} > /dev/null 2>&1 | ||
| _s=\$(echo {} | sed 's/tokyonight_/tokyonight-/; s/^rose-pine$/rose-pine-moon/') | ||
| case \"\$_s\" in | ||
| rose-pine-moon|rose-pine-dawn|\ | ||
| catppuccin-latte|catppuccin-frappe|catppuccin-macchiato|catppuccin-mocha|\ | ||
| nord|\ | ||
| tokyonight-night|tokyonight-storm|tokyonight-day|tokyonight-moon) | ||
| printf '{\"colorscheme\":\"%s\"}' \"\$_s\" > \"$NVIM_STATE\";; | ||
| esac | ||
| bat --color=always \"$ALACRITTY_THEME_DIR_PATH\"/{}.toml | ||
| " | ||
| ) | ||
|
|
||
| sync_nvim() { | ||
| _s=$(echo "$1" | sed 's/tokyonight_/tokyonight-/; s/^rose-pine$/rose-pine-moon/') | ||
| case "$_s" in | ||
| rose-pine-moon|rose-pine-dawn|\ | ||
| catppuccin-latte|catppuccin-frappe|catppuccin-macchiato|catppuccin-mocha|\ | ||
| nord|\ | ||
| tokyonight-night|tokyonight-storm|tokyonight-day|tokyonight-moon) | ||
| _tmp=$(mktemp "${NVIM_STATE}.XXXXXX") | ||
| printf '{"colorscheme":"%s"}' "$_s" > "$_tmp" && mv "$_tmp" "$NVIM_STATE" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| if [ -z "$new_theme" ]; then | ||
| echo "Theme not selected." | ||
| alacritty-theme "$current_theme" | ||
| sync_nvim "$current_theme" | ||
| exit 1 | ||
| fi | ||
|
|
||
| alacritty-theme "$new_theme" | ||
| sync_nvim "$new_theme" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| name: nvim-ctx | ||
| description: Fetch the current neovim context (open file, cursor position, and active selection) from a running nvim instance, then act on any instructions the user passed alongside the invocation. Trigger when the user types `/nvim-ctx` with or without arguments. | ||
| --- | ||
|
|
||
| # nvim-ctx | ||
|
|
||
| ## Parsing args | ||
|
|
||
| Args follow this shape: `[--session <name>] [instructions...]` | ||
|
|
||
| - If args begins with `--session <name>`, extract `<name>` as the tmux session to target and treat the remainder as instructions. | ||
| - Otherwise, use no session argument (defaults to current tmux session) and treat all args as instructions. | ||
|
|
||
| ## Fetching context | ||
|
|
||
| Run: | ||
|
|
||
| ```sh | ||
| nvim-ctx [<session>] | ||
| ``` | ||
|
|
||
| It outputs JSON with `file`, `start_line`, `end_line`, and `text` (active visual selection if one exists, otherwise the full buffer). | ||
|
|
||
| **If `nvim-ctx` fails** (no nvim pane found, nvim not running, socket not found): tell the user briefly what failed and ask them to paste the relevant code instead. Do not proceed as if you have context you don't have. | ||
|
|
||
| ## After fetching | ||
|
|
||
| If instructions were provided, use the context to address them directly — the fetched file/selection is the subject. | ||
|
|
||
| If no instructions were provided, briefly surface what you found (file path, line range, whether it's a selection or full buffer) and wait for the user to tell you what they want. | ||
|
|
||
| Do not re-read the file with the Read tool just because you have the path — the JSON output already contains the text. Only reach for Read if you need lines outside the reported range. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make
theme.jsonwrites resilient (ensure directory + atomic replace).Line 22 and Line 35 write directly to
"$NVIM_STATE"with>. If~/.local/share/nvimdoesn’t exist, sync fails; and truncate-in-place can briefly expose invalid JSON to Neovim’s file watcher.Suggested fix
Also applies to: 22-23, 35-35
🤖 Prompt for AI Agents