# Using Github's Atom as a Swift IDE for Linux and Mac

**URL:** <https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481>\
**Category:** Using Swift\
**Created:** [December 12, 2015, 5:28pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481 "2015-12-12T17:28:15Z")\
**Posts on this page:** 12\
**Page:** 3

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [May 25, 2018, 9:16am UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/41 "2018-05-25T09:16:25Z")

</div>

> [@taylorswift](#):
>
> I was able to get [a simple C program](https://github.com/kelvin13/atomic-blonde/blob/master/c/blonde.c) calling into `libSourceKitInProc.so` running so the next step is basically getting it to compile under node.js and apm and writing the javascript nan bindings for it

Yeah, a `sourcekit` node module would be ideal. I think Ryan Lovelett was aiming to [do something like that](https://www.npmjs.com/package/node-sourcekit), but I'm not sure what the status of it is.

---

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [May 25, 2018, 9:25am UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/42 "2018-05-25T09:25:10Z")

</div>

Also some relevant discussion [here](https://github.com/RLovelett/node-sourcekit/issues/2) I think (Brian - [@modocache](https://github.com/modocache) - is the person responsible for nuclide-swift I think).

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 25, 2018, 8:08pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/43 "2018-05-25T20:08:38Z")

</div>

i know, i’ve figured most of that out in the last 48 hours or so. I process the data in C and then just pass (row, column) marker ranges to the javascript which handles the Atom UI highlighting. Node.js/APM builds the module cleanly with Nan and V8. Probably the more efficient way to do it compared with parsing SourceKitten output. The only real issue remaining is figuring out how to get more detailed highlighting that doesn’t treat `foo` and `self` and `$0` the same and knows about stdlib symbols. And a weird Nan bug that seems to corrupt UTF8 strings if they’re exactly 342 characters or longer.

The code is here btw: [atomic-blonde/blonde.cpp at master · kelvin13/atomic-blonde · GitHub](https://github.com/kelvin13/atomic-blonde/blob/master/cpp/blonde.cpp)

Another potential problem is linking with the Swift runtime libraries. People seem to install them all over the place (mine live in `$HOME/tools/swift/usr/lib` for example) which makes `-rpath` not work

---

<div class="post-metadata">

**Author:** ![felix91gr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/felix91gr/32/443_2.png) [@felix91gr](https://forums.swift.org/u/felix91gr)\
**Post date:** [May 25, 2018, 8:13pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/44 "2018-05-25T20:13:19Z")

</div>

I think you'd maybe want syntax highlighting to be done from a regex parser because regex are easier to analyze and a regex parser would almost certainly outperform something more complex like SK at this task.

Can't the general context-sensitive tooling be done with SK and the more specific regex-tied tooling be done with a parser and a syntax (YAML I think is the standard?) file?

Edit: that's my best guess as to why SK seems to not be designed for syntax highlighting

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 25, 2018, 8:21pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/45 "2018-05-25T20:21:14Z")

</div>

we could probably treat `self` and `$` as special cases (hacky) but highlighting standard library symbols is going to be more problematic. that said, the current `language-swift89` isn’t much better at it,, it gives way too many false-positives (and basically breaks every time a new Swift Evolution proposal gets implemented) for me to be happy with it just by the fact that stdlib symbols like `min` get overloaded so often in user code. But that would require more sophisticated name resolution beyond simple syntax parsing

---

<div class="post-metadata">

**Author:** ![felix91gr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/felix91gr/32/443_2.png) [@felix91gr](https://forums.swift.org/u/felix91gr)\
**Post date:** [May 25, 2018, 8:32pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/46 "2018-05-25T20:32:43Z")

</div>

> [@taylorswift](#):
>
> But that would require more sophisticated name resolution beyond simple syntax parsing

Okay, yeah. You're right. Hmm. How about using an AST-aware tool, like @harlanhaskins's?

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 25, 2018, 8:49pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/47 "2018-05-25T20:49:20Z")

</div>

There really isn’t a good solution to this because you can define `min(_:_:)` in another file in the same module and all of a sudden `min(_:_:)` and `Swift.min(_:_:)` are two completely different symbols. `language-swift89` currently treats all occurences of `min` as a standard library symbol, unless a `.` comes before it, unless `Swift` comes before the `.`, which is maybe 75% accurate

---

<div class="post-metadata">

**Author:** ![felix91gr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/felix91gr/32/443_2.png) [@felix91gr](https://forums.swift.org/u/felix91gr)\
**Post date:** [May 25, 2018, 8:52pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/48 "2018-05-25T20:52:43Z")

</div>

Oh damn

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 26, 2018, 7:37am UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/49 "2018-05-26T07:37:39Z")

</div>

More syntax highlighting fun:

The atom plugin is basically fully functional and you can test it here: [atomic-blonde](https://atom.io/packages/atomic-blonde)

 ![Screenshot%20from%202018-05-25%2023-47-59](https://global.discourse-cdn.com/swift/original/2X/a/adc5893823211a381d6120454d0143fbe3a81017.png)

`atomic-blonde` seems to be a bit slower than the `language-swift89` grammar. The SourceKit highlighter has a latency of about 11ms per keypress. The old regex one by comparison takes just 3ms.

Here’s a time graph of the SourceKit highlighter (each lobe containing a green rectangle represents one highlighter cycle, 3 cycles are shown):

 ![Screenshot%20from%202018-05-26%2000-31-16](https://global.discourse-cdn.com/swift/original/2X/0/04f696c260ea2c42cdc16691ceb3095ae5d8b09e.png)

(Un)surprisingly, over 90% of the extra time is spent in javascript, mostly in calls to clearing and constructing marker layers in the Atom interface. The actual call to `blonde`, the C++ module that calls SourceKit and does additional processing, takes less than a millisecond. (It’s the tiny yellow rectangle at the bottom outlined in blue.)

---

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [May 28, 2018, 11:15am UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/50 "2018-05-28T11:15:40Z")

</div>

> [@taylorswift](#):
>
> Another potential problem is linking with the Swift runtime libraries. People seem to install them all over the place (mine live in `$HOME/tools/swift/usr/lib` for example) which makes `-rpath` not work

Could you trigger the build of the cpp on demand, rather than as part of the apm install? That way you can make the location of the runtime libraries a configuration that people can edit in Atom's settings UI.

---

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [May 28, 2018, 11:17am UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/51 "2018-05-28T11:17:40Z")

</div>

(this approach looks great by the way - I think I'll do something similar, with the bare minimum of the SourceKit calls that I need)

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [May 28, 2018, 9:21pm UTC](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481/52 "2018-05-28T21:21:23Z")

</div>

user would have to have clang++ or g++ installed no?

[Previous page](https://forums.swift.org/t/using-githubs-atom-as-a-swift-ide-for-linux-and-mac/481.md?page=2)
