-
Notifications
You must be signed in to change notification settings - Fork 0
Implement theme and transparency functions #24
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
base: master
Are you sure you want to change the base?
Conversation
Added functions to enable transparency and apply themes based on terminal.
📝 WalkthroughWalkthroughIntroduces terminal-aware theme selection in 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @after/plugin/theme.lua:
- Around line 49-57: Wrap each vim.cmd.colorscheme call in a protected call
(pcall) inside apply_theme_for_terminal and provide a safe fallback theme if the
requested scheme isn't installed; specifically, when applying "deus" or
"duskfox" via vim.cmd.colorscheme, call it with pcall and on failure call
vim.cmd.colorscheme again with a known-safe fallback (e.g., "default" or another
bundled theme) so missing themes won't error and break startup.
🧹 Nitpick comments (1)
after/plugin/theme.lua (1)
1-47: Apply transparency after:colorscheme(and re-apply onColorScheme) to avoid being overwritten.Right now
enableTransparency()(even if uncommented) is called in the same branch aftervim.cmd.colorscheme("duskfox")(good), but it won’t persist if the user changes colorscheme later, and the function mixes"none"/"NONE"plus hard-codedfgthat may clash across themes.Proposed refactor: make transparency consistent + auto re-apply
local function enableTransparency() - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + 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, "LineNr", { bg = "none", fg = "#5c6370" }) + -- Consider avoiding hard-coded fg so it adapts to theme palettes + vim.api.nvim_set_hl(0, "LineNr", { bg = "NONE" }) @@ end + +local function setup_transparency_autocmd() + local group = vim.api.nvim_create_augroup("ThemeTransparency", { clear = true }) + vim.api.nvim_create_autocmd("ColorScheme", { + group = group, + callback = enableTransparency, + }) +end
📜 Review details
Configuration used: Environment YAML
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
after/plugin/theme.lua
🔇 Additional comments (1)
after/plugin/theme.lua (1)
59-59: Nice simple entrypoint; consider keeping it idempotent if sourced multiple times.Direct invocation is fine in
after/plugin/*; just ensure any future additions (e.g., autocmd creation) use augroups/clear to avoid duplicates.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard vim.cmd.colorscheme(...) with pcall + fallback to prevent startup/config breakage when a theme isn’t installed.
If deus or duskfox isn’t available, this will throw and stop sourcing this plugin file.
Proposed fix: safe theme selection with fallback
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
+ local ok = false
+ if term_program == "iTerm.app" then
+ ok = pcall(vim.cmd.colorscheme, "deus")
+ else
+ ok = pcall(vim.cmd.colorscheme, "duskfox")
+ end
+
+ if not ok then
+ pcall(vim.cmd.colorscheme, "default")
+ end
+
+ -- If you want transparency, call it here so it always runs after colorscheme:
+ -- enableTransparency()
end🤖 Prompt for AI Agents
In @after/plugin/theme.lua around lines 49 - 57, Wrap each vim.cmd.colorscheme
call in a protected call (pcall) inside apply_theme_for_terminal and provide a
safe fallback theme if the requested scheme isn't installed; specifically, when
applying "deus" or "duskfox" via vim.cmd.colorscheme, call it with pcall and on
failure call vim.cmd.colorscheme again with a known-safe fallback (e.g.,
"default" or another bundled theme) so missing themes won't error and break
startup.
Added functions to enable transparency and apply themes based on terminal.