Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Bend 2 formatter language server

bend2-fmt-lsp is a formatting-only language server for Bend 2. It supports full-document formatting over stdio and intentionally exposes no diagnostics, completion, hover, range-formatting, or on-type-formatting features.

Install and run

Node.js 22 or newer is required.

npm install
npm run build
node dist/server.js --stdio

The server handles documents whose language ID is bend or bend2. It preserves line breaks, blank lines, comments, literal spelling, line endings, and the final-newline state. Formatting normalizes indentation and safe token spacing without wrapping code. When a document cannot be tokenized safely, the server returns no edits.

Editor setup

Neovim with nvim-lspconfig:

vim.api.nvim_create_autocmd("FileType", {
  pattern = "bend",
  callback = function()
    vim.lsp.start({
      name = "bend2-fmt-lsp",
      cmd = { "bend2-fmt-lsp", "--stdio" },
      root_dir = vim.fs.root(0, { ".git" }),
    })
  end,
})

Helix (languages.toml):

[language-server.bend2-fmt-lsp]
command = "bend2-fmt-lsp"
args = ["--stdio"]

[[language]]
name = "bend"
scope = "source.bend"
file-types = ["bend"]
language-servers = ["bend2-fmt-lsp"]
auto-format = true

Emacs with Eglot:

(add-to-list 'eglot-server-programs
             '(bend-mode . ("bend2-fmt-lsp" "--stdio")))