BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Swift Adopts the Language Server Protocol

Swift Adopts the Language Server Protocol

This item in japanese

Apple's Swift team announced they are going to provide support for using Swift with the Language Server Protocol (LSP). This will open up the possibility for developers to use Swift in any editor that supports LSP with code-completion, syntax-highlighting, etc.

In addition to code completion and syntax highlighting, the Swift LSP-compliant language service will support cross language-indexing across C/C++/ObjC sources to power jump-to-definition, call-hierarchy, search-symbols, and refactoring. Apple’s team plans to bring Xcode to the new language service and extend the protocol to support Xcode editing features that are not included in LSP.

According to current plans, the Swift LSP service will use SourceKit and integrate it with Clangd, an open-source implementation of the Language Server Protocol based on Clang. The Language Server Protocol implementation for Swift is available on GitHub. Still, it is considered yet in early development and most more advanced features are not yet available.

Among the benefits of Swift LSP service, it will improve Swift usability on Linux, thus possibly improving the language adoption beyond the Apple’s ecosystem. Additionally, as a side effect of bringing LSP to Xcode, Xcode could include support for additional languages, such as C#, Rust, and many others, including a few that theoretically Xcode already supports, including XML, JSON, etc. Making Xcode LSP-compliant is not currently in the team’s focus, though.

The Language Server Protocol was originally developed at Microsoft as the protocol Visual Studio Code used to communicate with its language services. Microsoft open-sourced LSP in 2016. The big advantage LSP brings is the reusability of language services across LSP-compliant editors. This reduce significantly the effort required for a language team to make their language fully supported in a variety of editors, since they only need to implement an LSP-compliant language server that will be usable from any LSP-compliant editor.

Currently, there are over 70 LSP-compliant language servers, and many of the major programming tools support LSP, including Eclipse, emacs, GNOME Builder, Atom, vim, Visual Studio, and Visual Studio Code.

Rate this Article

Adoption
Style

BT