https://github.com/joeriddles/nats-server-lsp.git
Language Server Protocol implementation for NATS server configuration files.
npm install -g nats-config-lsp
Or use locally:
npm install
npm run build
The LSP communicates over stdio. Configure your editor to use:
nats-config-lsp --stdio
Install the NATS Configuration extension from the vscode-extension directory:
cd vscode-extension
npm install
npm run package
code --install-extension nats-config-0.1.0.vsix
The extension automatically activates for:
nats.conf, nats-server.conf, or srv.conf.nats.conf extension# nats-config to the first line of any .conf file to enable NATS config mode:
# nats-config
port = 4222
host: "localhost"
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
configs.nats_config = {
default_config = {
cmd = { 'nats-config-lsp', '--stdio' },
filetypes = { 'nats-config' },
root_dir = lspconfig.util.find_git_ancestor,
settings = {},
},
}
lspconfig.nats_config.setup{}
The LSP validates against the full NATS server configuration schema:
server_name, server_tagshost, port, listen, client_advertisemax_connections, max_payload, max_pending, max_subscriptionsping_interval, ping_max, write_deadlinedebug, trace, logfile, logtimehttp_port, https_porttls - TLS/SSL configurationcluster - Cluster configurationjetstream - JetStream persistenceauthorization - Authentication and authorizationaccounts - Multi-tenancy accountsleafnodes - Leaf node connectionsgateway - Super-cluster gatewaysmqtt - MQTT protocol supportwebsocket - WebSocket supportThe NATS config format supports flexible syntax:
# Comments with # or //
port = 4222 # equals assignment
host: "localhost" # colon assignment
debug true # whitespace assignment
# Blocks
cluster {
name: "my-cluster"
routes: [
"nats://node1:6222"
"nats://node2:6222"
]
}
# Variables
TOKEN: "secret"
auth_token: $TOKEN
# Includes
include ./auth.conf
# Size units: K, KB, M, MB, G, GB, T, TB
max_payload: 1MB
# Duration units: s, m, h
ping_interval: 2m
npm install
npm run build
npm run watch # Watch mode
npm test # Run tests
# Build the LSP server first
npm run build
# Set up the extension
cd vscode-extension
npm install
npm run copy-server
To test the extension, open the vscode-extension folder in VS Code and press F5 to launch the Extension Development Host. The extension will compile automatically, but you need to run npm run copy-server again if you change the LSP server code.
MIT