Nadeeshaan Gunasinghe and Nipuna Marcus
Language Server Protocol and Implementation
Supporting Language-Smart Editing and Programming Tools
1st ed.
Logo of the publisher
Nadeeshaan Gunasinghe
Walahanduwa, Sri Lanka
Nipuna Marcus
Mawathagama, Sri Lanka
ISBN 978-1-4842-7791-1 e-ISBN 978-1-4842-7792-8
https://doi.org/10.1007/978-1-4842-7792-8
Nadeeshaan Gunasinghe and Nipuna Marcus 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
To our beloved parents who always were behind us and Kasun Indrasiri who always was an inspiration and a role model
Introduction
The Language Server Protocol (LSP) has been one of the most talked about topics during the past few years when it comes to the tooling for programming languages. With the advancement of the developer tools and the programming languages, developers started to rely more and more on advanced tools and enhanced language services. When we consider one of the most focused branches of developer tools which is IDEs and text editors, there are many vendors who have released various editing tools in the past couple of decades. When we consider the number of programming languages along with the number of smart editors nowadays, in order to support language intelligence among the editors, these vendors have to repeat the same thing. The Language Server Protocol was introduced to solve this particular problem, and today it has become the norm of the development tools language intelligence provider. By adopting the LSP, tools such as text editors and integrated development environments (IDEs) could expand the capabilities and avoid the users burden of switching between the development tools for trying new programming languages and frameworks.
This book is for the developers who are passionate about developing programming language tools. In this book, we provide the readers a comprehensive understanding about the Language Server Protocol and how to develop a Language Server from scratch. The readers will be guided with code samples to provide a better understanding about the server implementation by adhering to the user experience best practices as well as the LSP best practices. The readers are expected to use the book along with the example implementation, in order to get a better understanding about the concepts described in the book. In the example implementation, the book refers to VS Code as the client; however, the readers can use any other client and integrate the server implementation as desired.
The chapters of the book have been ordered to capture various aspects of the developer experience when it comes to the programming language tooling, and the LSP operations and features are categorized under these aspects. The readers are not overwhelmed by including the code snippets of the data structures in the LSP and it is recommended to refer to the official documentation of the Language Server Protocol for the data structures.
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/978-1-4842-7791-1. For more detailed information, please visit http://www.apress.com/source-code.
Acknowledgments
We would first like to thank Jonathan Gennick, Assistant Editorial Director at Apress, for evaluating and accepting our proposal for this book. We would also like to thank Laura Berendson, Development Editor at Apress, and Nirmal Selvaraj, Project Coordinator, for guiding us toward the end. Andres Sacco served as the Technical Reviewer. Thank you, Andres, for making sure we did our best.
Kasun Indrasiri, Software Architect and author of Microservices for the Enterprise and GRPC: Up and Running, inspired us to work on this book and mentored us throughout the process. We are eternally grateful to Kasun Indrasiri for the guidance and support.
Finally, we would like to thank our families and parents as, without them, none of our life achievements would be possible.
Table of Contents
About the Authors
Nadeeshaan Gunasinghe
is Technical Lead at WSO2 and has more than five years of experience in enterprise integration, programming languages, and developer tooling. He leads the Ballerina Language Server team and is a key contributor to Ballerina, which is an open source programming language and platform for the cloud, and he is an active contributor to the WSO2 Enterprise Service Bus.
Nipuna Marcus
is Technical Lead at WSO2 and has more than five years of experience in front-end development, programming languages, and developer tooling. He was a member of the Ballerina Language Server team and a key contributor to the Ballerina programming language.
About the Technical Reviewer
Andres Sacco
has been working as a developer since 2007 in different languages including Java, PHP, Node.js, and Android. Most of his background is in Java and the libraries or frameworks associated with this language, for example, Spring, Hibernate, JSF, and Quarkus. In most of the companies that he worked for, he researched new technologies in order to improve the performance, stability, and quality of the applications of each company.