Sublime Forum

How to get indented symbols view list?

#1

Python:

(New user, only one image) Ruby, however, does not do this, displaying only a long straight list of symbols.

I tried comparing both syntax definiton files, but couldn’t spot what scopes informed the Symbols View of nested symbols. Could anyone point me in the right direction towards achieving nesting?

Thanks!

0 Likes

#2

This is not (directly) a function of the syntax definitions. If you take a look at Packages\Python\Symbol List.tmPreferences it contains a symbolTransformation setting that modifies how the symbols look in the symbol list.

That said, it does rely on the symbols that come out of the syntax system, so the two are tied together in that regard.

There is more information in the unofficial documentation on Symbols, and on Text Transformations in particular.

1 Like

#3

Thank you, I have looked at that file, but it does not in any way deal with indentation.

e.g.
<key>symbolTransformation</key> <string> s/class\s+([[:alpha:]_][[:alnum:]_]*.+?\)?)(\:|$)/$1/g; s/(?:async\s+)?def\s+([[:alpha:]_][[:alnum:]_]*).*/$1\(…\))/g; </string>

Nowhere in that transformation is indentation dealt with. The symbol strings passed into these transforms contain only the symbols themselves. Indentation is added elsewhere.

0 Likes

#4

There aren’t settings for indentation. Instead, you would need to select a scope name that only specifies something like methods, and have the transform capture the whole text and then add a two spaces and then the capture.

There is an example of this in the D syntax.

1 Like

#5

True, but including indentation in the transformation causes indenting to happen as well.

0 Likes

#6

Ahh, that makes sense. Thank you both.

0 Likes