Has anyone found a way to use a Dart Language module with BBEdit?

158 views
Skip to first unread message

Alfredo

unread,
Jun 13, 2024, 3:41:55 PMJun 13
to BBEdit Talk
I do about 50% of my work under the Flutter umbrella. There are two "official" IDEs for Flutter: VS Code and Android Studio. I prefer Android Studio for compiling/linking/installing on all platforms (Android, iOS, macOS, Windows, Linux, Web/PWA).

However (and this is a big "however") I use BBEdit for all of my editing and I have configured both Android Studio and BBEdit to refresh file contents upon detecting any change. Perfect world (for me).

Flutter supports hot reload and hot restart, so it's really impressive to see that when I save a changed source file with BBEdit, I can immediately do a hot reload or hot restart with Android Studio and I can immediately see the results of my changes on whatever platform I happen to be debugging.

Magic.

I wish there were a language module for Dart (the language that Flutter uses) that I could use with BBEdit. 

For now, I switch the language mapping for a given source file between Java and JavaScript, to highlight different structural aspects in the source file and to navigate to different things using the Function Navigator. This is reasonably ok but not ideal.

Has anyone found a way to use a Dart Language module with BBEdit?

Thanks.

Alfredo

Maarten Sneep

unread,
Jun 13, 2024, 4:47:07 PMJun 13
to bbe...@googlegroups.com
Hi,

There are three methods to support a language on BBEdit: codeless language modules, specifically coded language modules and the language server protocol. The last one is probably your best bet.

Dart is not mentioned on https://www.barebones.com/support/bbedit/lsp-notes.html or in the language module library (https://www.barebones.com/support/bbedit/plugin_library.html). But if you find the LSP module that VS Code uses, then you should be able to configure BBEdit to use the same.

Kind regards,

Maarten

--
This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/235e08f7-b6b6-45c6-aecf-9ec022ffd07cn%40googlegroups.com.

Fabio Ferrero

unread,
Jun 14, 2024, 8:37:50 AMJun 14
to BBEdit Talk
I use Flutter too, happy to help to make BBEdit even better with this language!

Alfredo

unread,
Jun 14, 2024, 3:23:47 PMJun 14
to BBEdit Talk
Hartelijk dank, Maarten.

Sono contento di vedere un altro utente Flutter, Fabio.

The international friendly race is on, with at least two teams: Italy and Guatemala!  

I'll research the route that Maarten suggested.

A challenge, as Rich observed in another thread, is Micro$oft, which controls VS Code.

We'll see . . . 

Thanks to everyone.

Alfredo

Alfredo

unread,
Jun 17, 2024, 5:22:43 PM (12 days ago) Jun 17
to BBEdit Talk
This is a good starting point but it would be even better if it provided some examples for C or Java or JavaScript:


I immediately admit my total ignorance of the majority of languages mentioned in this list.

Any clues regarding some (any) examples for the function pattern along the lines of  C or Java or JavaScript?

<key>Function Pattern</key>


Thanks,

Alfredo

Alfredo

unread,
Jun 17, 2024, 5:29:11 PM (12 days ago) Jun 17
to BBEdit Talk
My motivation is to be able to use BBEdit's Function Navigator on Dart files.

Darren Duncan

unread,
Jun 18, 2024, 9:22:58 AM (11 days ago) Jun 18
to bbe...@googlegroups.com
For my part, I've already similarly created a few very simple BBEdit codeless
language modules for some documentation formats that didn't already have them,
namely Wikitext and Perl POD. Simply being able to quickly navigate to section
headings is extremely helpful for moving around files. -- Darren Duncan

Alfredo

unread,
Jun 18, 2024, 1:37:03 PM (11 days ago) Jun 18
to BBEdit Talk
That's the idea, Darren.

Unfortunately, given my (very) limited regex knowledge and (lack of) regex skills, coming up with the appropriate magic incantations for this is not quite within my horizon:

`<key>Function Pattern</key>`

I'll appreciate any guidance in this regard.

I have a pretty good set of Dart keywords for this:

`<key>BBLMKeywordList</key>`

And I stole the comments section from the C# that BBEdit provides:

```
        <key>Comment Pattern</key>
        <string><![CDATA[
    (?x:
                (?> // .* $ ) |
                (?> /\* (?s:.*?) (?: \*/ | \z ) )
)
        ]]></string>
```

A Dart source file looks reasonably acceptable, but still no BBEdit Function Navigator yet (as expected).

Poquito a poquito . . . 

Alfredo

Rich Siegel

unread,
Jun 18, 2024, 1:44:31 PM (11 days ago) Jun 18
to BBEdit Talk
On 18 Jun 2024, at 13:37, Alfredo wrote:

