Skip to content

Commit bad723b

Browse files
authored
Add lsp setup instructions for text editors (#365)
* Add lsp setup instructions for text editors * Tag vscode only
1 parent 0982708 commit bad723b

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

INSTALLATION.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Standalone Installation Guide
2+
3+
This guide covers installing and configuring the CloudFormation Language Server for standalone editors.
4+
5+
> **Note**: For Visual Studio Code, the language server is bundled with the [AWS Toolkit](https://aws.amazon.com/visualstudio/) extensions.
6+
7+
## Prerequisites
8+
9+
1. [Node.js](https://nodejs.org/en)
10+
11+
## Download
12+
13+
Download the latest release for your platform from [GitHub Releases](https://github.com/aws-cloudformation/cloudformation-languageserver/releases/latest).
14+
15+
### Available Builds
16+
17+
| Platform | Architecture | Node Version | Asset |
18+
|----------|--------------|--------------|-------|
19+
| macOS | ARM64 (Apple Silicon) | 22 | `cloudformation-languageserver-*-darwin-arm64-node22.zip` |
20+
| macOS | x64 (Intel) | 22 | `cloudformation-languageserver-*-darwin-x64-node22.zip` |
21+
| Linux | ARM64 | 22 | `cloudformation-languageserver-*-linux-arm64-node22.zip` |
22+
| Linux | x64 | 22 | `cloudformation-languageserver-*-linux-x64-node22.zip` |
23+
| Linux (glibc 2.28) | ARM64 | 18 | `cloudformation-languageserver-*-linuxglib2.28-arm64-node18.zip` |
24+
| Linux (glibc 2.28) | x64 | 18 | `cloudformation-languageserver-*-linuxglib2.28-x64-node18.zip` |
25+
| Windows | ARM64 | 22 | `cloudformation-languageserver-*-win32-arm64-node22.zip` |
26+
| Windows | x64 | 22 | `cloudformation-languageserver-*-win32-x64-node22.zip` |
27+
28+
### Example: macOS ARM64
29+
30+
```bash
31+
curl -L -o cfn-lsp.zip \
32+
https://github.com/aws-cloudformation/cloudformation-languageserver/releases/latest/download/cloudformation-languageserver-darwin-arm64-node22.zip
33+
34+
unzip cfn-lsp.zip -d /path/to/install-location
35+
```
36+
37+
## Server Configuration
38+
39+
### Running the Server
40+
41+
```bash
42+
node /path/to/install-location/cfn-lsp-server-standalone.js --stdio
43+
```
44+
45+
Communication options:
46+
- `--stdio` - Use stdin/stdout (recommended)
47+
- `--node-ipc` - Use Node IPC
48+
49+
### Initialization Options
50+
51+
The language server accepts initialization options via the LSP `initialize` request:
52+
53+
```json
54+
{
55+
"initializationOptions": {
56+
"aws": {
57+
"clientInfo": {
58+
"extension": {
59+
"name": "your-editor-name",
60+
"version": "1.0.0"
61+
}
62+
},
63+
"telemetryEnabled": true
64+
}
65+
}
66+
}
67+
```
68+
69+
| Option | Type | Description |
70+
|--------|-------------------|-------------|
71+
| `aws.clientInfo.extension.name` | string | Your editor/client name |
72+
| `aws.clientInfo.extension.version` | string | Your editor/client version |
73+
| `aws.clientInfo.clientId` | string (optional) | Unique identifier for the client instance |
74+
| `aws.telemetryEnabled` | boolean | Enable anonymous usage metrics (default: `false`) |
75+
76+
See [Telemetry](src/telemetry/README.md) for details on collected metrics.
77+
78+
### Supported File Types
79+
80+
- `yaml` - YAML CloudFormation templates
81+
- `json` - JSON CloudFormation templates
82+
- `cfn`, `tempalte` - Custom CloudFormation template extensions
83+
84+
---
85+
86+
## Editor Setup
87+
88+
### Neovim
89+
90+
```lua
91+
local lspconfig = require("lspconfig")
92+
local configs = require("lspconfig.configs")
93+
94+
if not configs.cfn_lsp then
95+
configs.cfn_lsp = {
96+
default_config = {
97+
cmd = { "node", "/path/to/install-location/cfn-lsp-server-standalone.js", "--stdio" },
98+
filetypes = { "yaml", "json" },
99+
root_dir = function(fname)
100+
return lspconfig.util.root_pattern(".git", "package.json")(fname) or vim.fn.getcwd()
101+
end,
102+
init_options = {
103+
aws = {
104+
clientInfo = {
105+
extension = { name = "neovim", version = vim.version().major .. "." .. vim.version().minor },
106+
clientId = vim.fn.hostname(),
107+
},
108+
telemetryEnabled = true,
109+
},
110+
},
111+
},
112+
}
113+
end
114+
115+
lspconfig.cfn_lsp.setup({})
116+
```
117+
118+
Verify: Open a YAML/JSON file and run `:LspInfo`
119+
120+
### Sublime Text (LSP package)
121+
122+
Add to LSP settings:
123+
124+
```json
125+
{
126+
"clients": {
127+
"cfn-lsp": {
128+
"enabled": true,
129+
"command": ["node", "/path/to/install-location/cfn-lsp-server-standalone.js", "--stdio"],
130+
"selector": "source.yaml | source.json",
131+
"initializationOptions": {
132+
"aws": {
133+
"clientInfo": {
134+
"extension": { "name": "sublime", "version": "4.0" },
135+
"clientId": "sublime-client"
136+
},
137+
"telemetryEnabled": true
138+
}
139+
}
140+
}
141+
}
142+
}
143+
```

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ The server implements the Language Server Protocol (LSP) to enable code editors
5858
- **Regional Schemas** - Automatic schema retrieval and caching for different AWS regions
5959
- **Tree-sitter Parsing** - Fast and accurate syntax parsing
6060

61+
## Installation
62+
63+
For standalone editors like Neovim, Emacs, Helix, or Sublime Text, see the [Installation Guide](INSTALLATION.md).
64+
65+
For Visual Studio Code, the language server is bundled with the [AWS Toolkit](https://aws.amazon.com/visualstudio/) extensions.
66+
6167
## Telemetry
6268

6369
The CloudFormation Language Server collects anonymous usage metrics. See [Telemetry](src/telemetry/README.md) for details on what is collected and how to control telemetry settings.

0 commit comments

Comments
 (0)