michaelbrusegard / tabline.wez

A versatile and easy to use retro tab bar plugin for the WezTerm terminal emulator created with the lualine.nvim configuration format
MIT License
42 stars 5 forks source link

Only adding extentions to setup() causes error #16

Closed MLFlexer closed 1 month ago

MLFlexer commented 1 month ago

With this minimal config:

local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")
config.use_fancy_tab_bar = false
tabline.setup({ extensions = { "resurrect" } })

I get the following error:

runtime error: ...chaelbrusegardsZstablinesDswez/plugin/tabline/
config.lua:128: attempt to index a nil value (field 'options')
stack traceback:
        ...chaelbrusegardsZstablinesDswez/plugin/tabline/config.lua:128: in function
'tabline.config.set'
        ...DscomsZsmichaelbrusegardsZstablinesDswez/plugin/init.lua:35: in function
'httpssCssZssZsgithubsDscomsZsmichaelbrusegardsZstablinesDswez.setup'
        [string "/home/mlflexer/.config/wezterm/wezterm.lua"]:149: in main chunk

It looks like it is expecting the field options to be defined, but it is nil in this case.

It would be great if there was a nil check, or if the example in the readme was changed.

michaelbrusegard commented 1 month ago

Yea this was an oversight. I thought it was handled but as you can see it is not:

function M.set(user_opts)
  user_opts = user_opts or { options = {} }
  local color_overrides = user_opts.options.color_overrides or {}
  user_opts.options.color_overrides = nil

  M.component_opts = set_component_opts(user_opts)
  M.opts = util.deep_extend(default_opts, user_opts)
  M.sections = util.deep_copy(M.opts.sections)
  M.colors = util.deep_extend(get_colors(M.opts.options.theme), color_overrides)
end

will get a fix out

michaelbrusegard commented 1 month ago

Thanks for the bug report. Your minimal config should now work correctly