New LSP language service supporting Swift and C-family languages for any editor and platform

This sounds like great news But as someone a couple rungs down from this level, could someone please give some practical examples of how this could prove beneficial? Obviously one is that other IDEs can now support Swift more easily. But what other doors could this open?

No, since no one who writes Swift in Xcode can possibly be unaware of it, and fixing it should be a matter of basic QA imho, and I already spend too much time reporting (less obvious compiler) bugs.

Another example of a common auto indent annoyance
let a = [1, 2, 3]
let b = a.filter { (element) in
    element % 2 == 0
    }
    .map { (element) -> String in
        String(element)
}
print(b)
4 Likes
Or something like this in string literals which makes pasting formatted json strings in Xcode a pain.
// caused by typing the `:`
let test = """
test:
  """
3 Likes

To me (a teacher) it means I will finally be able to teach Swift as a programming language on its own, and not just as part of an iOS course. Yes, Windows support is still missing, and that's a big issue, but unlike macOS, Linux is easy to install on any hardware (or a VM), so teaching a complete Swift course on Linux is finally possible.

CLion's next release (currently in early access preview) already ticks most of my boxes, but for non-CS students (or high school), I need something simpler, like VS Code or Atom.

6 Likes

Any plans to combine efforts with GitHub - RLovelett/langserver-swift: A Swift implementation of the open Language Server Protocol.

Another major benefit is to focus disparate efforts and have a common infrastructure to collaborate for awesome tooling support of Swift.

1 Like

The Swift for TensorFlow team has a job offer for engineers with experience on “Windows platform support”, which is interesting
 There's hope! :slight_smile:

5 Likes

This is excellent news! I will very much be looking forward to the Sublime integration for development on Linux.

I hope all members of the community are interested in working together on a combined effort. Several people have invested time into solutions in this area.

One of the things that I would like to emphasize is that more of the Swift tooling support in Xcode currently supported by SourceKit will have far more of that core functionality in the open source service (e.g., the global index and global refactoring operations) once we move to an LSP-based implementation. @akyrtzi mentioned this in the original post but that important nuance may been missed. Consequently, the LSP service @akyrtzi is describing will be functionally more powerful than SourceKit is today.

13 Likes

Extremely exciting news for Swift enthusiasts. I have a question more towards Xcode: would it open a door to use Xcode for other languages? For example, Rust is a low level language I find very useful for embedded/IoT. I use some shared code with Rust/Swift & connecting using C ABI.
I also like Xcode and would like to use it to edit Rust. It has its own implementation of LSP (rls). I was wondering if adding support for LSP would make Xcode more open to other languages having LSP implementations.

1 Like

Theoretically it should, but whether the Xcode team decides to support such a thing is completely different. I wouldn’t think so.

Hopefully they'll at least add better editor support for things already technically supported like Java, XML, JSON, etc.

OR...finally have an actual plugin platform like every other IDE and editor...but I'll take what I can get. :slightly_smiling_face:

Getting Xcode to use our new LSP service should make it viable to use other LSP services as well, and it’s something that we are interested in, but we don’t have specific plans to announce at this moment. Our primary focus will be to get the new LSP service integrated and a complete replacement for the existing internal mechanism.

20 Likes

Will it be able to have code completion for such module which is exporting a C library? :thinking:

I'm not sure what you mean - completion in the C code, completion in Swift code that imports it? Both should work, although to complete in the module we need to be able to import it.

Several connected questions from IDE makers:

  1. Are there any plans to have the index/cache format description, so it could be used also outside the LSP server if needed?
  2. Do you plan to make extension points allowing to extend the cache/index/LSP functionality without building a custom toolchain (applies to both OSS toolchains and the one bundled in the Xcode)?
  3. Are there any plans to combine the LSP direction with further evolution of Xcode Source Editor extensions and/or making another plugin system allowing to:

a. Add custom UI components in Xcode
b. Use editor API and extend it (not only actions, but also highlighting, completion, etc)

LSP is great to deliver the most of general editor functionality, but next, some tool creators will need to extend it and integrate into existing IDEs and editors - including Xcode. Say, what if one wants to have a semantic highlighting in Xcode when different variables have different colors? He will need to extend the core, next make an extension for LSP protocol, next change how the highlighting behaves in the Xcode, implements custom settings, and for that he needs the ability to extend the UI as well.

2 Likes

We will provide a library usable via a C and Swift API that provides access to the index database.

This is beyond what we are committed in delivering as part of this announcement. I'd recommend to make your enhancement requests known to the Xcode team via https://bugreport.apple.com, if you haven't already.

@blangmuir, what does the "d" at the end stand for here?

2 Likes

@anthonylatsis deamon

6 Likes

i have always wondered this

1 Like