Code Monkey home page Code Monkey logo

Comments (4)

akinsho avatar akinsho commented on May 17, 2024

@LoydAndrew that's a cool idea tbh I hadn't really considered it ever. There isn't really a way to do that currently but I like the idea. I think a reverse command would be good as well i.e. toggle all with none open opens all the previously opened and then using that again toggles them all.

It wouldn't be too hard to implement basically could add a check for the all argument to the toggle term commannd and then loop through all terminals and call toggle. I guess the potentially weird edge case would be if one terminal was open and you hit TermToggle all should that open the rest or close the open one.

Maybe in that case it should work more explicitly ToggleTermCloseAll or ToggleTermOpenAll and then it can be explicitly mapped to opening any that aren't open or just closing them all.

Anyway I'd be happy to help direct a PR for this, most of the logic to do this is already there just needs commands defined and cobble thing together

" in toggleterm.vim
command! ToggleTermCloseAll lua require('toggleterm').toggle_all('close')
command! ToggleTermOpenAll lua require('toggleterm').toggle_all('open')

Then in toggleterm.lua

function M.toggle_all(command)
  for _, term in get_all() then
    if direction == "close" then
      term:close()
    else
      if not term:is_open() then
       term:toggle()
      end
    end
  end
end

from toggleterm.nvim.

akinsho avatar akinsho commented on May 17, 2024

@LoydAndrew it was pretty straightforward to do i.e. more or less exactly what I had above so I just did it in my lunch break. Can you test it out and see if it works

from toggleterm.nvim.

LoydAndrew avatar LoydAndrew commented on May 17, 2024

@akinsho
Thanks, great and quick work. I guess the only problem is to have 2 explicit commands rather then one toggle, but I can live with that. Again, very appreciate it.

from toggleterm.nvim.

akinsho avatar akinsho commented on May 17, 2024

@LoydAndrew if you had only one command and had 1 window open it's not clear how it should work. Should it close that window or open other windows you previously toggled 🤷🏾‍♂️ I'm definitely open to a PR to fix it though but I probably won't spend more time on it myself, this isn't really a workflow I use

from toggleterm.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.