mrjones2014 / smart-splits.nvim

🧠 Smart, seamless, directional navigation and resizing of Neovim + terminal multiplexer splits. Supports tmux, Wezterm, and Kitty. Think about splits in terms of "up/down/left/right".
MIT License
895 stars 37 forks source link

[Feature]: Improve mux auto-detection and make lookup more flexible #141

Open mrjones2014 opened 8 months ago

mrjones2014 commented 8 months ago

Similar Issues

Description

Recently there's been an increase in issues related to mux auto-detection, and an interesting use-case in #140. Using tmux in other terminals, but kitty mux in kitty.

Mux auto-detection needs to be made more robust, and we also need to make the priority order configurable, so that e.g. if tmux is installed and you're using kitty, but you want to use kitty mux in the kitty terminal, you can specify that kitty should take precedence here.

I'm thinking we can do something like:

local mux_lookup = {
  tmux = function()
    local term = vim.trim((vim.env.TERM_PROGRAM or ''):lower())
    return term == 'tmux'
  end,
  wezterm = function()
    local term = vim.trim((vim.env.TERM_PROGRAM or ''):lower())
    return term == 'wezterm'
  end,
  kitty = function()
    return vim.env.KITTY_LISTEN_ON ~= nil and #vim.env.KITTY_LISTEN_ON > 0
  end,
}

And then the config would be something like:

require('smart-splits').setup({
  mux_detection_priority = { 'tmux', 'wezterm', 'kitty' },
})