Skip to content

feat: add NormalFloat hl for floating windows #2167

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 6 commits into from
May 6, 2023
Merged

feat: add NormalFloat hl for floating windows #2167

merged 6 commits into from
May 6, 2023

Conversation

jamestansx
Copy link
Contributor

Currently, NvimTreeNormal is used for floating window's background. However, when winblend is set and Normal highlight is set to transparent, the background will turn black. Using NormalFloat allows users to customize the background and not interfere with normal window.

minimal init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      --"jamestansx/nvim-tree.lua",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      { "catppuccin/nvim", as = "catppuccin" }
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true
vim.opt.winblend = 10

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
---@diagnostic disable-next-line: duplicate-set-field
_G.setup = function()
  -- run help with `g?` key or enable float
  -- to see the background color in black
  require("nvim-tree").setup {}

  require("catppuccin").setup({
    transparent_background = true, -- to set Normal to transparent
    integrations = {
      nvimtree = false, -- to ensure that no hl is changed by catppuccin
    }
  })
  vim.cmd.colorscheme "catppuccin"
end

@alex-courtis
Copy link
Member

alex-courtis commented Apr 30, 2023

There's a regression with the sign column and help window placement. Tested clean under 0.8.3

master:
20230430_134055
20230430_134115

branch:
20230430_134216
20230430_134223

@alex-courtis
Copy link
Member

I'm aware of some breaking changes for floating window backgrounds under nvim 0.9.0.

Parity between branch and master under 0.9.0 is good enough.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Looking good; we need to ensure default behaviour is unchanged.

@jamestansx
Copy link
Contributor Author

Noted, I have fixed it. You can refer to the following screenshots.

SignColumn:
image

Help window:
image

Float Window:
image

@jamestansx jamestansx requested a review from alex-courtis April 30, 2023 07:11
Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Many thanks for your contribution

@alex-courtis alex-courtis merged commit 98b76ff into nvim-tree:master May 6, 2023
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