I'd like to generate a set of tags and then view them in Treemacs, ideally whenever I open a file that I can generate tags for.

The docs for Treemacs' tag view say:

Treemacs is able to display not only the file system, but also tags found in individual files. The tags list is sourced using emacs’ builtin imenu functionality, so all file types that emacs can generate an imenu index for are supported.

Imenu caches its result, so to avoid stale tag lists setting imenu-auto-rescan to t is recommended. Tags generated with the help of semantic-mode are likewise supported.

I looked around and it appears that js-mode does offer imenu support.

I'm at a loss for how to actually connect these two - how do I get js-mode to create the imenu index so that treemacs can actually use it?

1 Answer 1


js2-mode generates an imenu index that Treemacs displays.

  • I'm sorry for the total noob questions, but - how do I get js2-mode to generate the imenu? Once it's generated does Treemacs automatically display that? (If so - how does Treemacs know to look for the imenu?) Commented Dec 9, 2019 at 21:23
  • The imenu generation should happen automatically. You can see it in treemacs by putting point on, say, a js file and hitting TAB -- it will show the items it found in that file such as variables, functions, etc. Commented Dec 10, 2019 at 20:49
  • 1
    Hey, that worked! Thanks for the help! Commented Dec 11, 2019 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.