Komodo extensions (also known as add-ons) are used to extend the functionality of the IDE. Komodo is based upon the Mozilla framework, so it has the same extension capabilities as Firefox does, which means the Mozilla extension documentation also applies to Komodo as well. These Mozilla resources are a great place to begin understanding the fundamentals of extensions.
Add-on DialogUse the Tools > Add-ons menu to open the Add-ons management dialog. The Extensions tab will show you the currently installed add-ons, most of which are included through the default Komodo installation. Use the Get Add-ons tab to browse the recommended Add-ons or use the filter field search for a particular extension. Choose an extension and click on the download or Install links. You can also read the add-on tutorial covering the add-on dialog features.
Creating an Extension
Extensions usually come in two flavours:
- Feature Extensions: these add new interfaces, components and functionality to Komodo.
- Language Extensions: which adds (or improves) support for a particular programming language in Komodo.
The best way to start creating a new Komodo feature is by utilizing the Komodo macro system, which you can use to quickly and easily create new functionality for Komodo, such as adding user interfaces, responding to keypresses, opening files, or performing text manipulation in the Komodo editor.
If you wish - you may then turn your macro into a Komodo add-on (so it's easily installable and will automatically update when you make changes to it). To get started, use the Project -> New -> New Project from Template and select the Create Komodo Extension project. When using a Komodo extension project, you'll find there is a "Build and Install" macro added to your Komodo toolbox, which you can use to create and install the extension xpi file.
Language extensions are used to extend Komodo's knowledge of programming languages (like Java, Matlab, Mel). This can control things like Language Detection, Code Coloring, Editor Indentation, Syntax Checking, Code Intelligence (completions and calltips) and Debugging.
The easiest way to create a new Komodo language is to use the Project -> New Project from Template and select the Create Komodo Language project. Fill out the add-on details, then you can customize the language details (like the comment styles, keywords and code intelligence) and create the project. You'll find there is a "Build and Install" macro added to your Komodo toolbox, which you can use to create and install the extension xpi file.
Once you've got the basics of the language down, you can further tweak the generated files to your liking and then re-build and re-install the add-on to test it out. Below is a description for the generated files and folders of the add-on:
- install.rdf, chrome.manifest Registration information for the add-on (e.g. name, author, homepage) and the user interface to load for the add-on.
- components Controls the registration of the language within Komodo, provides information about the language (name, file extension, etc...).
- pylib Provides code intelligence facilities, for code completion popups, calltips and code browser information.
- udl The UDL files provide syntax highlighting (coloring) for your language, including keyword, strings, numbers and comment styling.
- templates The templates folder holds the custom language templates that will be availalbe in Komodo's New File from Template dialogs.
User Defined Languages (UDL)
Komodo's system for defining multi-language syntax lexing (coloring) is called UDL (User Defined Languages). UDL files are written in a language called Luddite, which then gets compiled into a Scintilla lexer package for use inside Komodo. All udl files are stored inside the "udl" folder of your extension.
Code Intelligence is enabled in a Komodo language extension by adding a pylib/codeintel_langname.py file to your extension. It works by first triggering a completion event and then responding to an evalutation request.
- Trigger - whenever a keypress occurs in Komodo, the trg_from_pos Python method in your codeintel_language file will be called. It will be up to you to decide if you want to offer completions at that point - when you do, then you'll need to return a Trigger() instance.
- Evaluation - handles the lookup for completion/calltips. The async_eval_at_trg method is called when the trg_from_pos method has returned a trigger. It's job is to provide the list of completions or the calltip string.
Extension Development Tools and Useful Links
- Komodo Developer Add-on
- DOM Inspector
Grok provides a fast source code search engine. You can use this online search tool to find code examples for working with different parts of Komodo. For example, here is a list of hits for the Komodo hyperlinks feature.
- Error Console
- Mozilla Extension Development Documentation
Thanks to Komodo being based upon the Mozilla framework, Komodo has the same extension capabilities as the Firefox browser, making Komodo extension development a breeze - you can even re-purpose existing Firefox extensions to work within Komodo.
- Komodo Edit Add-Ons
These are Komodo Edit add-ons that are included in the regular Komodo Edit installers. You will also find these add-ons in the "extensions" directory of your Komodo installation.
- OpenKomodo Add-Ons
These are Komodo add-ons that have been developed by ActiveState that are not included in the regular Komodo installers. A lot of these are hosted on the ActiveState Community site.