I'm trying to incorporate this library into my own plugin, but with the following file.
local function tonode(themes)
local nodes = {}
for _, theme in pairs(themes) do
local node = n.option(theme, { name = theme })
table.insert(nodes, node)
end
return nodes
end
-- TODO: let create_renderer to take in a function or a table of acceptable values
local renderer = n.create_renderer({
width = 40,
height = vim.api.nvim_win_get_height(0),
relative = "editor",
-- position starts from the left corner
position = {
row = 0,
col = vim.api.nvim_win_get_width(0) - 3,
},
})
local body = n.columns(n.rows(
{ flex = 2 },
n.prompt({
autofocus = true,
prefix = " ::: ",
size = 1,
border_label = {
text = " Huez",
align = "center",
},
}),
n.select({
flex = 1,
autofocus = false,
border_label = "Themes",
data = tonode(api.get_installed_themes(vim.g.huez_config.exclude)), -- this api call return's a list of strings which are then cast to nodes
on_change = function(theme)
vim.cmd("colorscheme " .. theme.name)
end,
on_select = function(theme)
api.save_colorscheme(theme.name) -- <--- the problem is here, and I've already tested that this api call works as intended in my testing suite.
renderer:close()
utils.log_info("Selected " .. theme.name)
end,
})
))
The on_change function works completely fine giving me the impression that theme.name is not nil. BUT when I select a color scheme, the on_select function will print me theme.name prints nil, I have already tested that my api's work, I'm wondering if there's anything I'm doing that's particularly wrong.
steps to reproduce
create a function strings that returns a list of strings
create a function to_node that takes in a list of strings as a arg and converts each string to a n.option returning an array of NuiTreeNodes
copy paste the above code and replace data = ... with data = to_node(strings)
I'm trying to incorporate this library into my own plugin, but with the following file.
The
on_change
function works completely fine giving me the impression that theme.name is not nil. BUT when Iselect
a color scheme, theon_select
function will print metheme.name
prints nil, I have already tested that my api's work, I'm wondering if there's anything I'm doing that's particularly wrong.steps to reproduce
strings
that returns a list of stringsto_node
that takes in a list of strings as a arg and converts each string to an.option
returning an array ofNuiTreeNodes
data = ...
withdata = to_node(strings)