Skip to content

Commit 07fa44c

Browse files
authored
Merge pull request #160 from Mr-Hypocrite/fix/wezterm-wsl
fix(mux): nvim-wezterm panes not seamlessly switching while using wsl2
2 parents 0cf7149 + 324abc0 commit 07fa44c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lua/smart-splits/config.lua

+7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ local mux_utils = require('smart-splits.mux.utils')
2626
---@field ignored_events string[]
2727
---@field multiplexer_integration SmartSplitsMultiplexerType|false
2828
---@field disable_multiplexer_nav_when_zoomed boolean
29+
---@field wezterm_cli_path string|nil
2930
---@field kitty_password string|nil
3031
---@field setup fun(cfg:table)
3132
---@field set_default_multiplexer fun():string|nil
3233
---@field log_level 'trace'|'debug'|'info'|'warn'|'error'|'fatal'
3334

3435
---@type SmartSplitsConfig
3536
local config = { ---@diagnostic disable-line:missing-fields
37+
wezterm_cli_path = 'wezterm',
3638
ignored_buftypes = {
3739
'nofile',
3840
'quickfix',
@@ -109,6 +111,11 @@ end
109111
function M.setup(new_config)
110112
local original_mux = config.multiplexer_integration
111113

114+
if mux_utils.is_WSL() then
115+
-- on WSL default to .exe unless explicitly set in user config
116+
new_config.wezterm_cli_path = new_config.wezterm_cli_path or 'wezterm.exe'
117+
end
118+
112119
config = vim.tbl_deep_extend('force', config, new_config or {})
113120
-- if the mux setting changed, run startup again
114121
if

lua/smart-splits/mux/utils.lua

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ function M.are_we_tmux()
99
return term == 'tmux'
1010
end
1111

12+
function M.are_we_wezterm()
13+
if M.are_we_gui() then
14+
return false
15+
end
16+
17+
local term = vim.trim((vim.env.TERM_PROGRAM or ''):lower())
18+
return term == 'wezterm'
19+
end
20+
21+
--- Check if we're in WSL
22+
---@return boolean
23+
function M.is_WSL()
24+
return vim.env.WSL_DISTRO_NAME ~= nil and vim.env.WSL_DISTRO_NAME ~= ''
25+
end
26+
1227
---Check if Neovim is running in a GUI (rather than TUI)
1328
---@return boolean
1429
function M.are_we_gui()

lua/smart-splits/mux/wezterm.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local Direction = require('smart-splits.types').Direction
2+
local config = require('smart-splits.config')
23

34
local dir_keys_wezterm = {
45
[Direction.left] = 'Left',
@@ -16,7 +17,7 @@ local dir_keys_wezterm_splits = {
1617

1718
local function wezterm_exec(cmd)
1819
local command = vim.deepcopy(cmd)
19-
table.insert(command, 1, 'wezterm')
20+
table.insert(command, 1, config.wezterm_cli_path)
2021
table.insert(command, 2, 'cli')
2122
return vim.fn.system(command)
2223
end

0 commit comments

Comments
 (0)