-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.wezterm.lua
155 lines (142 loc) · 3.83 KB
/
.wezterm.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
local wezterm = require("wezterm")
local config = {}
-- The color scheme you want to use
local scheme = "Spacemacs (base16)"
-- Obtain the definition of that color scheme
local scheme_def = wezterm.color.get_builtin_schemes()[scheme]
local function is_vim(pane)
-- this is set by the plugin, and unset on ExitPre in Neovim
return pane:get_user_vars().IS_NVIM == "true"
end
local direction_keys = {
h = "Left",
j = "Down",
k = "Up",
l = "Right",
}
local function split_nav(resize_or_move, key)
return {
key = key,
mods = resize_or_move == "resize" and "META" or "CTRL",
action = wezterm.action_callback(function(win, pane)
if is_vim(pane) then
-- pass the keys through to vim/nvim
win:perform_action({
SendKey = { key = key, mods = resize_or_move == "resize" and "META" or "CTRL" },
}, pane)
else
if resize_or_move == "resize" then
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
else
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
end
end
end),
}
end
-- Event handlers
-- Better inc/dec font size
wezterm.on("my-inc-font-size", function(window)
local size = window:effective_config().font_size + 1
local overrides = window:get_config_overrides() or {}
overrides.font_size = size
window:set_config_overrides(overrides)
end)
wezterm.on("my-dec-font-size", function(window)
local size = window:effective_config().font_size - 1
local overrides = window:get_config_overrides() or {}
overrides.font_size = size
window:set_config_overrides(overrides)
end)
-- Up Right Status
wezterm.on("update-right-status", function(window)
-- Add font name and size to status bar
local font = window:effective_config().font.font[1].family
local size = window:effective_config().font_size
local status = wezterm.format({
"ResetAttributes",
-- { Background = { Color = "#666666" } },
-- { Foreground = { Color = "White" } },
{ Text = string.format("%s %spt ", font, size) },
})
-- Add Leader
local leader = ""
if window:leader_is_active() then
leader = "LEADER |"
end
window:set_right_status(string.format("%s %s", leader, status))
end)
config.font = wezterm.font("JetBrains Mono")
-- Leader is the same as my old tmux prefix
config.leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 }
config.colors = {
tab_bar = {
active_tab = {
bg_color = scheme_def.background,
fg_color = scheme_def.foreground,
},
},
}
config.text_blink_rate = 500
config.default_cursor_style = "BlinkingBlock"
config.cursor_blink_ease_in = "Constant"
config.cursor_blink_ease_out = "Constant"
config.keys = {
-- splitting
{
mods = "LEADER",
key = "-",
action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }),
},
{
mods = "LEADER",
key = "|",
action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
{
mods = "LEADER",
key = "z",
action = wezterm.action.TogglePaneZoomState,
},
-- rotate panes
{
mods = "LEADER",
key = "Space",
action = wezterm.action.RotatePanes("Clockwise"),
},
-- show the pane selection mode, but have it swap the active and selected panes
{
mods = "LEADER",
key = "0",
action = wezterm.action.PaneSelect({
mode = "SwapWithActive",
}),
},
-- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
{
key = "a",
mods = "LEADER|CTRL",
action = wezterm.action.SendKey({ key = "a", mods = "CTRL" }),
},
-- move between split panes
split_nav("move", "h"),
split_nav("move", "j"),
split_nav("move", "k"),
split_nav("move", "l"),
{
mods = "SUPER",
key = "=",
action = wezterm.action.EmitEvent("my-inc-font-size"),
},
{
mods = "SUPER",
key = "-",
action = wezterm.action.EmitEvent("my-dec-font-size"),
},
-- resize panes
-- split_nav("resize", "h"),
-- split_nav("resize", "j"),
-- split_nav("resize", "k"),
-- split_nav("resize", "l"),
}
return config