Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-again committed Jul 15, 2024
1 parent 772aa0e commit ea3f760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
16 changes: 4 additions & 12 deletions lua/wezterm-config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,14 @@ function M.set_wezterm_user_var(name, value)
end

local value_type = type(value)
local value_tbl
local value_out
if value_type == 'boolean' or value_type == 'number' then
value = tostring(value)
-- value_tbl = vim.json.encode({
-- value = value,
-- })
value_tbl = vim.json.encode(value)
-- elseif value_type == 'table' then
value_out = vim.json.encode(tostring(value))
else
-- NOTE: remember that config.background is like { { source = { File = '...' } }, ... }
-- looks like the outermost pair(s) of curly braces get converted/interpreted as array []
-- by vim.json.encode()
-- actually it seems to work without the gsub...
-- value_tbl = vim.json.encode({ value = value })
value_tbl = vim.json.encode(value)
-- value = string.gsub(value, '[%[%]]', '')
value_out = vim.json.encode(value)
end

-- NOTE: v0.10 adds vim.version.ge() and vim.version.le() so shouldn't use it yet since v0.10 isn't out
Expand Down Expand Up @@ -112,7 +104,7 @@ function M.set_wezterm_user_var(name, value)
end

local stdout = uv.new_tty(1, false)
local value_b64_enc = base64.encode(value_tbl)
local value_b64_enc = base64.encode(value_out)

-- people have asked Wez about stuff like this before, to which he's linked
-- https://wezfurlong.org/wezterm/recipes/passing-data.html
Expand Down
6 changes: 0 additions & 6 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ function M.override_user_var(overrides, name, value)
-- returns tbl if successfully parsed
-- otherwise it returns 1 (?) so I guess an error code or at least
-- something with type == 'number'

-- local ok, parsed_val = pcall(wezterm.json_parse, value)
local parsed_val = wezterm.json_parse(value)
-- if type(parsed_val) == 'table' then
-- parsed_val = parsed_val.value
-- end

if type(parsed_val) == 'table' then
overrides[name] = parsed_val
else
Expand Down

0 comments on commit ea3f760

Please sign in to comment.