rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
2.97k stars 78 forks source link

error: set termguicolors...but it is set! #153

Closed gennaro-tedesco closed 1 year ago

gennaro-tedesco commented 1 year ago

Somewhat related to https://github.com/rcarriga/nvim-notify/issues/122: in correspondence of styles fade and fade_in_slide_out I get the exception

Opacity changes require termguicolors to be set.
Change to different animation stages or set termguicolors to disable this warning

although the variable termguicolors is set.

verbose set termguicolors?

  termguicolors
    Last set from ~/.config/nvim/plugin/settings.vim line 6

and

echo &termguicolors = 1

I am running nvim on iTerm2 with zsh (if it matters), and I get the error even with a minimal configuration for notify without any other plugin (except my colorscheme).

How can I debug the error to provide more details?

rcarriga commented 1 year ago

Can you provide the minimal configuration that you're using to test so that I can reproduce? Should be easy to track down the issue with

gennaro-tedesco commented 1 year ago

I have reduced it to the following minimal configuration:

call plug#begin('~/.config/nvim/plugged')

Plug 'rcarriga/nvim-notify'
Plug 'lifepillar/vim-solarized8'

call plug#end()

" colour scheme
set termguicolors
set background=dark
colorscheme solarized8_flat

and with notify setup being

notify.setup({
    timeout = 5000,
    render = "minimal",
    stages = "fade",
})

Do you think it can be a matter of terminal emulator as well?

rcarriga commented 1 year ago

That's not a minimal init file

I can't reproduce with this nvim --clean -u minimal.lua

-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.stdpath("config"))
vim.opt.packpath:remove(vim.fn.stdpath("data") .. "/site")

-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
  vim.cmd("packadd packer.nvim")
  install_plugins = true
end

local packer = require("packer")

packer.init({
  package_root = test_dir .. "/pack",
  compile_path = test_dir .. "/plugin/packer_compiled.lua",
})

packer.startup(function(use)
  use("wbthomason/packer.nvim")

  use({
    "rcarriga/nvim-notify",
    config = function()
      require("notify").setup({
        timeout = 5000,
        render = "minimal",
        stages = "fade",
      })
    end,
  })
  use({
    "lifepillar/vim-solarized8",
    config = function()
      vim.cmd([[colorscheme solarized8_flat]])
    end,
  })

  if install_plugins then
    packer.sync()
  end
end)

vim.opt.termguicolors = true
vim.opt.background = "dark"
gennaro-tedesco commented 1 year ago

Interestingly enough I am observing the following:

Perhaps packer defers some settings (i. e. termguicolors) before/after some calls (don't know exactly) and vim-plug doesn't, which is why in the former case they are fine and in the latter they are not? 🤔

rcarriga commented 1 year ago

Packer works by adding a file to the runtimepath that is loaded after the init.lua so the entire init file is run before any plugin config, whereas I believe vim-plug will run the plugin configs as they are specified in the init so yes it is likely an ordering issue. I'd say try setting termguicolors at the start of your init file and see if that solves it

gennaro-tedesco commented 1 year ago

You are perfectly right: setting set termguicolors at the very beginning of the init file fixed it. I didn't know how these settings are added to the runtime, great to understand it now, thank you!