Sublime Forum

Can i exploit the goto feature?

#1

Hi,

I want to create a plugin that finds out keywords used in workspace.
So my first idea was to parse every file of the current workspace but if there is an api or something else that can help me use the goto definition feature that would be great!

Thanks

0 Likes

#2

Depending on what you mean by “keywords”, there’s somewhat of an API for this, but nothing that directly tells you every symbol that’s in the current work space directly. Depending on what it is you have in mind, this may or may not help you out.

For example, Goto > Goto Symbol in the menu opens the Goto Anything panel that shows you the symbols defined in the current file so you can jump to them. The view.symbols() method in the API will fetch you the same list of symbols as is displayed in that case, along with their locations.

On the other hand, Goto > Goto Symbol in Project opens a different popup that shows you the global list of symbols from all files that are indexed instead of just for the current file. In that case the API has window.lookup_symbol_in_index() and window.lookup_symbol_in_open_files(), but both of them work in the opposite direction; you tell them what symbol you’re interested in and it tells you where you can find it.

0 Likes

#3

Yes i see what the symbols features can do, but let’s say i want to fetch the parameters of the current selected function, of course the function is defined in another file so how can i get the function definition in order to get my parameters?

0 Likes

#4

That sort of information isn’t something that Sublime indexes, so for something like that you would need to write something yourself or leverage something that is provided by an external code intelligence package.

0 Likes

#5

Alright is there an external code intelligence package that provide that?

0 Likes

#6

You try to look into:

  1. https://www.youtube.com/watch?v=2GqpdfIAhz8 (Language Server Protocol Explained)
  2. https://github.com/Microsoft/language-server-protocol
  3. https://github.com/tomv564/LSP
  4. https://github.com/SublimeCodeIntel/SublimeCodeIntel
0 Likes

#7

Thanks i will look into that.

0 Likes