AndreM222 / copilot-lualine

This is a component which makes a status icon for copilot.lua
MIT License
59 stars 3 forks source link

fix(customization): allow selective override of component options #1

Closed Lysander6 closed 10 months ago

Lysander6 commented 10 months ago

Firstly, I would like to preface this by saying that I may lack some context and the proposed change may be completely misguided, as I lack expertise in both Neovim and Lua, but it seems to solve a problem I was having.

What I was trying to do when configuring this module is simply override the colour of the active/enabled state icon, leaving the rest same as the default options. When I tried this, I couldn't do this without also providing all the other options (icons, etc), as an error was thrown saying that basically the enabled property can't be read from the icons attribute, which is nil here if options.symbols.status.icons.enabled then.

The code removed in this commit forced the user to specify all options of the component, even if they only wanted to override a single specific setting. This case seems to be handled by the vim.tbl_deep_extend already present in this part of the code.

Now the following customization is possible:

lualine_x = {
  {
    "copilot",
    symbols = {
      -- no need to specify icons, etc.
      status = {
        hl = {
          enabled = "#74c7ec",
        },
      },
    },
  },
  "progress",
  "location",
},