Neovim plugin to make working with Web Origami more pleasant.
neovim-plugin weborigami neovim nvim nvim-plugin
JavaScript 70%
Lua 14%
Vim Script 11%
3%
Shell 2%
TypeScript <1%
HTML <1%

README.md

Web Origami Neovim Plugin

Neovim plugin to make working with Web Origami more pleasant.

Neovim plugin providing full Language Server Protocol (LSP) support and syntax highlighting for Web Origami.

Features #

  • Diagnostics: Syntax error highlighting via @weborigami/language compiler.
  • Autocompletion: Path completions (files/folders), scope completions (object properties, lambda params), and builtin function names (Origami, Tree, Dev, Protocol).
  • Go-to-definition: Navigate from file references to the corresponding file, or from local properties/parameters to their declaration.
  • Syntax highlighting: Comprehensive highlighting for .ori, .ori.html, and .ori.md files.
  • Filetype detection: Automatic detection of Origami files.

Installation #

Required:

  • Neovim >= 0.10.0 (for vim.fs, vim.system, and built-in LSP support)
  • Node.js (to run the LSP server)

You can install the plugin using the plugin manager of your choice. Using lazy.nvim you can install it like so:

{
  "https://tangled.org/vale.rocks/weborigami-nvim",
  opts = {},
}

Configuration #

Default configuration:

{
  server = {
    -- Whether to auto-install npm dependencies (`npm install` in server dir)
    auto_install = true,
    -- Command to run Node.js
    cmd = { "node" },
  },
  lsp = {
    -- Additional LSP capabilities to merge (eg, from nvim-cmp)
    capabilities = nil,
    -- Callback invoked when LSP attaches to a buffer
    on_attach = nil,
    -- Root directory markers used to detect project root
    root_markers = { ".git", "package.json", "config.ori", "site.ori" },
  },
  filetypes = {
    origami = "origami",
    origami_html = "origamihtml",
    origami_markdown = "origamimarkdown",
  },
}

Custom on_attach #

opts = {
  lsp = {
    on_attach = function(client, bufnr)
      -- Keymaps
      local bufopts = { buffer = bufnr, noremap = true, silent = true }
      vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
      vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
    end,
  },
}

How it Works #

The plugin bundles an LSP server adapted from origami-vscode-extension (MIT). The server source is kept in server/ and tracked as part of this repository. The upstream extension is included as a git subtree at server/upstream/ for reference and syncing. Neovim-specific adaptations are captured in server/neovim.patch so they can be reapplied when pulling upstream changes.

On first use, the plugin runs npm install in the server/ directory to install dependencies (@weborigami/language, @weborigami/async-tree, vscode-languageserver).

When you open an Origami file:

  1. Neovim detects the filetype.
  2. The plugin starts the LSP server.
  3. The server compiles your code with @weborigami/language.
  4. Diagnostics, completions, and definition navigation become available.

Updating the LSP Server #

Tip

This section is for maintainers. Users get the server code bundled with the plugin and do not need to run these steps.

The LSP server source is adapted from the official origami-vscode-extension. To pull in upstream changes and reapply Neovim adaptations:

One-time setup #

git remote add origami-upstream https://github.com/WebOrigami/origami-vscode-extension.git
git subtree add --prefix=server/upstream origami-upstream main --squash

Syncing updates #

# Pull the latest upstream code into the subtree
git subtree pull --prefix=server/upstream origami-upstream main --squash

# Apply Neovim adaptations and copy files into server/
./scripts/sync-upstream.sh

scripts/sync-upstream.sh stages the upstream server files, applies server/neovim.patch, copies the result into server/, and records the synced commit SHA in server/upstream-sha. Review the diff with git diff -- server/ before committing.

How the patch works #

server/neovim.patch is a unified diff that captures every change made to the upstream files:

  • Path import tweaks (upstream nests server modules one level deeper)
  • Neovim filetype support (origamihtml, origamimarkdown compiler entries in diagnostics.mjs)
  • The stdio-based entry point (index.mjs, adapted from upstream's server.mjs)
  • Two fresh handlers (hover.mjs, symbols.mjs) that don't exist upstream
  • Minor platform and bug fixes (cross-platform root detection, unicode spread operator, off-by-one in local declaration bounds)

To update the patch after making new adaptations, regenerate it from the staging directories:

# Create a/ (pristine upstream) and b/ (adapted) staging directories then diff them:
diff -ruN a/ b/ -x node_modules > server/neovim.patch