Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to allow users to open the toggleterm in the current window, just like :term? #528

Open
nullptr-yxw opened this issue Dec 27, 2023 · 1 comment

Comments

@nullptr-yxw
Copy link

nullptr-yxw commented Dec 27, 2023

It might be quite difficult to manage the window of the toggleterm(for example, #97 and #484), so is it possible to allow users opening the toggleterm in the current window(direction="buffer"), just like:term? So that the manage of the toggleterm window will be more flexible. And the users can use some commands such as tab or setlocal nobuflisted to change the performance as well.

@nullptr-yxw nullptr-yxw changed the title Is it possible to open the toggleterm in the current window, just like :term? Is it possible to allow users to open the toggleterm in the current window, just like :term? Dec 27, 2023
@blurskye
Copy link

blurskye commented Feb 15, 2024

well yes it is possible but quite useless... here is a snippet from my plugin...
.......

    local buf_type = vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), 'buftype')
    local terminal_buf_found = false
    if buf_type ~= 'terminal' then
        local buffers = vim.api.nvim_list_bufs()
        for _, buf in ipairs(buffers) do
            if vim.api.nvim_buf_get_option(buf, 'buftype') == 'terminal' then
                vim.api.nvim_win_set_buf(vim.api.nvim_get_current_win(), buf)
                terminal_buf_found = true
                break
            end
        end
        if not terminal_buf_found then

            vim.api.nvim_exec(':ToggleTerm', false)
        end
    end

the snippet is for a different usecase, in trying to send ctrl+c to the terminal, but maybe thats all you need to write a custom script to achieve what you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants