How to open a list of files in the atom tree view from an atom plugin


I am trying to do some research on this, but still can’t find anything appropriate. Can someone guide me? I have code in my atom plugin where I fetch files and then want to open them in the tree view structure of atom.




I tried the following

I don’t see the file opening in the treeview. Is it because I still have a modal open? I don’t think that is the issue tho.



You didn’t ask for a method to open a single file in the tree-view. You asked for a “list of files”. atom.project.addPath is for adding project roots to the tree-view, so you would have to add an ancestor directory of the file. The tree-view doesn’t show single files, it shows directories.


Sorry about that, should have been more clear. I am now trying to pass a path which is a root directory for the project, and then opens that in atom with the underlying tree structure. The path I am passing right now is -


This still won’t open the treeview. Is there something else I am missing?

Thanks for your help on this. :slight_smile:


Edit1: Also, there is no project opened in atom right now. I am doing a fetch for some files and creating a directory structure from that, which I want to open in the IDE.

Edit2: I just found a way to open the project in atom, but it opens in a new window even if I pass in newWindow: false in the options to the I want to reuse the same atom window to open the project.


Does this path exist on disk when you pass it to atom.project.addPath?


Just found it. I have to use atom.workspace.project.addPath(path), and it opens the project I want on the Atom IDE in the current window.

Thanks for the help dude.