Fix: Handle table values in highlight options properly #428 #390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the #428 issue
The plugins actually doesn't work properly in anywhere neither windows, nor WSL. It works only for the first time after the plugin installs(not just with volt theme switcher but also in case of
Telescope themes
).The problem was in the
init.lua
insidelua/base46
directory of thebase46
plugin.The old
tb_2str
function -As far as I understand, this function converts a highlight group table into a string of
nvim_set_hl
commands.The problem is that some highlight options (like link) can have table values, and the current code tries to concatenate them as strings.
This is the original code, which tried to concatenate a table directly, which is not allowed in Lua.
So, I corrected the function definition to properly convert highlight table to string even if the tables has some table values as properties.
This is the new function definition -
The new
tb_2str
checks for thetable
type and iterates through the table's key-value pairs, formatting them into a string representation suitable fornvim_set_hl
.Thus the PR has resolved the "attempt to concatenate local 'optVal' (a table value)" error and restores the functionality of theme switching and other features relying on highlight linking.
I have tested this code in both Windows 11 and WSL. Works like a charm.
Now base46 theme changing works with both Telescope and volt theme picker plugins.
Kindly review the changes whether this solution is viable for merging.
Thanks in advance,
2025-02-16.04-02-25.mp4