irongit

chore: tried wezterm again, feels slow

huncholanehuncholaneauthored
parent 4772585commit d7fe97fd1f71f6d3c24a55a9c6c1590aa71750f2Browse files

1 file changed, +99 -79

+99-79wezterm/wezterm.lua
@@ -2,104 +2,124 @@ local wezterm = require("wezterm")
22 local utils = require("utils")
33 local act = wezterm.action
44 local config = wezterm.config_builder()
5+local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm")
6+local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")
7+local workspace_switcher = wezterm.plugin.require("https://github.com/MLFlexer/smart_workspace_switcher.wezterm")
8+
9+-- set up tabline
10+tabline.setup()
11+tabline.apply_to_config(config)
12+
13+-- set up resurrect
14+wezterm.on("gui-startup", resurrect.state_manager.resurrect_on_gui_startup)
15+resurrect.state_manager.periodic_save()
516
617 -- window config
718 config.enable_wayland = false
8-config.font_size = 10
19+config.font_size = 8
920 config.window_decorations = "RESIZE"
1021 config.window_background_opacity = 0.85
1122 config.enable_scroll_bar = true
1223 config.colors = {
13- scrollbar_thumb = "grey",
24+ scrollbar_thumb = "orange",
1425 }
1526 config.color_scheme = "Tokyo Night Storm"
1627
1728 -- keymap
1829 config.keys = {
19- -- Vim like pane movement
20- { key = "h", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Left") },
21- { key = "j", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Down") },
22- { key = "k", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Up") },
23- { key = "l", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Right") },
24-
25- -- Vim like resize events
26- { key = "h", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Left", 3 }) },
27- { key = "j", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Down", 3 }) },
28- { key = "k", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Up", 3 }) },
29- { key = "l", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Right", 3 }) },
30+ -- Vim like pane movement
31+ { key = "h", mods = "ALT", action = act.ActivatePaneDirection("Left") },
32+ { key = "j", mods = "ALT", action = act.ActivatePaneDirection("Down") },
33+ { key = "k", mods = "ALT", action = act.ActivatePaneDirection("Up") },
34+ { key = "l", mods = "ALT", action = act.ActivatePaneDirection("Right") },
3035
31- -- make ctrl-enter mean something
32- { key = "Enter", mods = "CTRL", action = wezterm.action.SendString("\x1bo") },
36+ -- Vim like resize events
37+ { key = "h", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Left", 3 }) },
38+ { key = "j", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Down", 3 }) },
39+ { key = "k", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Up", 3 }) },
40+ { key = "l", mods = "SHIFT|ALT", action = act.AdjustPaneSize({ "Right", 3 }) },
3341
34- -- Exit pane
35- { key = "e", mods = "CTRL|SHIFT", action = act.CloseCurrentPane({ confirm = false }) },
42+ -- Vim like create panes
43+ { key = "h", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Left" }) },
44+ { key = "j", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Down" }) },
45+ { key = "k", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Up" }) },
46+ { key = "l", mods = "CTRL|SHIFT", action = act.SplitPane({ direction = "Right" }) },
3647
37- -- window keys
38- { key = "n", mods = "CTRL|ALT", action = utils.SpawnMaximizedCommandInNewWindow({}) },
48+ -- New tab in current pane's cwd
49+ { key = "t", mods = "SHIFT|ALT", action = act.SpawnTab("CurrentPaneDomain") },
3950
40- -- debug
41- { key = "d", mods = "CTRL|SHIFT", action = act.ShowDebugOverlay },
51+ -- Close current pane
52+ { key = "q", mods = "ALT", action = act.CloseCurrentPane({ confirm = true }) },
4253
43- -- quit all
44- { key = "q", mods = "CTRL|SHIFT", action = act.QuitApplication },
54+ -- open lazygit
55+ {
56+ key = "g",
57+ mods = "CTRL|SHIFT",
58+ action = wezterm.action_callback(function(win, pane)
59+ win:perform_action(act.SplitPane({ direction = "Right", command = { args = { "lazygit" } } }), pane)
60+ win:perform_action(act.TogglePaneZoomState, pane)
61+ end),
62+ },
4563
46- -- Show the launcher in fuzzy selection mode and have it list all workspaces
47- -- and allow activating one.
48- {
49- key = "9",
50- mods = "ALT",
51- action = act.ShowLauncherArgs({
52- flags = "FUZZY|WORKSPACES",
53- }),
54- },
55- { key = "n", mods = "ALT", action = act.SwitchWorkspaceRelative(1) },
56- { key = "p", mods = "ALT", action = act.SwitchWorkspaceRelative(-1) },
57- -- Prompt for a name to use for a new workspace and switch to it.
58- {
59- key = "w",
60- mods = "CTRL|SHIFT",
61- action = act.PromptInputLine({
62- description = wezterm.format({
63- { Attribute = { Intensity = "Bold" } },
64- { Foreground = { AnsiColor = "Fuchsia" } },
65- { Text = "Enter name for new workspace" },
66- }),
67- action = wezterm.action_callback(function(window, pane, line)
68- -- line will be `nil` if they hit escape without entering anything
69- -- An empty string if they just hit enter
70- -- Or the actual line of text they wrote
71- if line then
72- window:perform_action(
73- act.SwitchToWorkspace({
74- name = line,
75- }),
76- pane
77- )
78- end
79- end),
80- }),
81- },
64+ -- workspace switcher
65+ {
66+ key = "p",
67+ mods = "ALT",
68+ action = workspace_switcher.switch_to_prev_workspace(),
69+ },
8270
83- -- open lazygit
84- {
85- key = "g",
86- mods = "CTRL|SHIFT",
87- action = utils.SpawnMaximizedCommandInNewWindow({ "lazygit" }),
88- },
71+ -- resurrect bindings
72+ {
73+ key = "w",
74+ mods = "ALT",
75+ action = wezterm.action_callback(function(win, pane)
76+ resurrect.state_manager.save_state(resurrect.workspace_state.get_workspace_state())
77+ end),
78+ },
79+ {
80+ key = "W",
81+ mods = "ALT",
82+ action = resurrect.window_state.save_window_action(),
83+ },
84+ {
85+ key = "T",
86+ mods = "ALT",
87+ action = resurrect.tab_state.save_tab_action(),
88+ },
89+ {
90+ key = "s",
91+ mods = "ALT",
92+ action = wezterm.action_callback(function(win, pane)
93+ resurrect.state_manager.save_state(resurrect.workspace_state.get_workspace_state())
94+ resurrect.window_state.save_window_action()
95+ end),
96+ },
97+ {
98+ key = "r",
99+ mods = "ALT",
100+ action = wezterm.action_callback(function(win, pane)
101+ resurrect.fuzzy_loader.fuzzy_load(win, pane, function(id, label)
102+ local type = string.match(id, "^([^/]+)") -- match before '/'
103+ id = string.match(id, "([^/]+)$") -- match after '/'
104+ id = string.match(id, "(.+)%..+$") -- remove file extention
105+ local opts = {
106+ relative = true,
107+ restore_text = true,
108+ on_pane_restore = resurrect.tab_state.default_on_pane_restore,
109+ }
110+ if type == "workspace" then
111+ local state = resurrect.state_manager.load_state(id, "workspace")
112+ resurrect.workspace_state.restore_workspace(state, opts)
113+ elseif type == "window" then
114+ local state = resurrect.state_manager.load_state(id, "window")
115+ resurrect.window_state.restore_window(pane:window(), state, opts)
116+ elseif type == "tab" then
117+ local state = resurrect.state_manager.load_state(id, "tab")
118+ resurrect.tab_state.restore_tab(pane:tab(), state, opts)
119+ end
120+ end)
121+ end),
122+ },
89123 }
90124
91--- plugins
92-local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")
93-tabline.setup()
94-tabline.apply_to_config(config)
95-
96--- log success on reload
97-wezterm.on("window-config-reloaded", function(_, _)
98- wezterm.log_info("Successfully loaded config from .config")
99-end)
100-
101--- load workspaces
102-local workspaces = require("workspaces")
103-workspaces.setup(config)
104-
105125 return config