Komodo-CFML

Original: 05 Feb 2010 06:51 am by Ron
Updated: 19 Feb 2010 05:57 am

Introduction

A partial screenshot of an early version of CFML within Komodo Edit

An partial screenshot of an early version of CFML within Komodo Edit, showing some of the syntax highlighting (02/2010)

Komodo-CFML is a project I’ve undertaken to develop a reasonably functional CFML language mode for ActiveState’s Komodo Edit and Komodo IDE multi-language editor environments. I’ve long thought the Komodo platform an attractive base for CFML development, givenĀ it’s availability for the three major OS’s (Mac OS X, Linux, and Windows) and it’s reasonably full feature set, particularly:

  • syntax support for a wide variety of languages
  • extensibility via macros, snippets, abbreviations, and full-blown editor extensions for both addtional languages and
  • additional functionality
  • lots of the normal editor bells and whistles that I tend to look for that set higher-end editors apart from others: code folding,
  • block selection, indentation marking, flexible key binding
  • a freely-available version (Komodo Edit) as well as the more feature-rich pay version (Komodo IDE)

Capabilities

My intent is that Komodo-CFML will eventually provide all of the following:

  • full syntax highlighting support for CFML, as implemented not just by Adobe’s ColdFusion application server but also the additional tags and functions provided by offerings from Railo, NewAtlanta’s BlueDragon, and the OpenBD project. In doing so, it should support
    • CFML by itself, within HTML, within CSS, within JavaScript, and within SQL in CFQUERY tags,
    • full syntax highlighting for all of the above-mentioned languages (HTML, JavaScript, CSS, SQL) when they occur in CFML language files,
    • syntax highlighting for CFSCRIPT within CFML files, and
    • some (possibly limited) syntax highlighting for custom tags and tags loaded as tag libraries via CFIMPORT.
  • access to tag completion, smart indenting, code folding support, etc., for the HTML, CSS, and JavaScript languages when they occur in CFML files,
  • tag completion, smart indenting, code folding, etc., for CFML tags
  • recognition (e.g., appropriate syntax highlighting) of known variables in language scopes (e.g., cgi.remote_Host) as keywords

Current Status

I’m at a 0.1.1 version release as of early February 2010. I have most of the desired capabilities related to the syntax highlighting complete; I’ve been using it in one form or another as my primary CFML editor almost exclusively for the past 6 weeks or so. At present, there are several notable items from the above list, however, that are not yet implemented:

  • Highlighting of known variables in language scopes (e.g., cgi.remote_Host)
  • Auto-completion support for CFML tags to provide help with tag attributes
  • Function “insight” to provide help with CFML functions

In addition, I have a bit of work (perhaps re-work) to make code folding a little smarter for CFML tags that can’t have close tags when written in non-XML style. Folding support, as it is currently written, works great if all of the code uses XML-style tag endings for empty tags, but less well if not. An example might help make this clearer; if the editor finds

<cfset variables.goo = "some string" />

it understands this is an empty tag (based on the XML-style closing) and that it shouldn’t assume the presence of a closing tag for code folding. If, however, the tag were to be written as

<cfset variables.goo = "some other string">

the editor — or more correctly, my CFML mode — assumes the presence of a matching closing tag. I’ve got huge piles of older code still in production use written in this second form, and although the CFML itself works without problem I feel strongly that the editor needs to be a little smarter in handling these tags that can’t (as opposed to don’t) have close tags and should allow for coding in either form (as both forms are considered valid by the CFML engines themselves.

One last caveat: the current implementation almost certainly will not work correctly in syntax highlighting CFML files that are exclusively CFSCRIPT without the CFSCRIPT tags, as supported by Adobe ColdFusion 9 for components written exclusively in CFSCRIPT. I might wrestle that one to the ground one day if it becomes important to me.

Roadmap

My plans for Komodo-CFML are something like this:

  • 0.1.0: Full syntax support for CFML; first public release
  • 0.1.5: Better code folding support (as described above)
  • 0.2.0: Auto-completion for (most) CFML tags
  • 0.3.0: Function insight for (most) CFML functions

You might notice I haven’t included the desired support for highlighting known variables in defined language scopes (e.g., my “cgi.remote_Host” example) on the roadmap; this is mostly because at this time I don’t have a feel for whether anyone (other than me) cares about this and because at this point I’m not at all sure I can get there. I’ve given this a try a couple of times and have come away with implementations that mostly work but eventually break down. It’s probably one of those things I will occasionally poke at when I have a few spare cycles and if I’m successful, I will include it in some sort of interim release off the map.

Installation Notes

Komodo file mode selection list

File mode selection list, after installing Komodo-CFML -- note CFML is now available

Installing the CFML mode itself is as simple as downloading the .xpi file (below) and dragging it onto a running instance of Komodo. Komodo will warn you that you should only install extensions from sources you trust… if you’re up for it, select “Install” and Komodo will ask you to restart. Once restarted, Komodo should now have CFML as an available choice in the list of supported modes (as shown at right). Select “CFML” and start playing…

The next couple of things you will probably want to play with will be file associations and font/color selections for CFML files. Installing the editor extension registers only a single file assocation as a CFML type: .cfml files. Most of us will want .cfm and .cfc as additional extensions automatically treated as CFML files. Go to “File Associations” under “Preferences” and add both of these, selecting CFML as the language associated with each file type. Fonts and colors for the different CFML language tokens can be set on the “Fonts and Colors” panel, using the “Lang-Specific” tab and choosing CFML as the language. The Komodo-CFML extension has some example CFML embedded; that example will be shown there so you can see how CFML will be rendered.

The final step is to make Komodo aware of valid CFML tags. Komodo uses HTML-Tidy to do some of its HTML validation and by default, Tidy doesn’t know which CFML tags are to be considered valid; all CFML tags will be flagged as invalid and will be underlined with annoying squiggly red lines in the default color theme. I have pulled together a quick file defining the valid CFML tags for most of the current versions of the CFML engines (see below). Download that file, put it somewhere out of the way on your drive, and then point Komodo at it via “Preferences > Languages > HTML > Syntax Checking > Configuration File”. You can modify that file to include your own custom tags, as well, if you choose.

I’ve done all of the development of this extension using the current version of Komodo Edit (v. 5.2.x), so I’m confident that it works on that version. I’ve done a bit of testing with the extension using a recent nightly trunk build of v. 6 (still in alpha) and it works the same there, so if you’re out on the edge there, it should still be OK. I haven’t tested on earlier versions. If you are running a version earlier than 5.2, please comment with your version and experience with the extension.

Downloads

Editor extension: cfml-0.1.1-ko.xpi
HTML-Tidy CFML Configuration file: tidy-cfml.config

Release Notes and To-Do List

  • 2010.02.17: v. 0.1.1 — Updates to better handle unquoted attribute values in CFML start tags; support for nested CFML comments
  • 2010.02.15: Initial release of v. 0.1.0

Based on feedback from people using it, I’ve got the following items on my to-do list:

  • Fix problems handling (possibly invalid) unquoted attribute values in CFML start tags (Done: v. 0.1.1)
  • Support nested CFML comments (Done: v. 0.1.1)
  • Identify the specific versions (or at least a minimum version) of Komodo required by the extension

Feedback

All comments and feedback — particularly if you see oddities in the highlighting of the CFML code — are welcome. Just leave a comment below.