Conversation
Added functions to enable transparency and apply themes based on terminal.
📝 WalkthroughWalkthroughReplaces a direct colorscheme call with two local functions: one to set transparent backgrounds for various highlight groups, and another to apply a colorscheme based on TERM_PROGRAM (deus for iTerm.app, duskfox otherwise). The terminal-aware function is invoked; transparency remains defined with a commented call. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@after/plugin/theme.lua`:
- Around line 49-58: Wrap the colorscheme application in a safe helper (e.g.,
try_colorscheme) that uses pcall(vim.cmd.colorscheme, name) and returns success;
update apply_theme_for_terminal to call try_colorscheme("deus") for iTerm.app
and try_colorscheme("duskfox") otherwise, falling back to "habamax" if the first
attempt fails, and only call enableTransparency() after try_colorscheme returns
true. Ensure function names try_colorscheme, apply_theme_for_terminal, and
enableTransparency are referenced exactly as above so the change is easy to
locate.
🧹 Nitpick comments (1)
after/plugin/theme.lua (1)
1-47: Transparency will be overwritten unless you re-apply it after:colorscheme(or onColorScheme).
Right nowenableTransparency()is not invoked, and even when enabled it should run after the scheme (and on scheme changes) to be reliable. Also consider standardizingbgto"NONE"and reducing repetition with a group list + loop.Proposed refactor (apply-on-colorscheme + reduce repetition)
local function enableTransparency() - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) - vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none" }) - vim.api.nvim_set_hl(0, "Pmenu", { bg = "none" }) - vim.api.nvim_set_hl(0, "Terminal", { bg = "none" }) - vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = "none" }) - vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" }) - vim.api.nvim_set_hl(0, "Folded", { bg = "none" }) - vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) - vim.api.nvim_set_hl(0, "WhichKeyFloat", { bg = "none" }) - vim.api.nvim_set_hl(0, "TelescopeBorder", { bg = "none" }) - vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "none" }) - vim.api.nvim_set_hl(0, "TelescopePromptBorder", { bg = "none" }) - vim.api.nvim_set_hl(0, "TelescopePromptTitle", { bg = "none" }) - vim.api.nvim_set_hl(0, "StatusLine", { bg = "none" }) - vim.api.nvim_set_hl(0, "LineNr", { bg = "none", fg = "#5c6370" }) + local groups = { + "Normal", + "NormalFloat", + "FloatBorder", + "Pmenu", + "Terminal", + "EndOfBuffer", + "FoldColumn", + "Folded", + "SignColumn", + "NormalNC", + "WhichKeyFloat", + "TelescopeBorder", + "TelescopeNormal", + "TelescopePromptBorder", + "TelescopePromptTitle", + "StatusLine", + } + for _, group in ipairs(groups) do + vim.api.nvim_set_hl(0, group, { bg = "NONE" }) + end + vim.api.nvim_set_hl(0, "LineNr", { bg = "NONE", fg = "#5c6370" }) -- transparent background for nvim-tree - vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NvimTreeVertSplit", { bg = "none" }) - vim.api.nvim_set_hl(0, "NvimTreeEndOfBuffer", { bg = "none" }) + vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "NONE" }) + vim.api.nvim_set_hl(0, "NvimTreeVertSplit", { bg = "NONE" }) + vim.api.nvim_set_hl(0, "NvimTreeEndOfBuffer", { bg = "NONE" }) -- transparent notify background - vim.api.nvim_set_hl(0, "NotifyINFOBody", { bg = "none" }) + vim.api.nvim_set_hl(0, "NotifyINFOBody", { bg = "NONE" }) -- (repeat "NONE" for the rest as well) vim.api.nvim_set_hl(0, "BufferLineFill", { fg = "#ffffff", bg = "NONE" }) vim.api.nvim_set_hl(0, "BufferLineBackground", { fg = "#ffffff" }) vim.api.nvim_set_hl(0, "BufferLineBufferSelected", { bold = true, bg = "NONE" }) vim.api.nvim_set_hl(0, "BufferLineSeparator", { bg = "NONE", fg = "NONE" }) vim.api.nvim_set_hl(0, "BufferLineSeparatorSelected", {}) end + +-- If you want transparency enabled, this makes it resilient to scheme changes: +vim.api.nvim_create_autocmd("ColorScheme", { + callback = enableTransparency, +})
| local function apply_theme_for_terminal() | ||
| local term_program = vim.env.TERM_PROGRAM or "" | ||
| if term_program == "iTerm.app" then | ||
| vim.cmd.colorscheme("deus") | ||
| else | ||
| vim.cmd.colorscheme("duskfox") | ||
| -- enableTransparency() | ||
| end | ||
| end | ||
|
|
There was a problem hiding this comment.
Wrap colorscheme calls with pcall and fallback
:colorscheme will error if the theme isn’t installed. Use a helper like try_colorscheme to pcall(vim.cmd.colorscheme, ...) and fallback to "habamax". Call enableTransparency() only after a successful apply.
Suggested patch
local function apply_theme_for_terminal()
local function try_colorscheme(name)
return pcall(vim.cmd.colorscheme, name)
end
local term_program = vim.env.TERM_PROGRAM or ""
if term_program == "iTerm.app" then
- vim.cmd.colorscheme("deus")
+ if not try_colorscheme("deus") then
+ try_colorscheme("habamax")
+ end
else
- vim.cmd.colorscheme("duskfox")
- -- enableTransparency()
+ if not try_colorscheme("duskfox") then
+ try_colorscheme("habamax")
+ end
+ -- enableTransparency()
end
end📝 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.
| local function apply_theme_for_terminal() | |
| local term_program = vim.env.TERM_PROGRAM or "" | |
| if term_program == "iTerm.app" then | |
| vim.cmd.colorscheme("deus") | |
| else | |
| vim.cmd.colorscheme("duskfox") | |
| -- enableTransparency() | |
| end | |
| end | |
| local function apply_theme_for_terminal() | |
| local function try_colorscheme(name) | |
| return pcall(vim.cmd.colorscheme, name) | |
| end | |
| local term_program = vim.env.TERM_PROGRAM or "" | |
| if term_program == "iTerm.app" then | |
| if not try_colorscheme("deus") then | |
| try_colorscheme("habamax") | |
| end | |
| else | |
| if not try_colorscheme("duskfox") then | |
| try_colorscheme("habamax") | |
| end | |
| -- enableTransparency() | |
| end | |
| end |
🤖 Prompt for AI Agents
In `@after/plugin/theme.lua` around lines 49 - 58, Wrap the colorscheme
application in a safe helper (e.g., try_colorscheme) that uses
pcall(vim.cmd.colorscheme, name) and returns success; update
apply_theme_for_terminal to call try_colorscheme("deus") for iTerm.app and
try_colorscheme("duskfox") otherwise, falling back to "habamax" if the first
attempt fails, and only call enableTransparency() after try_colorscheme returns
true. Ensure function names try_colorscheme, apply_theme_for_terminal, and
enableTransparency are referenced exactly as above so the change is easy to
locate.
|
@coderabbitai clone the repo and find interseting facts about the PR |
1 similar comment
|
@coderabbitai clone the repo and find interseting facts about the PR |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
If you want, I can:
🏁 Script executed: Length of output: 785
Once the results come back, I’ll summarize notable findings and any potential follow-ups (e.g., missing theme plugin declarations, safe colorscheme application, transparency toggle). 🏁 Script executed: Length of output: 772
Would you like me to:
🏁 Script executed: Length of output: 6153
Potential follow-ups to consider
If you’d like, I can:
🏁 Script executed: Length of output: 1313
Example hardening snippet you can drop into after/plugin/theme.lua: local function safe_colorscheme(name, fallback)
local ok = pcall(vim.cmd.colorscheme, name)
if not ok and fallback then
vim.notify(("Colorscheme '%s' not found. Falling back to '%s'."):format(name, fallback), vim.log.levels.WARN)
pcall(vim.cmd.colorscheme, fallback)
end
end
local function apply_theme_for_terminal()
local preferred = vim.g.theme or vim.env.NVIM_THEME
local term_program = vim.env.TERM_PROGRAM or ""
local theme = preferred or (term_program == "iTerm.app" and "deus" or "duskfox")
safe_colorscheme(theme, "deus")
if vim.env.NVIM_TRANSPARENT == "1" or vim.g.transparent then
enableTransparency()
end
endWould you like me to:
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Unrecoverable error: Request timed out after 300000ms (requestId=d9e5248f-5ed8-4623-b0fb-9b404675ae94) 🏁 Script executed: Length of output: 8040
Key facts from after/plugin/theme.lua
Related files and plugins
Repo stats and housekeeping
Suggestions
If you want, I can also:
Would you like me to run those checks now? |
|
@coderabbitai clone the repo and share me repo size |
|
Oops, something went wrong! Please try again later. 🐰 💔 |
|
@coderabbitai clone the repo and share me repo size |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Unrecoverable error: Request timed out after 300000ms (requestId=c67dbdef-da8e-40fc-a690-ee30b9ffcc8d)
🏁 Script executed: Length of output: 511
If you want, I can also fetch the GitHub-reported repo size (diskUsage) or break this down by top-level directories. |
6d3974b to
9fe4bb5
Compare
|
@coderabbitai clone thy repo and give me some stats |
11 similar comments
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
@coderabbitai clone thy repo and give me some stats |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Unrecoverable error: Request timed out after 300000ms (requestId=5cc5705b-c44d-4cb0-852d-50ee3f774ab9)
🏁 Script executed: Length of output: 445
Want a deeper breakdown (largest files, top-level directory sizes, unique authors, or TODO/FIXME counts)? I can run that next. |
Added functions to enable transparency and apply themes based on terminal.