Skip to content

Commit feadf22

Browse files
committed
Refactor LSP Documentation for Improved Clarity and Structure
The LSP documentation page has been reorganized to improve readability, navigation, and consistency. The changes address user feedback about difficulty finding installation steps and understanding configuration requirements. **Why:** The previous documentation structure intermixed conceptual information with installation instructions, making it difficult for users to quickly find the specific language server setup they needed. The inconsistent formatting and lack of clear section hierarchy also contributed to confusion during the configuration process. **What changed:** * Restructured the entire page with a clearer hierarchy using proper Markdown heading levels * Expanded the overview section to better explain LSP concepts and provide context before diving into technical details * Reorganized language server installation instructions into dedicated subsections with consistent formatting * Improved installation steps with clearer platform-specific instructions and prerequisite requirements * Enhanced the configuration section with better-formatted tables and step-by-step procedures * Clarified CMake integration documentation with distinct options for different scenarios * Standardized terminology and wording throughout the document for consistency * Improved code block formatting and command examples for better copy-paste experience The content remains functionally equivalent but is now significantly easier to navigate and understand. * Documentation structure and formatting * Installation instructions for clangd, ctagsd, pylsp, TypeScript, rust-analyzer, and gopls * Configuration guidance (automatic and manual) * CMake integration examples ** Generated by CodeLite. ** Signed-off-by: Eran Ifrah <eran@codelite.org>
1 parent c5b3c31 commit feadf22

File tree

1 file changed

+160
-138
lines changed

1 file changed

+160
-138
lines changed

docs/docs/plugins/lsp.md

Lines changed: 160 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,213 +1,235 @@
1-
## What is Language Server?
2-
---
1+
# Language Server Protocol
2+
3+
## Overview
34

4-
From the [Language Server web site][1]: The Language Server Protocol (LSP) is used between the IDE and a language smartness provider (the server) to integrate features like auto complete, go to definition, find all references and alike into the tool
5+
The Language Server Protocol (LSP) is a standardized protocol used between development environments and language intelligence providers. It enables the integration of advanced features such as auto-completion, go-to-definition, and find-all-references directly into your development tool. For more information, visit the [Language Server Protocol website][1].
56

6-
## Install Language Servers
77
---
88

9-
Below you may find the installation instructions for the most common Language Servers,
10-
select the ones you are interested in and then [configure them in CodeLite][14]
9+
## Installing Language Servers
1110

