An implementation of the language server protocol (LSP) for EBNF grammars.
- Semantic tokens (Root rule)
- Diagnostics
- Hover
- References
- Completion
- Document formatting
- Rename
- Go to definition
- Document symbols
- Code actions (supress unused warning)
- Formatting
- Workspace support - multiple files
ebnfer.mp4
Build from source or install via cargo:
cargo install ebnferDownload the VSIX matching your platform and architecture from the GitHub release, then install it:
code --install-extension ebnfer-<platform>.vsixThe extension includes the language server, EBNF syntax highlighting, and
editor configuration. Set ebnfer.server.path only when you want to override
the bundled executable.
Install ebnfer with Cargo, then add the EBNF filetype and LSP configuration:
vim.filetype.add({
extension = {
ebnf = "ebnf",
},
})
vim.lsp.config("ebnfer", {
cmd = { vim.fn.has("win32") == 1 and "ebnfer.exe" or "ebnfer" },
filetypes = { "ebnf" },
root_markers = { ".ebnfer-root", ".git" },
})
vim.lsp.enable("ebnfer")Use :checkhealth vim.lsp to confirm that the server attached. An optional
.ebnfer-root file can define the grammar workspace when the files are not
inside a Git repository.
All .ebnf files below an LSP workspace folder are indexed recursively and
share one rule namespace. Definitions, references, hover, completion,
diagnostics, rename, and go-to-definition work across files.
Multi-root workspace folders remain independent namespaces. Open editor buffers override their on-disk files until they are closed.
- Publish the VS Code extension to the Marketplace and Open VSX
This project is inspired by the ebnf analysis crate on crates.io - ebnf. Also inspired by the following youtube video: Learn By Building: Language Server Protocol - TJ Devries.