Help with creating package

Hi!

I am trying to create some new functionally with Atom. Heres a short description of what I would like to make:

Since I am a neat freak, I like a clean project directory, and all unnecessary files/folders should be hidden from my sight. I think it would be really neat if I could create a file called .hide inside my project folder. In this file there would be paths to folders and files that I would like to hide. And a keyboard shortcut would toggle this feature.

In order to create this, I must have some way to locate these files somehow. Maybe using css selector and setting each element to display:hidden perhaps, but this has turned out to be difficult since the data-path attribute for the folders are placed on the ‘wrong’ element. (should be placed on ancestor+). I started thinking that maybe someone here could have a suggestion.

I have now tried using the tree view API, but the ‘entryForPath(entryPath)’ method just won’t return the correct dom element if the folder is closed in the tree view, ie. the element does not necessarily exist.

Can anyone here think of a smart way to get all dom elements (given the paths in the .hide file(s)) even if they don’t exist in the dom yet? Or maybe tell the tree view not to show certain files and folders(and their content) somehow?

Atom already has a feature to ignore version controlled files, e.g. files in your .gitignore:

Tree-view items that are VCS-ignored have the class .status-ignored, so it should be enough if your package toggles whether items with that class are hidden.

Update: Actually, the tree-view package has an option to hide VCS-ignored files

Thank you for responding!

But let’s say I have a file, called ‘my-file.js’ that I do want to commit in git, ie. don’t put into the .gitignore file, but I still want to hide it from my visual field.

Do you think this would be possible using your suggested method?

I use project-viewer package to selectively load projects (or groups of projects) into tree-view.
I believe that this setup might do what you are asking. The project-viewer pane can be toggled closed after you select the project(s) to load into tree-view.

Thanks, I will try this out:)

Just so I understand you right?

You mean that a combination of project-viewer and the css/less class .status-ignored should make my feature possible to create?

If you still want to write your own package, I’ve used the ignore module to parse custom ignore files in my portable-packages package. It should be trivial to adapt the following code to suit your needs:

I found a package that does the job; tree-ignore

No need to build! But thanks! I found it using the keyword ‘ignore’, thanks!

1 Like