Skip to content
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

Provide custom palette directly to neogit #153

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

gldtn
Copy link
Contributor

@gldtn gldtn commented Dec 20, 2024

@@ -5,28 +5,34 @@ local M = {}
--- @param t CyberdreamPalette
function M.get(opts, t)
opts = opts or {}
local neogit = require("neogit")
Copy link
Owner

Choose a reason for hiding this comment

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

We need to check if neogit can be loaded before we try to require it. If you don't have the plugin installed, it breaks cyberdream:

Failed to run `config` for cyberdream.nvim

vim/_editor.lua:0: /home/scott/git/nix/nvim/init.lua..nvim_exec2() called at /home/scott/git/nix/nvim/init.lua:0../home/scott/git/cyberdream.nvim/colors/cyberdream.lua: Vim(colorscheme):E5113: Error while calling lua chunk: ...git/cyberdream.nvim/lua/cyberdream/extensions/neogit.lua:8: module 'neogit' not found:
	no field package.preload['neogit']
Suggested change
local neogit = require("neogit")
if not package.loaded["neogit"] then
return {}
end
local neogit = require("neogit")

@scottmckendry
Copy link
Owner

scottmckendry commented Dec 20, 2024

Hey @gldtn!

Thanks for your PR 🙂

Aside from the issue with the require, I'm really liking how this looks. Though I would prefer a scenario where we don't have to make any extra require calls to external plugins.

neogit.setup() worries me most since I'd imagine most people will be lazy-loading Neogit, and colourshemes are always the first plugin that neovim has to load. This will be slowing down cyberdream's load times quite a bit, I'd imagine.

Is there any reason why using the built-it Neogit highlight groups isn't an option here?

@gldtn
Copy link
Contributor Author

gldtn commented Dec 20, 2024

Is there any reason why using the built-it Neogit highlight groups isn't an option here?

The whole reason I changed to the built-in hl groups was to not have to set each group individually and let neogit take care of the rest by simply passing cyberdream colors to it.

I did not think about the possible loading issues as you described above. I believe in order to not require neogit I would maybe have to somewhat replicate some of the items in the hl_store = {} table defined here: https://github.com/NeogitOrg/neogit/blob/0820552997dd4dda4faa147228f0e61ea88290a3/lua/neogit/lib/hl.lua#L152

Let me see what I can come up with when I get home today and I'll give you an update.

@scottmckendry
Copy link
Owner

You could use Cattpuccin's implementation as a reference:

https://github.com/catppuccin/nvim/blob/f8a155ab5891c5d2fb709b7e85627f1783d5a5d9/lua/catppuccin/groups/integrations/neogit.lua

You probably won't need to define all highlight groups; most default links should be fine to leave as is.

They use darken & lighten helpers for darker and lighter colours for backgrounds etc.

If you want to do something similar you can use blend. There's an example of this here:

https://github.com/scottmckendry/cyberdream.nvim/blob/731290012f435e06e4d5d64ed7c09cec49df2663/lua/cyberdream/extensions/markdown.lua

@gldtn
Copy link
Contributor Author

gldtn commented Dec 21, 2024

This removes .setup() call. Overall Neogit should look much cleaner with this update.

Question, when you set Cyberdream with transparent = true, does fg becomes white if set to t.bg on your terminal? Or is this a normal behavior in Neovim? I'm assuming Cyberdream sets bg to "NONE" if transparency is enabled.

For example:
NeogitCommitViewHeader = { bg = t.cyan, fg = t.bg }

To avoid this I set it to t.bg_solid

I noticed this behavior when customizing my fzf-lua/telescope, I can open a issue to show screenshots if necessary.

Thanks!

@scottmckendry scottmckendry merged commit 2ee87ea into scottmckendry:main Dec 22, 2024
5 checks passed
@scottmckendry
Copy link
Owner

Great stuff @gldtn 🙂 thanks again for contributing to the project!

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.

2 participants