caddy-language-server

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 4 Imported by: 0

README

caddy-language-server

A language server for Caddyfile configuration files.

Features

  • Diagnostics — flags unknown directives, misplaced subdirectives, invalid subdirectives inside blocks, and undefined snippet references in import statements
  • Completion — suggests top-level directives inside site blocks and snippet names after import
  • Hover — shows documentation for directives under the cursor

The parser is built on Caddy's own tokenizer (github.com/caddyserver/caddy/v2/caddyconfig/caddyfile) so it stays in sync with Caddy's actual syntax rules.

Install

go install github.com/teemuteemu/caddy-language-server@latest

This puts a caddy-language-server binary in $(go env GOPATH)/bin — make sure that directory is on your PATH. Prebuilt binaries for Linux and macOS are also attached to each release.

Editor setup

caddy-language-server communicates over stdio using the Language Server Protocol (JSON-RPC 2.0). Point your editor's LSP client at the caddy-language-server binary with no extra arguments.

Neovim (nvim-lspconfig)

vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
  pattern = "Caddyfile",
  callback = function()
    vim.bo.filetype = "caddy"
  end,
})

require("lspconfig.configs").caddy_ls = {
  default_config = {
    cmd = { "caddy-language-server" },
    filetypes = { "caddy" },
    root_dir = require("lspconfig.util").root_pattern("Caddyfile"),
  },
}
require("lspconfig").caddy_ls.setup({})

Development

go test ./...   # run tests
go vet ./...    # static analysis

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
docgen command
docgen generates internal/handler/docs_gen.go containing Markdown documentation for Caddyfile directives, extracted from Caddy's source code.
docgen generates internal/handler/docs_gen.go containing Markdown documentation for Caddyfile directives, extracted from Caddy's source code.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL