Home Download Buy Blog Forum Support

[ST3] extensibility of the indexer

[ST3] extensibility of the indexer

Postby mraleph on Wed Apr 24, 2013 11:31 am

I really like ST3 built-in indexer. It is very fast and works like a charm (compared to resource hungry clang based indexer).

However I am working on C++ code base that makes extensive use of macros to define symbols/methods.

These symbols are not indexed by ST3 indexer because it obviously does not perform macro expansion.

I wonder if built-in indexer has any sort of the API that would just allow me to tell it that FOO(BAR) defines symbol kFOO_BAR?
Posts: 1
Joined: Wed Apr 24, 2013 11:26 am

Re: [ST3] extensibility of the indexer

Postby pfultz2 on Thu Apr 25, 2013 4:26 pm

I believe the symbol indexing uses the tmLanguage files to parse the symbols. On sublime 2 they were located in the `Packages/` directory, but I don't know where they are located in sublime 3.
Posts: 2
Joined: Thu Apr 25, 2013 4:19 pm

Re: [ST3] extensibility of the indexer

Postby jacobvgardner on Fri Apr 26, 2013 2:57 pm

In sublime text 3, tmLanguage files are located in

C:\prog files\Sublime Text 3\Packages\language.sublime-package


/opt/sublime-text-3/packages/language.sublime-package on linux.

Not sure about mac.

There's files called 'Symbol List.tmPreferences'

The default, for example is:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
   <string>Symbol List</string>
   <string>entity.name.function, entity.name.type, meta.toc-list</string>

The scope section determines what get indexed. Many languages override this default with their own. It does use tmLanguage files (the same files that dictate syntax highlighting) to do indexing. So macro expansion would not be possible through these default channels, and no there is no exposed API as of yet to define custom rules or symbols for indexing. As of right now, you would be better off writing your own indexer and leveraging the limited capabilities of the current indexer.

The window class has lookup_symbol_in_index(symbol) and lookup_symbol_in_open_files(symbol) and you could use view.scope_name(point) to determine a word's type in the file to determine if you should run your macro-expander or not.

Just a thought.
Posts: 3
Joined: Thu Mar 21, 2013 9:46 pm
Location: Olathe, KS

Return to Technical Support

Who is online

Users browsing this forum: dyekvar, Exabot [Bot] and 26 guests