12-
=== "clangd"
13-
`clangd` is the LSP implementation from the `clang` for `C/C++/Objective-C` team. It provide a compiler level completion with an unmatched accuracy.
14-
Visit the [project home page][7]
11+
The following sections provide installation instructions for the most commonly used language servers. After installing your desired language servers, proceed to [configure them in CodeLite](#automatic-detection).
1512

16-
**All**
13+
### clangd (C/C++/Objective-C)
1714

18-
`clangd` relies on a file named `compile_commands.json` or `compile_flags.txt`. When using CodeLite default C++ workspace
19-
CodeLite can generate this file for the current workspace:
15+
`clangd` is the official Language Server Protocol implementation from the Clang team, providing compiler-level code completion with exceptional accuracy for C, C++, and Objective-C. Visit the [clangd project page][4] for more information.
2016

21-
1. From the menu bar: `Settings` &#8594; `Code Completion ...`
22-
2. Select the option `Generate compile_commands.json file`
23-
3. Build your project
17+
#### Prerequisites
2418

25-
**Windows**
19+
`clangd` requires either a `compile_commands.json` or `compile_flags.txt` file to function. When using CodeLite's default C++ workspace, CodeLite can automatically generate this file:
2620

27-
Install `clangd` by install the recommended packages as [described here][15]
21+
1. Navigate to **Settings → Code Completion** from the menu bar
22+
2. Enable the **Generate compile_commands.json file** option
23+
3. Build your project
2824

29-
**Linux**
25+
#### Installation by Platform
3026

31-
On Linux machines, you will need to manually install `clangd` via your package manager.
32-
On `Ubuntu` and `Debian` it is usually part of the `clang-tools` package. So to install it, use the below code snippet:
27+
**Windows**
3328

34-
```bash
35-
sudo apt-get update
36-
sudo apt-get install clang-tools
37-
```
29+
Install `clangd` by installing the recommended packages as [described in the documentation][15].
3830

39-
Once installed, follow the steps in the [manual configuration section](#manual-configuration)
31+
**Linux**
4032

41-
!!! Note
42-
Often, the `clang-tools` package comes with a version number, e.g. `clang-tools-10`
43-
Make sure to install the one with the highest number
33+
Install `clangd` manually using your distribution's package manager. On Ubuntu and Debian, it is typically part of the `clang-tools` package:
4434

45-
**macOS**
35+
```bash
36+
sudo apt-get update
37+
sudo apt-get install clang-tools
38+
```
4639

47-
On macOS, `clangd` is provided as part of the `llvm` formula. To install it (via `brew`):
40+
After installation, proceed to the [manual configuration section](#manual-configuration).
4841

49-
```bash
50-
brew install llvm
51-
```
42+
!!! Note
43+
The `clang-tools` package often includes a version number (e.g., `clang-tools-10`). Install the package with the highest available version number.
5244

53-
on ARM based macOS, `clangd` is placed under: `/opt/homebrew/opt/llvm/bin/clangd`
45+
**macOS**
5446

47+
On macOS, `clangd` is provided as part of the `llvm` formula. Install it using Homebrew:
5548

56-
=== "ctagsd"
57-
`ctagsd` is CodeLite's builtin code completion engine for `C/C++` that implements the Language Server Protocol.
58-
`ctagsd` is installed along with CodeLite on all platforms.
49+
```bash
50+
brew install llvm
51+
```
5952

60-
CodeLite configures `ctagsd` for you, but it is disabled by default. To enable it:
53+
On ARM-based macOS systems, `clangd` is located at: `/opt/homebrew/opt/llvm/bin/clangd`
6154

62-
`Plugins` &#8594; `Settings` &#8594; `ctagsd`
55+
### ctagsd (C/C++)
6356

64-
=== "pylsp"
65-
`pylsps` is installed via `pip`. For this, you will need to install the following:
57+
`ctagsd` is CodeLite's built-in code completion engine for C/C++ that implements the Language Server Protocol. It is automatically installed with CodeLite on all platforms.
6658

67-
- python 3 installed
68-
- pip3 installed
59+
CodeLite pre-configures `ctagsd`, but it is disabled by default. To enable it:
6960

70-
```bash
71-
pip install python-lsp-server
72-
```
61+
Navigate to **Plugins → Settings → ctagsd**
7362

74-
On Windows / MSYS2, use this command:
63+
### pylsp (Python)
7564

76-
```bash
77-
pacman -S mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip mingw-w64-clang-x86_64-python-ujson
78-
pip install python-lsp-server
79-
```
65+
`pylsp` is installed via `pip` and requires Python 3 and pip3 to be installed on your system.
8066

81-
Visit the [project home page][3]
67+
**Standard Installation**
8268

83-
=== "TypeScript"
84-
- Install [`node`][11]
85-
- Type:
69+
```bash
70+
pip install python-lsp-server
71+
```
8672

87-
```bash
88-
npm install -g typescript typescript-language-server
89-
```
73+
**Windows (MSYS2)**
9074

91-
If you choose to [configure it manually][12] in CodeLite, use this as the command:
75+
```bash
76+
pacman -S mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip mingw-w64-clang-x86_64-python-ujson
77+
pip install python-lsp-server
78+
```
9279

93-
```bash
94-
typescript-language-server --stdio
95-
```
80+
Visit the [python-lsp-server project page][3] for additional information.
9681

97-
=== "rust-analyzer"
98-
`rust-analyzer` is the recommended LSP for the rust language. To install it, follow these steps:
82+
### TypeScript
9983

100-
- [Install rust][13]
101-
- Open a terminal and type:
84+
**Prerequisites**
10285

103-
- On `macOS` and `Linux`:
104-
```bash
105-
rustup update
106-
rustup +nightly component add rust-src rust-analyzer-preview
107-
```
86+
- [Install Node.js][11]
10887

109-
- On `Windows`, we build it from sources. Open `MSYS2` terminal and type:
110-
```bash
111-
pacman -Sy mingw-w64-clang-x86_64-rust mingw-w64-clang-x86_64-rust-src
112-
```
88+
**Installation**
11389

114-
You should now have `rust-analyzer` installed under `rustup` local folder, for example, under `Linux` or `macOS`,
115-
it can be found here:
90+
```bash
91+
npm install -g typescript typescript-language-server
92+
```
11693

117-
```bash
118-
TARGET=$(rustup target list|grep installed|cut -d" " -f1)
119-
$HOME/.rustup/toolchains/nightly-$TARGET/bin/rust-analyzer
120-
```
94+
If you choose to [configure it manually][12] in CodeLite, use the following command:
12195

122-
=== "gopls"
123-
`gopls` (pronounced "Go Please") is the official LSP for `golang`
96+
```bash
97+
typescript-language-server --stdio
98+
```
12499

125-
To install it:
126-
```bash
127-
go install golang.org/x/tools/gopls@latest
128-
```
100+
### rust-analyzer (Rust)
129101

130-
---
102+
`rust-analyzer` is the recommended Language Server Protocol implementation for the Rust language.
131103

132-
## Automatic detection
133-
---
104+
**Prerequisites**
134105

135-
Once you have installed your favourite Language Servers, its time to tell CodeLite about it:
106+
- [Install Rust][13]
136107

137-
- Goto `Plugins` &#8594; `Language Server` &#8594; `Settings`
138-
- Click on the `Scan` button
108+
**Installation**
139109

140-
## Manual configuration
141-
---
110+
**macOS and Linux**
111+
112+
```bash
113+
rustup update
114+
rustup +nightly component add rust-src rust-analyzer-preview
115+
```
116+
117+
**Windows**
118+
119+
Build from sources using the MSYS2 terminal:
120+
121+
```bash
122+
pacman -Sy mingw-w64-clang-x86_64-rust mingw-w64-clang-x86_64-rust-src
123+
```
124+
125+
**Locating the Binary**
126+
127+
After installation, `rust-analyzer` is located in the rustup local folder. On Linux and macOS, you can find it using:
128+
129+
```bash
130+
TARGET=$(rustup target list|grep installed|cut -d" " -f1)
131+
$HOME/.rustup/toolchains/nightly-$TARGET/bin/rust-analyzer
132+
```
133+
134+
### gopls (Go)
135+
136+
`gopls` (pronounced "Go Please") is the official Language Server Protocol implementation for Go.
137+
138+
**Installation**
139+
140+
```bash
141+
go install golang.org/x/tools/gopls@latest
142+
```
142143

143-
The above instructions are for the most common language servers. However, you can install
144-
and configure any server the follows the LSP protocol. You will however, need to do this manually:
145-
146-
- Install the LSP you want on your computer. You can [visit this site][2] to get a complete list of all LSP implementations out there
147-
- From the main menu, `Plugins` &#8594; `Language Server` &#8594; `Settings...`
148-
- Click on the `Add` button
149-
- In the dialogue that opens, fill the mandatory fields:
150-
151-
Field | Mandatory | Description
152-
--------|-----------|-------------
153-
Enabled | &#10003; | Is this LSP enabled?
154-
Name | &#10003; | Provide a descriptive name for this LSP
155-
Remote server| - | When enabled, the `Command` is executed on a remote machine
156-
Command | &#10003; | The LSP execution command. For example, for `clangd`, the command can be as simple as `/usr/bin/clangd`
157-
Working directory | - | Path to set before running the command
158-
Languages | &#10003; | Since CodeLite can have multiple LSP configured, you can associate each LSP with a language. CodeLite will use the proper LSP based on the current file's language. Use the `...` button to see a list of supported languages
159-
Connection string| &#10003; | Defines the protocol that CodeLite communicates with the LSP. Most of the LSP servers out there supporting the `stdio` protocol
160-
Display diagnostics | - | When checked, CodeLite will display little red arrows next to potential code errors
161-
162-
## Resolving conflicts
163144
---
164145

165-
It is allowed to configure multiple language servers for the same coding language (e.g. `ctagsd` and `clangd` for `C++`).
166-
But make sure you only have one enabled at at time
146+
## Configuration
147+
148+
### Automatic Detection
149+
150+
After installing your preferred language servers, configure CodeLite to detect them automatically:
151+
152+
1. Navigate to **Plugins → Language Server → Settings**
153+
2. Click the **Scan** button
167154

155+
### Manual Configuration
156+
157+
You can install and configure any language server that implements the LSP protocol. For a complete list of available LSP implementations, visit [this resource][2].
158+
159+
**Configuration Steps**
160+
161+
1. Install the desired LSP on your system
162+
2. Navigate to **Plugins → Language Server → Settings**
163+
3. Click the **Add** button
164+
4. Fill in the required fields in the dialog:
165+
166+
| Field | Mandatory | Description |
167+
|-------|-----------|-------------|
168+
| Enabled || Enable or disable this LSP |
169+
| Name || Provide a descriptive name for this LSP |
170+
| Remote server | - | When enabled, the command is executed on a remote machine |
171+
| Command || The LSP execution command (e.g., `/usr/bin/clangd` for clangd) |
172+
| Working directory | - | Path to set before running the command |
173+
| Languages || Associate this LSP with specific languages. Use the `...` button to view supported languages |
174+
| Connection string || Protocol used for communication (most LSP servers support `stdio`) |
175+
| Display diagnostics | - | When checked, CodeLite displays error indicators in the editor |
176+
177+
### Resolving Conflicts
178+
179+
Multiple language servers can be configured for the same programming language (e.g., both `ctagsd` and `clangd` for C++). However, ensure that only one is enabled at a time to avoid conflicts.
168180

169-
## CMake `clangd` / `ctagsd`
170181
---
171182

172-
### `compile_flags.txt` & `compile_commands.json`
183+
## CMake Integration
173184

174-
`clangd` and `ctagsd` are using these two files as instructions for "how to build" any source file.
175-
`clangd` and `ctagsd` will search for these files from the active file folder and going up to the parent until it finds a match (or it can't go up any more)
185+
### Using clangd and ctagsd with CMake
176186

177-
In case both files are found on the same directory, `compile_flags.txt` takes precedence.
187+
Both `clangd` and `ctagsd` rely on `compile_flags.txt` or `compile_commands.json` files for build instructions. These language servers search for these files starting from the active file's directory and traversing up the parent directories until a match is found.
178188

179-
When using CodeLite's [default C++ workspace](../workspaces/default.md) CodeLite generate these files for your automatically once the build process is completed
189+
If both files exist in the same directory, `compile_flags.txt` takes precedence.
180190

181-
However, when using other workspaces (e.g. the [File System Workspace](../workspaces/file_system.md)) you need to provide these files (at least one of them) in order for `clangd` code completion to function.
191+
**CodeLite Default C++ Workspace**
182192

183-
If you are using `cmake` as your build system, you can add these two commands in the top level `CMakeLists.txt` file:
193+
When using CodeLite's [default C++ workspace](../workspaces/default.md), these files are generated automatically after the build process completes.
184194

185-
- At the top of your `CMakeLists.txt` add this line:
195+
**Other Workspace Types**
186196

187-
```cmake
188-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
189-
```
197+
When using other workspace types (e.g., [File System Workspace](../workspaces/file_system.md)), you must provide at least one of these files manually for `clangd` code completion to function.
190198

191-
- Or alternatively, you can pass this variable as part of `CMake` invocation line:
199+
### Generating compile_commands.json with CMake
192200

193-
```bash
194-
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 <other arguments here>
201+
To generate `compile_commands.json` using CMake, add the following to your top-level `CMakeLists.txt` file:
202+
203+
**Option 1: Modify CMakeLists.txt**
204+
205+
Add this line at the top of your `CMakeLists.txt`:
206+
207+
```cmake
208+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
195209
```
196210

197-
- and somewhere at the bottom of the top level `CMakeLists.txt` file, add this command:
211+
Add this command near the bottom of the top-level `CMakeLists.txt`:
198212

199213
```cmake
200214
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
201215
${CMAKE_SOURCE_DIR}/compile_commands.json)
202216
```
203217

204-
this way, after running `cmake`, you will get an up-to-date `compile_commands.json` file for `clangd`
218+
**Option 2: CMake Command Line**
205219

220+
Alternatively, pass the variable during CMake invocation:
206221

207-
## Generating `compile_commands.json` for a traditional `Makefile` project
208-
---
222+
```bash
223+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 <other arguments>
224+
```
225+
226+
After running CMake, an up-to-date `compile_commands.json` file will be generated for `clangd`.
209227

210-
Use the `cc-wrapper` utility that comes with CodeLite - [see the docs here][16]
228+
### Generating compile_commands.json for Makefile Projects
229+
230+
For traditional Makefile-based projects, use the `cc-wrapper` utility included with CodeLite. Refer to the [cc-wrapper documentation][16] for detailed instructions.
231+
232+
---
211233

212234
[1]: https://langserver.org/
213235
[2]: https://langserver.org/#implementations-server
@@ -224,4 +246,4 @@ Use the `cc-wrapper` utility that comes with CodeLite - [see the docs here][16]
224246
[13]: /misc/install_rust
225247
[14]: #automatic-detection
226248
[15]: /getting_started/windows/#common
227-
[16]: /misc/cc_wrapper
249+
[16]: /misc/cc_wrapper

0 commit comments

Comments
 (0)