Skip to content

Commit 29bd20c

Browse files
committed
add recipe for language server
1 parent c5c8032 commit 29bd20c

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

docs/recipes/language-server.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!--
2+
{
3+
"title": "Language Server Protocol (LSP) for Lucee",
4+
"id": "language-server-protocol",
5+
"description": "This document explains how to configure and use the Language Server Protocol implementation for Lucee CFML/CFScript.",
6+
"keywords": [
7+
"LSP",
8+
"language server",
9+
"IDE integration",
10+
"VS Code",
11+
"development tools",
12+
"code completion"
13+
]
14+
}
15+
-->
16+
17+
# Language Server Protocol (LSP) for Lucee
18+
19+
**Experimental Feature**: The Language Server Protocol implementation is available as an experimental feature in Lucee 6.1 and above. As an experimental feature, it may undergo changes or improvements in future releases.
20+
21+
The Lucee Language Server Protocol implementation provides modern IDE features for Lucee CFML/CFScript development. It enables features like code completion, go to definition, and syntax validation in compatible editors like VS Code.
22+
23+
## Configuration
24+
25+
The LSP server can be configured using either environment variables or system properties. Both methods support the same configuration options.
26+
27+
### Environment Variables
28+
29+
```bash
30+
# Enable/disable the LSP server (default: false)
31+
export LUCEE_LSP_ENABLED=true
32+
33+
# Set the port number (default: 2089)
34+
export LUCEE_LSP_PORT=2089
35+
36+
# Configure the CFML component that handles LSP requests
37+
export LUCEE_LSP_COMPONENT="org.lucee.cfml.lsp.LSPEndpoint"
38+
```
39+
40+
### System Properties
41+
42+
The same settings can be configured using Java system properties:
43+
44+
```bash
45+
-Dlucee.lsp.enabled=true
46+
-Dlucee.lsp.port=2089
47+
-Dlucee.lsp.component=org.lucee.cfml.lsp.LSPEndpoint
48+
```
49+
50+
## Configuration Options
51+
52+
| Option | Description | Default Value |
53+
|--------|-------------|---------------|
54+
| lucee.lsp.enabled | Enables/disables the LSP server | false |
55+
| lucee.lsp.port | Port number for the LSP server | 2089 |
56+
| lucee.lsp.component | CFML component that handles LSP requests | org.lucee.cfml.lsp.LSPEndpoint |
57+
58+
## Component Implementation
59+
60+
The LSP server delegates all language-specific functionality to a CFML component. This component must implement the `execute` method that receives JSON-formatted LSP messages:
61+
62+
```cfml
63+
// org/lucee/cfml/lsp/LSPEndpoint.cfc
64+
component {
65+
public string function execute(required string jsonMessage) {
66+
// Process LSP message and return response
67+
return jsonMessageResponse;
68+
}
69+
}
70+
```
71+
72+
## Logging
73+
74+
The LSP server logs its activity to Lucee's logging system. By default, it uses the 'debug' log (temporary because this is info by default),
75+
but you can configure a specific 'lsp' log in your Lucee configuration.
76+
77+
## Startup and Shutdown
78+
79+
The LSP server automatically starts when Lucee initializes if `lucee.lsp.enabled` is set to true. It runs in a daemon thread and will automatically shut down when Lucee stops.

0 commit comments

Comments
 (0)