code icon indicating copy to clipboard operation
code copied to clipboard

Symbols outline should be enabled for project with a TAGS file

Open tello2004 opened this issue 4 months ago • 7 comments

Problem

I currently maintain a bunch of CoffeeScript codebases, all of them with Ctags-compatible files. To my surprise, looks like Code only enables the Symbols Outline for a select number of languages.

Proposal

Check for a TAGS/tags file in the current project directory, and if it exists then attach the Symbols Outline.

Prior Art (Optional)

No response

tello2004 avatar Aug 20 '25 16:08 tello2004

It would be simple enough to add text/x-coffeescript to the mimetypes that cause the Ctags symbol pane to show. Other languages which are not compatible would need their own parser and pane but could be added in principle if there is enout demand.

jeremypw avatar Aug 20 '25 17:08 jeremypw

Interesting bit:

https://github.com/elementary/code/blob/03e1d8b2650bae7f80b2baf7d32947d4afec55ea/src/SymbolPane/C/CtagsSymbolOutline.vala#L65

Other languages which are not compatible would need their own parser and pane but could be added in principle if there is enout demand.

Universal Ctags already takes care of that, either through an actual parser or regex. I don't think incompatible languages should be a problem since the tool ignores them.

tello2004 avatar Aug 20 '25 17:08 tello2004

Just tried this with a .coffescript file with mime-type application/vnd-coffescript but it does not generate any symbols (and does not look very C-like). What mime-types do you want to use the Ctags pane for?

jeremypw avatar Aug 20 '25 17:08 jeremypw

Just downloaded an example .tag file but the filetype is text/plain. I guess we could look at the file extension to trigger the symbol pane instead.

jeremypw avatar Aug 20 '25 17:08 jeremypw

Just tried this with a .coffescript file with mime-type application/vnd-coffescript but it does not generate any symbols (and does not look very C-like).

Currently https://github.com/preservim/tagbar/wiki#coffeescript snippet in my ctags config directory. It wonderfully works in Vim, which is the editor I have been using.

What mime-types do you want to use the Ctags pane for?

Mostly CoffeeScript, which currently lacks an LSP implementation and Ctags are the only sane way to navigate a big project. Though this enhancement benefits a lot of languages that are already implemented into Universal Ctags as parsers and optlib definitions.


Just downloaded an example .tag file but the filetype is text/plain. I guess we could look at the file extension to trigger the symbol pane instead.

What about trying to run ctags for files with a gtksourceview language-spec? Worst case scenario is the symbols panel shows empty, in which case it could default to getting out of the way (like it currently works today).

tello2004 avatar Aug 20 '25 17:08 tello2004

Worst case scenario is the symbols panel shows empty, in which case it could default to getting out of the way (like it currently works today).

We don't really want to create a symbol pane if the file is not compatible (i.e. does not generate any tags) because it will try to reparse the file every time it changes which wastes cpu. Sure, we could create the Ctags pane for all code text files and then hide it when there are no symbols but I am not sure that would be approved for merging.

jeremypw avatar Aug 20 '25 17:08 jeremypw

One possibility would be to add a "force" option which would allow the user create the symbol pane regardless.

jeremypw avatar Aug 20 '25 17:08 jeremypw