> That's the idea, Darren.
>
> Unfortunately, given my (very) limited regex knowledge and (lack of) regex
> skills, coming up with the appropriate magic incantations for this is not
> quite within my horizon:

Have you considered asking ChatGPT? :-)

It says:

(?<leading_whitespace>^\s*)(?<function_signature>(?:\w+\s+)?\w+\s+(?<function_name>\w+)\s*\([^)]*\)\s*{(?:(?!{).)*})(?<function_body>[\s\S]*?)

(NB: you will need to change the names of the capture groups to correspond to the requirements stated in the CLM documentation; and caveat lector: I have not tried this to see if it even works.)

R.
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/15799913-ab7b-4cc8-8539-376d45524523n%40googlegroups.com.


--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <https://www.barebones.com/>

Someday I'll look back on all this and laugh... until they sedate me.

Alfredo

unread,
Jun 18, 2024, 3:28:57 PM (11 days ago) Jun 18
to BBEdit Talk
Excellent suggestion, Rich.

I'm playing around with various of our mutual robot friend's proposals.

One of them looks promising:

<key>Function Pattern</key>
<string>\b(?:void|[\w<>\[\]]+)\s+(\w+)\s*\([^)]*\)\s*(?=\{|\=>)</string>

But the syntax checker complains about the "<" in

[\w<>\[\]]

Unencoded entity found; “<” needs to be encoded as “&lt;”

Fair enough. If I change the pattern to this:

<key>Function Pattern</key>
<string>\b(?:void|[\w&lt;>\[\]]+)\s+(\w+)\s*\([^)]*\)\s*(?=\{|\=>)</string>

the syntax checker doesn't complain but BBEdit's Function Navigator doesn't navigate functions (after a BBEdit restart, of course).

Patience, patience, . . . 

Any brave soul interested in sculpting the expression that Rich shared?

Thanks.

Alfredo

Darren Duncan

unread,
Jun 19, 2024, 8:31:41 AM (10 days ago) Jun 19
to bbe...@googlegroups.com
A key trick to deal with the entity encoding issues is use a CDATA block, like this:

<key>Function Pattern</key>
<string><![CDATA[(?xs:
...
)]]></string>

Where you replace the ... with the pattern you wanted, which can also be spread
across multiple lines for readability.

Inside CDATA you don't need to use XML/HTML entities like &lt;, you just write
your less-thans normally etc.

-- Darren Duncan

Ulrich Kapp

unread,
Jun 19, 2024, 8:31:42 AM (10 days ago) Jun 19
to BBEdit Talk
Hi Alfredo,

I just entered this discussion and have the following question:

Did you already try to use the Dart language server (https://github.com/serverpod/lsp_server) with BBEdit?
Maybe this will help your needs.

Ulrich

Alfredo

unread,
Jun 20, 2024, 1:38:12 PM (9 days ago) Jun 20
to BBEdit Talk
This did the trick. Thanks, Darren.

I have attached a plist file that (at least for my needs) works perfectly.

I chose the <key>Function Pattern</key> contents among several that good-old ChatGPT suggested. Excellent tip, Rich.

I'll appreciate any suggestions for improvement.

So far, so good.

Alfredo

Dart.plist

Alfredo

unread,
Jun 20, 2024, 1:41:02 PM (9 days ago) Jun 20
to BBEdit Talk
That language server is a bit above my pay scale.

Does anyone have a clue regarding how to extract (from the Dart language server that Ulrich mentioned) the relevant info for a BBEdit Codeless Language Module?

Thanks,

Alfredo

Alfredo

unread,
Jun 20, 2024, 4:30:34 PM (9 days ago) Jun 20
to BBEdit Talk
Hmmm... Along the way between my iCloud Drive and this BBEdit Google Group, somebody somehow seems to have changed the file. Here it goes as a zip file.

I also had a copy/paste bug in a comment for keywords that reflected the original c# template that I stole from BBEdit's sample: c# keywords ==>> Dart keywords

Oh, well . . . 

Alfredo

Dart.plist.zip

Rich Siegel

unread,
Jun 20, 2024, 5:06:46 PM (9 days ago) Jun 20
to BBEdit Talk
On 20 Jun 2024, at 13:41, Alfredo wrote:

> That language server is a bit above my pay scale.
>
> Does anyone have a clue regarding how to extract (from the Dart language
> server that Ulrich mentioned) the relevant info for a BBEdit Codeless
> Language Module?

This seems to old some clues: <https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md>

Thus, a suitable key in the language module might look like:

<key>BBLMLanguageServerInfo</key>
<dict>
<key>ServerCommand</key>
<string>dart</string>

<key>ServerArguments</key>
<array>
<string>language-server</string>
<string>--client-id com.barebones.bbedit</string>
<string>--client-version 15</string>
</array>
</dict>

(You should test and verify, of course.)

R.
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/345977dc-66d9-4f14-978c-8b49e10785e4n%40googlegroups.com.

Alfredo

unread,
Jun 20, 2024, 8:04:23 PM (9 days ago) Jun 20
to BBEdit Talk
Nice, Rich.

This works great. Now, of course, "one more thing".

How can I nudge BBEdit to display these "NOTE:" pieces of info on the Function Navigator?

ListTile( // NOTE: Report Log

I attach my slimmed-down version. I'll see if it makes through the maze unscathed.

Thanks.

Alfredo

Dart.plist

Rich Siegel

unread,
Jun 20, 2024, 9:18:08 PM (9 days ago) Jun 20
to BBEdit Talk
On 20 Jun 2024, at 20:04, Alfredo wrote:

> Nice, Rich.
>
> This works great. Now, of course, "one more thing".
>
> How can I nudge BBEdit to display these "NOTE:" pieces of info on the
> Function Navigator?
>
> ListTile( // NOTE: Report Log

Codeless languages modules don't support this; sorry.

R.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/3e937a7b-1458-4598-b495-43fef43f7a74n%40googlegroups.com.

Alfredo

unread,
Jun 20, 2024, 11:24:23 PM (9 days ago) Jun 20
to BBEdit Talk
Good to know, Rich.

I can always change the file's language to JavaScript to navigate my notes.

The way BBEdit handles (most of) the Dart language elements is sufficiently good for my needs.

I pass the baton now to Fabio, in case he's interested in modifying the Dart.plist file.

Given that the plain file gets modified by some overly enthusiast member of the communications chain, I enclose it as a ZIP file. Please ignore previous versions of this file that you may have downloaded.

Enjoy,

Alfredo
Dart.plist

Alfredo

unread,
Jun 22, 2024, 3:11:27 PM (7 days ago) Jun 22
to BBEdit Talk
Hmmm. . . 

The next (obvious) question then becomes: 

Which language modules support the inclusion of "commented notes" (or whatever the proper technical name happens to be) in BBEdit's Function Navigator?

Is that even possible for mere mortals?

Any hints on how to start exploring that topic?

Thanks.

Alfredo

Rich Siegel

unread,
Jun 22, 2024, 3:19:37 PM (7 days ago) Jun 22
to BBEdit Talk
On 22 Jun 2024, at 15:11, Alfredo wrote:

> Hmmm. . .
>
> The next (obvious) question then becomes:
>
> Which language modules support the inclusion of "commented notes" (or
> whatever the proper technical name happens to be) in BBEdit's Function
> Navigator?
>
> Is that even possible for mere mortals?

Callout generation is handled during function scanning; it depends on the implementation but most of BBEdit's built-in languages support them.

> Any hints on how to start exploring that topic?

<https://github.com/siegel/LanguageModuleSDK>.

R.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/0fd5adf9-969d-41db-b9b7-4b82be2824e5n%40googlegroups.com.

Alfredo

unread,
Jun 22, 2024, 6:22:46 PM (7 days ago) Jun 22
to BBEdit Talk
Excellent, Rich.

Thanks very much.

Alfredo

Alfredo

unread,
Jun 22, 2024, 7:52:39 PM (7 days ago) Jun 22
to BBEdit Talk
I browsed through the (terse ;-) compiled plug-in examples for Python, Setext and TeX.

While trying to find some (any!) kind of clue, I searched for "keywords" in Rich's entire LanguageModuleSDK and I noticed that Examples/PythonMachO/Info.plist is the only file that has "<key>Keywords</key>" with some of the usual suspects for Python. No other file has "<key>Keywords</key>". 

Any idea how to specify a language's keywords? (I probably need stronger reading glasses and the answer is probably staring at me, but I fail to see it.)

Even better: Any suggestions for finding some (any!) example of a compiled plug-in example for a C-family language such as JavaScript (which supports the all-important "// NOTE:" feature) ?

Thanks,

Alfredo

Gil Dawson

unread,
Jun 22, 2024, 7:59:37 PM (7 days ago) Jun 22
to bbe...@googlegroups.com
Hi--

The following snippet does what I expect in both Firefox and Safari...

PastedGraphic-1.png

...However, BBEdit gets the following errors...

PastedGraphic-2.png

...when I click Markup -> Check -> Document Syntax ^⌘Y

I wonder whether why?

Maybe my html file's preamble...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

...might have something to do with this?

--Gil



Gil Dawson

unread,
Jun 22, 2024, 9:50:55 PM (7 days ago) Jun 22
to bbe...@googlegroups.com
I found it!

From W3Schools...

In HTML 5, the declaration is simple:

<!DOCTYPE html>

That seems to clear the problems below (and introduce others), but what can you expect from a 15-year-old html file?

--Gil
Reply all
Reply to author
Forward
0 new messages