echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.45k stars 171 forks source link

How to load 3rd party colour schemes to properly override default highlight rules? #996

Closed suliatis closed 5 days ago

suliatis commented 5 days ago

Contributing guidelines

Module(s)

mini.deps

Description

I have a mini.nvim based configuration with the github-nvim-theme. When I overrode certain highlight groups of mini.nivm those doesn't seem to apply until I source my init.lua.

Neovim version

0.10.0

Steps to reproduce

Here is my init.lua to reproduce:

local path_package = vim.fn.stdpath 'data' .. '/site'
local mini_path = path_package .. '/pack/deps/start/mini.nvim'
if not vim.loop.fs_stat(mini_path) then
  vim.cmd 'echo "Installing `mini.nvim`" | redraw'
  local clone_cmd = {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/echasnovski/mini.nvim',
    mini_path,
  }
  vim.fn.system(clone_cmd)
  vim.cmd 'packadd mini.nvim | helptags ALL'
end

local MiniDeps = require 'mini.deps'
MiniDeps.setup { path = { package = path_package } }
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later

add { source = 'projekt0n/github-nvim-theme' }
now(function()
  local github_theme = require 'github-theme'
  github_theme.setup {
    options = {
      transparent = true,
    },
    groups = {
      all = {
        MiniTablineHidden = { bg = 'None' },
        MiniTablineFill = { bg = 'None' },
        MiniPickNormal = { bg = 'None' },
      },
    },
  }
  vim.cmd.colorscheme 'github_light'
end)

now(function()
  require('mini.basics').setup {
    options = {
      extra_ui = true,
    },
  }
end)

now(function()
  local MiniPick = require 'mini.pick'
  MiniPick.setup {
    mappings = {
      scroll_left = '',
      delete_char = '<C-h>',
    },
  }
  vim.ui.select = vim.schedule_wrap(MiniPick.ui_select)

  vim.keymap.set('n', '<leader>f', function()
    MiniPick.builtin.cli({
      command = { 'fd', '--hidden', '--type', 'f', '--type', 'd', '--exclude', '.git' },
    }, {
      source = {
        name = 'Files & Dirs',
        show = function(buf_id, items, query)
          MiniPick.default_show(buf_id, items, query, { show_icons = true })
        end,
        choose = vim.schedule_wrap(MiniPick.default_choose),
      },
    })
  end, { desc = 'Pick file or dir' })
end)

Expected behavior

If I source my init.lua again, then get the expected look.

Screenshot 2024-06-29 at 9 49 19 AM

Actual behavior

The picker has grey background though I set it to be none. I had similar experience with mini.tabline, but overriding highlight groups for mini.hipatterns or mini.diff work as epxpected.

Screenshot 2024-06-29 at 9 49 02 AM
echasnovski commented 5 days ago

Thanks for the issue!

It seems that setting { bg = 'None' } in groups.all clears highlight group, which means require('mini.pick').setup() creating default highlighting actually affects MiniPickNormal (links it to NormalFloat). I am not sure why sourcing the second time changes this behavior, but I'd guess it has something to do with 'github-nvim-theme' compiling its highlight groups.

Setting up 'mini.pick' before color scheme seems to fix this behavior, but it seems that the proper fix is on color scheme side.

I am mostly positive that this has nothing to do with 'mini.deps' (completely removing it from 'init.lua' has same effect) or 'mini.pick' (creating default highlight groups is the proper way of setting them up). Closing as "most certainly not an issue with 'min.nvim'".

suliatis commented 5 days ago

Thank you. I moved setting up the colorscheme to the end of my init.lua and it works just fine.