local wezterm = require('wezterm') local config = wezterm.config_builder() wezterm.on('gui-startup', function() local tab, pane, window = wezterm.mux.spawn_window({}) tab:set_title('home') end) if string.find(wezterm.target_triple, 'windows') then config.default_prog = { 'powershell.exe', '-ExecutionPolicy', 'Bypass', '-NoLogo', '-NoExit' } end config.font = wezterm.font('CaskaydiaCove Nerd Font Mono') config.font_size = 9 config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' } config.color_scheme = 'Firefly Traditional' config.colors = { foreground = '#D3D7CF', cursor_fg = 'black', cursor_bg = 'white', cursor_border = 'white', } config.use_fancy_tab_bar = false config.tab_max_width = 64 config.window_padding = { left = 0, right = 0, top = 0, bottom = 0, } config.keys = { { key = 'r', mods = 'CTRL|SHIFT', action = wezterm.action.PromptInputLine({ description = 'Enter new name for tab', action = wezterm.action_callback(function(window, pane, line) if line then window:active_tab():set_title(line) end end), }), }, { key = 'w', mods = 'CTRL|SHIFT', action = wezterm.action.CloseCurrentPane { confirm = true }, }, } local function send_move_key(window, pane) -- TODO: Detect if vim/nvim is running -- We can't use pane:get_foreground_process_info() because it appears to -- contain info about the most recent process launched in the pane. During -- testing this was lua-language-server.exe so obisouly can't be used to -- determine if we're running inside neovim. -- WezTerm supports the OSC 1337 SetUserVar escape sequence, this could be -- used to inform WezTerm that neovim is running in a given tab. if pane:get_user_vars()['vim'] ~= nil then if pane:get_user_vars().vim ~= '1' then return false end elseif #window:active_tab():panes() > 1 then return false end return true end local move_mods = 'CTRL' for _, map in pairs({ { key = 'h', direction = 'Left' }, { key = 'l', direction = 'Right' }, { key = 'k', direction = 'Up' }, { key = 'j', direction = 'Down' }, }) do table.insert(config.keys, { key = map.key, mods = move_mods, action = wezterm.action_callback(function(window, pane) if send_move_key(window, pane) then window:perform_action( wezterm.action.SendKey({ key = map.key, mods = move_mods }), pane) else window:perform_action( wezterm.action.ActivatePaneDirection(map.direction), pane) end end), }) end -- Attempt require(module) load a module, don't fail if its missing. -- Additionally, call the returned function passing in the wezterm and config -- objects defined in this file. local try_require = function(module) pcall(function() require(module)(wezterm, config) end) end; try_require('local') return config