Sublime Forum

[ST3] extensibility of the indexer

#1

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?

0 Likes

#2

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.

0 Likes

#3

In sublime text 3, tmLanguage files are located in

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

or

/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]<?xml version="1.0" encoding="UTF-8"?>

name Symbol List scope entity.name.function, entity.name.type, meta.toc-list settings showInSymbolList 1 uuid 0A0DA1FC-59DE-4FD9-9A2C-63C6811A3C39 [/code]

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.

0 Likes