Creating an invisible pane to hold items (trying to replicate Vim buffers)


#1

I’m trying to replicate Vim’s behaviour when it comes to panes.

  • Hiding tabs
  • When a pane is opened it is immediately activated
  • New item means old items are removed from pane, i.e. each pane only holds one item

Hiding tabs

I’ve done that like this in the styles.less file:

// Hide tabs
.tab-bar {
  display: none !important;
}

Activate new panes immediately

I’ve tried the following but Atom gives me errors when this code is in my init file and I open a new pane, not sure how to solve it:

atom.workspace.onDidAddPane(function (event) {
  /**
  * event = { pane }
  */

  event.pane.activate()
})

The error I get is always Uncaught Error: Setting active pane that is not present in pane container, how can I fix this?

One item per pane

I’ve figured it out with the following code, works decently:

atom.workspace.onDidOpen(function (event) {
  /**
   * event = { item, pane, index }
   */

  event.pane.destroyInactiveItems()
})

Now what I need help with is, the one item per pane solution is not great. It works, but it means that every time I open a new file Atom is destroying the other file after loading the new one in, not ideal. This also means that if I’ve modified the current file Atom will ask me if I want to save the file before closing it, which is fine but I don’t have to deal with that in Vim.

What I want is help with finding a way to have one hidden/invisible pane that will hold the items that are put away because a new one was loaded.

Ideally this pane would be integrated with the builtin Atom behaviours, like Cmd-p switching to the already open item if it already exists and Cmd-b letting me switch between already open items.

This is really the only thing keeping me back from switching to Vim, the incredibly weird behaviour (for me) when it comes to panes and items and how they’re handled by default.

Thanks for any help! :slight_smile:


#2

There is a change coming to panes soon. The pull has been accepted. You should find the details before you go too far.


#3

You have a link to the specific one? I tried looking for it but I didn’t find any significant behaviour changes.


#4

#5

From what I can tell, what this pull request does is make it so you can move/copy items to adjacent panes easier. AFAIK moving items to other panes was possible already, although you needed a reference to the pane, you coudln’t just go to the adjacent pane.

So, from what I can tell, my main problem still remains to be solved, which is to have a hidden pane that holds the items that are not currently active.

Thanks for letting me know of these changes though. :slight_smile:


#6

My best guess so far, and I’ll look into it after work, is that I should create a normal pane (not sure how to do that) and add styles to that pane to make it completely invisible, but retain a reference to it somewhere so I can send items to it.


#7

Couldn’t find a way to create a pane with code :frowning:. I only found info on panels.


#9

So can I assume there is no way? That is a disappointment. :frowning:

While I can get used to this weird flow that Atom is forcing on me ATM, I’d really like to figure it out so that I can configure it to a workflow I’m more used to…

Anyway, worth a try. All I really need is some point of access to the Pane class.


#10

Did you try reading the code?


#11

Why doesn’t the built-in PaneItem system work for this? If you disable the tabs package and don’t do the single-item-per-pane thing, then when you open a new file, the old file is still there … just with no way to bring it to the front except through the keybindings you named like Cmd+P and Cmd+B. This also solves the “prompt to save” problem you mentioned.


#13

I have and from what I can tell only Atom has access to the Pane class. It isn’t exposed anywhere from what I could tell.


#14

The thing is that I want to reproduce Vim’s behaviour.

Vim’s behaviour dictates that when I close a buffer (item), the window (pane) closes along with it.

If I simply disable tabs, like you said, when I close an item the other items are still there, the pane is not closed.

The only way I know how to do this is to only have one item per pane, which is why I want a hidden pane, to move all inactive items to that pane.