Skip to content

Commit

Permalink
fix: color float window border background (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
vollowx committed Jun 27, 2024
1 parent 6827a67 commit 31fcfb0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/catppuccin/groups/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function M.get()
}, -- normal text in non-current windows
NormalSB = { fg = C.text, bg = C.crust }, -- normal text in non-current windows
NormalFloat = { fg = C.text, bg = (O.transparent_background and vim.o.winblend == 0) and C.none or C.mantle }, -- Normal text in floating windows.
FloatBorder = { fg = C.blue },
FloatBorder = { fg = C.blue, bg = (O.transparent_background and vim.o.winblend == 0) and C.none or C.mantle },
FloatTitle = { fg = C.subtext0 }, -- Title of floating windows
Pmenu = {
bg = (O.transparent_background and vim.o.pumblend == 0) and C.none or U.darken(C.surface0, 0.8, C.crust),
Expand Down

11 comments on commit 31fcfb0

@boatnoah
Copy link

Choose a reason for hiding this comment

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

I get these weird borders around my telescope

Screenshot:

Before:

Screenshot 2024-07-03 at 1 48 56 AM

After:

@vollowx
Copy link
Collaborator Author

@vollowx vollowx commented on 31fcfb0 Jul 3, 2024

Choose a reason for hiding this comment

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

@boatnoah Sorry for this, I'm not using telescope.nvim and didn't notice this commit is breaking its appearance. Besides, #726 probably fixes this problem.

@boatnoah
Copy link

Choose a reason for hiding this comment

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

@boatnoah Sorry for this, I'm not using telescope.nvim and didn't notice this commit is breaking its appearance. Besides, #726 probably fixes this problem.

haha no worries! thanks for the quick reply.

@opalmay
Copy link
Contributor

@opalmay opalmay commented on 31fcfb0 Jul 6, 2024

Choose a reason for hiding this comment

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

Its not a telescope specific problem. It's affecting other floating windows, at least with rounded borders. (for example, cmp completions)

@yujinyuz
Copy link

Choose a reason for hiding this comment

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

My god. I've been figuring out for hours why my floating terminals have random borders
Screenshot 2024-07-07 at 19 38 32

@vollowx
Copy link
Collaborator Author

@vollowx vollowx commented on 31fcfb0 Jul 7, 2024

Choose a reason for hiding this comment

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

Sorry guys, though this's considered to be a bug fix, it now seems to be bringing more bugs than fixes... I'm going to revert this commit and maybe apply this some other time with more checks.

@yujinyuz
Copy link

Choose a reason for hiding this comment

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

@vollowx no worries.

I also tested it with tokyonight theme and I was having the same issue with the borders..

@vollowx
Copy link
Collaborator Author

@vollowx vollowx commented on 31fcfb0 Jul 7, 2024

Choose a reason for hiding this comment

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

I guess this is a more complex problem to be solved. There are 2 choices for 3 preferences:

  1. Floating window background: yes/no
  2. Floating window border: yes/no
  3. Floating window border with the same background from the window: yes/no

Maybe there should be options to control this as not all the users know/want to customize the highlight manually by themselves...

@igorlfs
Copy link
Contributor

@igorlfs igorlfs commented on 31fcfb0 Jul 7, 2024

Choose a reason for hiding this comment

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

I was surprised this was merged, since there has been some discussion in the past (see #347 and #313)

Personally, I think we should usually opt for a darker background (Mantle) for floating windows. The need for borders usually arises when a floating window's background matches the default background (there are other use cases, of course). This was the original complaint in #347 (user with no borders, complaining about matching background making stuff indistinguishable).

When a user desires borders, having a darker background for floating windows would also make the usage of a darker background for borders more desirable. The complaints here were that the backgrounds didn't match, not the darker background (for the border) itself. Changing every floating window background would be a "breaking change", though.

There are other use cases for the borders, and some cases require some adjustments. For instance, with this commit, I had to add this snippet to my nvim-cmp config:

window = {
    documentation = {
        border = "rounded",
        winhighlight = "Normal:NormalFloat",
    },
},

If we don't introduce an option, I think this compromise of having darker backgrounds would make most users happy.

@KodyVB
Copy link

@KodyVB KodyVB commented on 31fcfb0 Jul 8, 2024

Choose a reason for hiding this comment

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

I might be too late in posting this, but when the first merge happened I was wondering the same about Telescope and after searching for a bit too long, I found out that I had to set Telescope's normal highlight to be a normal float color while configuring Telescope:

vim.api.nvim_set_hl(0, "TelescopeNormal", { link = "NormalFloat" })

As far as my use cases went (using Mason, Lazy, and Telescope), that gave me a consistent look and feel where the border and float background were both dark.

But now that it was reverted, I went back to my old way of setting:

vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })

So now, Mason, Lazy, and Telescope all match the border's background color (which is not dark).

Not sure if that helps anything, but that's what I wound up doing for both the previous and current situations since I dislike having the mismatch between border and floating window background colors.

@vollowx
Copy link
Collaborator Author

@vollowx vollowx commented on 31fcfb0 Jul 8, 2024

Choose a reason for hiding this comment

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

@KodyVB Yeah that's the conflict: this PR not only fix some's preferred UI (e.g. border option: solid), but also breaks someone's (e.g. only border without a bg).

There should be a option that allow users to configure floating window UI in one place, which meets most user's need. Like fwindows = { border_color = 'blue', bg = false }, the bg controls both the background of border and the window. This might give users a easier and more intuitive way than using custom_highlights.

Besides just as I have mentioned, catppuccin.nvim does support customizing highlights. If you dislike the pre-provided highlights, you can define some by yourself, and they will override the pre-provided ones, so that you no longer need to do nvim_set_hls nor bear unexpected UI changes from the plugin.

Please sign in to comment.