[txmt-dev] Compiler Integration

Jacob Carlborg doob at me.com
Sat Sep 29 12:01:06 UTC 2012


I saw an issue on github about integrating libclang with TextMate. So I would like to start a discussion about a plugin interface to integrate compiler libraries, or similar, with TextMate. 

I haven't look at the TextMate source code thoroughly, I just had a quick glance. I see that there are a TMPlugInController that seems to handle loading plugins. Do TextMate have a proper plugin API or is it working just like in TM1, using method swizzling? I've done some minor work on a TM1 plugin. 

I think we should design a plugin interface for compiler integration that allows a plugin doing various tasks, such as syntax highlighting and autocompletion. The interface should not be specific to libclang, it should be possible to do this with any language supported by TextMate. 

First we would need to decide what we want the plugins to be able to do. Here's a suggestion for a list of tasks: 

* Syntax highlighting 
* Autocompletion 
* Error and waring reporting 
* Showing formatted documentation for symbols 
* Go to definition 

For the design of the interface I'm thinking an Objective-C protocol for each task that we want to support. I haven't thought that much of how any of these interfaces might look like but here are a quick suggestion for code completion: 

@protocol CodeCompletePlugin 
- (NSArray*) codeCompletionAt:(Cursor*)cursor; 
@end 

@interface Cursor 

@property NSString* file; 
@property size_t line; 
@property size_t column; 

@end 

@interface CodeCompleteResult 

@property NSString* result; 

@end 

When the user performs an code completion TM would call the "codeCompletionAt" method of a plugin that implements the CodeCompletePlugin protocol. It would pass a cursor representing the cursor location in the file where the user performed the code completion. The cursor should probably point to the start of a token, that's how libclang works. 

A plugin would probably need to register itself, including what language it should be used with. 

All this still quite a rough idea. 
What do you guys think? 

-- 
/Jacob Carlborg



More information about the textmate-dev mailing list