Skip to content

access getCurrentTheme() during globalAfter #47

@goeil

Description

@goeil

Hello all,
Thank for your Themery plugin, very kind.

I'm facing issue when trying to access currentTheme in a function launched on globalAfter hook.

return {
  {
    "zaldih/themery.nvim",
    lazy = false,
    config = function()
      _G.setTransparent = function()
          local ok, themery = pcall(require, "themery")
          if ok and themery and type(themery.getCurrentTheme) == "function" then
          local curtheme = themery.getCurrentTheme()
          if curtheme and curtheme.name then
            vim.print("Mon thème actuel : " .. curtheme.name)
        end
      end

      -- I'd like to use here the variable curtheme.name in a if condition
      vim.cmd("highlight Normal guibg=none")
      vim.cmd("highlight NonText guibg=none")
      vim.cmd("highlight Normal ctermbg=none")
      vim.cmd("highlight NonText ctermbg=none")
    end

    require("themery").setup({
      themes = {
        "gruvbox",
        …
      },
      globalAfter = [[
          setTransparent()
        ]]

The problem is that my theme does not switch. It does when I remove the first part of my setTransparent function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions