Skip to content
DanielHaugePublic

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

Test crates.io

EBNFER

An implementation of the language server protocol (LSP) for EBNF grammars.

Features

  • 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

Installation

Build from source or install via cargo:

cargo install ebnfer

Visual Studio Code

Download the VSIX matching your platform and architecture from the GitHub release, then install it:

code --install-extension ebnfer-<platform>.vsix

The extension includes the language server, EBNF syntax highlighting, and editor configuration. Set ebnfer.server.path only when you want to override the bundled executable.

Neovim 0.11+

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.

Workspaces

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.

Further development

  • Publish the VS Code extension to the Marketplace and Open VSX

Inspired

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.

Releases

Packages

Used by

Contributors

Languages