0

Python: add scope entity.name.function.python for the actual function name in a function call

lanzz 11 jaar geleden bijgewerkt 11 jaar geleden 1

In the Python/Python.tmLanguage file, find this pattern:

<dict>
<key>begin</key>
<string>(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\()</string>
<key>end</key>
<string>(?=\s*\()</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#dotted_name</string>
</dict>
</array>
</dict>
and add a scope name for this pattern:

<key>name</key>
<string>entity.name.function.python</string>
This would allow to highlight all function names inside a nested function call:
foo(bar(baz))


Without the above change, you cannot match both "foo" and "bar" function names; you can either match "meta.function-call" which would match "foo" but would also include all the parameters (thus also "baz", which is not a function name), or you can match "meta.function-call - meta.function-call.parameters" which would match "foo" but exclude the "bar" function name.

Hm, on second thought, "entity.name.function.python" is not a good choice, as it populates the "goto symbol" panel. "meta.function-call.function-name" perhaps?