Keyword, comment, and string highlighting work. Classes, structs, enums, functions, and extensions are indexed. Functions can be folded.
- Copy the file swift.plist to ~/Library/Application Support/BBEdit/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
- Quit and relaunch BBEdit.
Now files with the extension “swift” should be syntax highlighted. The function popup menu in the navigation bar should also list all the declarations in the current file.
- Extensions are only indexed by base type. This means that multiple extensions of the same base type have the same identifier in the function popup menu.
- Identifier matching does not include the full unicode ranges allowed by the Swift language reference. Only upper and lower case A-Z, 0-9, and ‘_’ are matched. I’m sorry for the lack of diacritic and emoji support, but I haven’t yet sorted out how to convince BBEdit to handle them in Identifier and Keyword Character Class.
- Only functions can be folded.
- Nested declarations are not indented in the function pop-up. I don’t think this is possible with CLMs.
The bulk of this CLM was developed by Curt Clifton. Michael Tsai made the improvements below.
- Curt’s CLM did not show functions inside of classes, structs, or extensions, which is most of the functions that I write. This was due to the fact that BBEdit CLMs do not suported nesting. I’ve fixed this by making the
function
pattern only match the body of afunc
; for other types, it matches just up to the name. This makes it possible to show nested functions in BBEdit’s function pop-up menu. The downside is that it is no longer possible to fold classes, structs, or extensions. - The operators
==
and<
are now valid function names. - Added more keywords and pre-defined names.
- Added support for triple-quoted strings.
- Class functions show the name of the function instead of
func
.