akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.21k stars 170 forks source link

feat: add skip_toggle option to ignore some opened terminals when toggling #530

Open tanloong opened 8 months ago

tanloong commented 8 months ago

This adds a skip_toggle option to allow users skip specific terminals when toggling. A use case is when using the file explorer lf.nvim which is based on toggleterm.nvim. A common scenario on my side is that there are two hidden terminals, an Lf terminal and a Shell terminal, where I hope the Shell terminal always shows up on ToggleTerm, even though it is not the last toggled one.

With the skip_toggle this behavior can be achieved:

toggleterm.setup({
    open_mapping = [[<m-=>]],
    skip_toggle = function(t)
        return t and t.cmd and vim.startswith(t.cmd, "lf ")
    end,
}

https://github.com/akinsho/toggleterm.nvim/assets/71320000/a22fe4da-6abd-467e-8212-e8d8c97da383