Skip to content
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

AstroUI config doesn't include the user config when extending heirline #14

Closed
3 tasks done
lougreenwood opened this issue Apr 10, 2024 · 5 comments
Closed
3 tasks done
Labels
bug Something isn't working can't replicate stale

Comments

@lougreenwood
Copy link

lougreenwood commented Apr 10, 2024

Checklist

  • I have searched through the AstroNvim docs
  • I have searched through the existing issues of AstroNvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.5

Operating system/version

macOS 14.4.1

Terminal/GUI

iTerm

Describe the bug

❗ I need to do some more investigation and narrow down a reproduction, so this issue is preliminary for now.

The issue I'm facing is related to porting my custom tab pages heirline config to V4. I get the following error:

Screenshot 2024-04-09 at 15 29 56

If I print the contents of config from file_icon in astroui/status/hl on line 68, like this:

function M.file_icon(name)
  print(vim.inspect(config))
  local hl_enabled = config.icon_highlights.file_icon[name]
  return function(self)
    if hl_enabled == true or (type(hl_enabled) == "function" and hl_enabled(self)) then
      return M.filetype_color(self)
    end
  end
end

I see that the config is empty:
Screenshot 2024-04-10 at 17 18 29.

This is wrong, since I have the following config for astroui:

return {
  "AstroNvim/astroui",
  ---@type AstroUIOpts
  opts = {
    -- change colorscheme
    colorscheme = "dracula",
    -- AstroUI allows you to easily modify highlight groups easily for any and all colorschemes
    highlights = {
      init = { -- this table overrides highlights in all themes
        -- Normal = { bg = "#000000" },
      },
      astrotheme = { -- a table of overrides/changes when applying the astrotheme theme
        -- Normal = { bg = "#000000" },
      },
    },
    status = {
      -- Configure attributes of components defined in the `status` API. Check the AstroNvim documentation for a complete list of color names, this applies to colors that have `_fg` and/or `_bg` names with the suffix removed (ex. `git_branch_fg` as attributes from `git_branch`).
      attributes = {
        git_branch = { bold = true },
      },
      -- Configure colors of components defined in the `status` API. Check the AstroNvim documentation for a complete list of color names.
      colors = {
        git_branch_fg = "#ABCDEF",
      },
      -- Configure which icons that are highlighted based on context
      icon_highlights = {
        -- enable or disable breadcrumb icon highlighting
        breadcrumbs = false,
        -- Enable or disable the highlighting of filetype icons both in the statusline and tabline
        file_icon = {
          tabline = function(self) return self.is_active or self.is_visible end,
          statusline = true,
        },
      },
      -- Configure characters used as separators for various elements
      separators = {
        none = { "", "" },
        left = { "", "  " },
        right = { "  ", "" },
        center = { "  ", "  " },
        tab = { "", "" },
        breadcrumbs = "",
        path = "",
      },
    },
    -- Icons can be configured throughout the interface
    icons = {
      -- configure the loading of the lsp in the status line
      LSPLoading1 = "",
      LSPLoading2 = "",
      LSPLoading3 = "",
      LSPLoading4 = "",
      LSPLoading5 = "",
      LSPLoading6 = "",
      LSPLoading7 = "",
      LSPLoading8 = "",
      LSPLoading9 = "",
      LSPLoading10 = "",
    },
  },
}

If I modify hl.lua on line 12, so that the definition of config becomes an inline function - resulting in the config is always re-evaluated, I see that the expected value, like this:

local config = function() return assert(require("astroui").config.status) end

and update uses of config to config(), I see the expected values when I print config from file_icon:
Screenshot 2024-04-10 at 17 25 33

Converting to a function also fixes the error shown at the start of this issue, since config().icon_hightlights.file_icon[name] in hl.lua now has a valid value.

This feels like a timing issue, but I see that astroui has a priority of 1000 and is lazy = false, so I'd expect it to be already setup and ready to go by the time that I use it via my heirline config.

I'll try to debug some more later and narrow this down to a repro and update this issue - I just needed to get this out whilst I had the motivation to write it up!

Steps to Reproduce

todo

Expected behavior

n/a

Screenshots

No response

Additional Context

No response

Repro

No response

@lougreenwood lougreenwood added the bug Something isn't working label Apr 10, 2024
@mehalter mehalter transferred this issue from AstroNvim/AstroNvim Apr 10, 2024
@mehalter
Copy link
Member

Investigating now, in the meantime I moved this to the correct repository

@mehalter
Copy link
Member

@lougreenwood can you please provide a minimal reproduction repro.lua that gets to this error? That will greatly help me in debugging. You can take a look at the template when opening a new issue on AstroNvim since I see that you deleted the one provided by default

@mehalter
Copy link
Member

Upon an initial investigation I cannot replicate this at all

@mehalter
Copy link
Member

Basically all of those modules are loaded post setup() call and therefore the config should be set fully before any of this code is running. We don't want to re-evaluate the config each time if that makes sense

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label May 17, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working can't replicate stale
Projects
None yet
Development

No branches or pull requests

2 participants