Sublime Forum

How to list project symbol from API?

#1

Hi everybody,

I hope you are going well.
i come back with another question :

In my .sublime-syntax, all scopes i need are correctly defined.
All my function names are indexed correctly in my project’s symbols.
I would like to list all these symbols filtered by “syntax” and by “type=function”. I have a lot of function by project and i would like to suggest the function names in the completion api.

With symbol_locations API, i can find a symbol that i know the name : sym=myfunction.

How to obtain from the API a list of all my project’s symbols where syntax="XPX and type=“function” ?
I have been searching for a while but no success.
Is it possible please ? and how to do that ?

On my project, i can use Goto Symbol in my Project… but it is interactive.
I would like an API to get a result list in my plugin code.

Thank’s in advance for your help.
Have a nice week.

Pascal

0 Likes

#2

ST doesn’t currently provide an api for arbitrary symbol queries.

0 Likes

#3

Thank you deathaxe for your answer.

Is ther any reason to this lack of function or is this totally because noboby had the need before ?
Is there a possibility to dispose such a function soon ?
Or how to do that since i do not have access to the list of symbol i think ?

Have a nice week.
Pascal

0 Likes

#4

ST’s auto-completion uses symbols from index to enrich completions. Unfortunatelly it only considers those which are present in current file only. It means once you’ve written an indexed function foo() in your code, ST will complete it again knowing it to be a function.

The compelling argument for all those limitations is performance. Providing completions for all indexed symbols is said to be too expensive even for builtin completions engine. Hence they are not exposed via API as python and the IPC interface between ST and the plugin host would struggle even more.

I’d also like to see such feature for my CNC language, but I guess the results woudn’t be too useful after all, because ST doesn’t know enough about semantics of a syntax and thus indexed symbols are not categorized well enough to not return 99% junk.

It all comes down to a real language-server which knows about a certain language being the better choise.

0 Likes