Skip to content

Commit 085711f

Browse files
authored
feat: add lsp blog (#215)
1 parent e0d13f7 commit 085711f

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed
84.5 KB
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: "Language Server Protocol (LSP): How Editors Speak Code"
3+
slug: "language-server-protocol-lsp-how-editors-speak-code"
4+
date: 2025-08-15
5+
authors: ["Ansh Arora"]
6+
tags: ["Makim", "Automation", "Developer Experience"]
7+
categories: ["Devops", "Dev Tools"]
8+
description: |
9+
The Language Server Protocol (LSP) powers modern code editors like VS Code by
10+
enabling real-time autocompletion, hover info, diagnostics, and more.
11+
thumbnail: "/header.png"
12+
template: "blog-post.html"
13+
---
14+
15+
# Language Server Protocol (LSP): How Editors Speak Code
16+
17+
When you open a code file in VS Code and get real-time suggestions, hover
18+
tooltips, or error squiggles, have you ever wondered **how** your editor
19+
understands the language you’re writing in?
20+
21+
This magic isn’t hardcoded per-language into the editor. Instead, it’s often
22+
powered by something called the **Language Server Protocol (LSP)**.
23+
24+
Let’s dive into what LSP is, why it exists, and how it powers modern development
25+
environments.
26+
27+
## What is the Language Server Protocol?
28+
29+
The **Language Server Protocol (LSP)** is a standardized way for development
30+
tools (like VS Code, Vim, or Emacs) to communicate with language-specific
31+
services (called language servers).
32+
33+
Instead of writing new editor plugins for every language and every editor, **LSP
34+
decouples the logic**:
35+
36+
- The **editor (client)** handles the UI and editor behavior.
37+
- The **language server** handles parsing, validation, completions, and other
38+
language-specific logic.
39+
40+
They talk to each other via a common JSON-RPC protocol over standard
41+
input/output, TCP, or WebSockets.
42+
43+
## Why was LSP created?
44+
45+
Before LSP, supporting multiple languages across editors was a mess:
46+
47+
- Each editor needed custom plugins.
48+
- Each language had to build and maintain these plugins.
49+
50+
This was inefficient and hard to maintain.
51+
52+
**Microsoft introduced LSP in 2016**, alongside VS Code, to fix this
53+
fragmentation. Now, language authors can focus on building a single LSP server,
54+
and editors can plug into it easily.
55+
56+
![LSP Languages and Editors](https://code.visualstudio.com/assets/api/language-extensions/language-server-extension-guide/lsp-languages-editors.png)
57+
58+
## Core Features of LSP
59+
60+
Here are some features LSP enables out-of-the-box:
61+
62+
- Autocompletion
63+
- Go to Definition
64+
- Hover Information
65+
- Diagnostics (errors/warnings)
66+
- Formatting
67+
- Find References
68+
- Rename Symbol
69+
- Signature Help
70+
71+
These features work **consistently across any editor** that supports!
72+
73+
## How Does It Work?
74+
75+
Here's a simplified lifecycle of how an editor (client) talks to a language
76+
server:
77+
78+
1. **Editor launches the language server.**
79+
2. **Sends an `initialize` request** to begin communication.
80+
3. As you edit:
81+
82+
- Sends `textDocument/didOpen`, `didChange`, or `didSave`.
83+
- Receives back diagnostics or suggestions.
84+
85+
4. On hover, completion, or definition jumps:
86+
87+
- Sends `textDocument/hover`, `completion`, or `definition` requests.
88+
- Displays server responses in the UI.
89+
90+
All of this happens over a well-defined set of JSON-RPC messages.
91+
92+
### Anatomy of a Language Server
93+
94+
A language server is just a **program** that:
95+
96+
- Parses the user’s code (possibly building an AST or symbol table).
97+
- Responds to LSP method calls.
98+
- Tracks open files and their versions.
99+
100+
## Final Thoughts
101+
102+
The Language Server Protocol has quietly become the **backbone of modern
103+
developer tooling**. Whether you’re building an IDE, a DSL, or a configuration
104+
tool, LSP lets you ship a polished editing experience with far less effort.
105+
106+
If you're working on your own language, plugin, or platform, building an LSP
107+
server is one of the smartest investments you can make.

0 commit comments

Comments
 (0)