Skip to content

Commit ff3d73e

Browse files
committed
Merge remote-tracking branch 'origin/feature/font-support' into feature/font-support
2 parents 2c26b3c + 782f0c8 commit ff3d73e

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

plugin/init.lua

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
-- https://github.com/wez/wezterm/issues/4533#issuecomment-1874094722
44
-- is there a better alt?
55
if vim ~= nil then
6-
return
6+
return
77
end
88

9-
local wezterm = require('wezterm')
9+
local wezterm = require("wezterm")
1010
local M = {}
1111

12+
local function trim_quotes(s)
13+
return (s or ""):gsub("^['\"](.-)['\"]$", "%1")
14+
end
15+
1216
---@param var string
1317
---@return boolean
1418
local function is_shell_integ_user_var(var)
15-
local shell_integ_user_vars = {
16-
'WEZTERM_PROG',
17-
'WEZTERM_USER',
18-
'WEZTERM_HOST',
19-
'WEZTERM_IN_TMUX',
20-
}
21-
for _, val in ipairs(shell_integ_user_vars) do
22-
if val == var then
23-
return true
24-
end
25-
end
26-
return false
19+
local shell_integ_user_vars = {
20+
WEZTERM_PROG = true,
21+
WEZTERM_USER = true,
22+
WEZTERM_HOST = true,
23+
WEZTERM_IN_TMUX = true,
24+
}
25+
return shell_integ_user_vars[var] == true
2726
end
2827

2928
---Interpret the Wezterm user var that is passed in and
@@ -52,8 +51,22 @@ function M.override_user_var(overrides, name, value)
5251
end
5352
overrides[name] = parsed_val
5453
end
55-
end
5654
return overrides
55+
56+
if name == "font" then
57+
local cleaned = trim_quotes(value)
58+
local success, font_obj = pcall(wezterm.font, cleaned)
59+
if success and font_obj then
60+
if font_obj.font and font_obj.font[1] and font_obj.font[1].family then
61+
font_obj.font[1].family = trim_quotes(font_obj.font[1].family)
62+
end
63+
overrides.font = font_obj
64+
wezterm.log_info("Applied FONT override. Cleaned value:", cleaned)
65+
else
66+
wezterm.log_error("Failed to create font object from sanitized input:", cleaned)
67+
end
68+
return overrides
69+
end
5770
end
5871

5972
return M

0 commit comments

Comments
 (0)