Editor Integration

Paradox includes a Language Server Protocol (LSP) implementation that provides IDE features for .dox files.

LSP Features

Feature Description

Hover

Shows type information when hovering over names, expressions, and type annotations

Completion

Autocompletes type names, field names, function names, and keywords

Go to Definition

Jump to where a type, function, or interface is defined

Find References

Find all usages of a name across the project

Document Symbols

Outline of all types, functions, and interfaces in the current file

Workspace Symbols

Search for definitions across the entire project

Formatting

Format .dox files on save (uses the same engine as paradox format)

Diagnostics

Real-time error reporting including type errors, parse errors, and refinement violations

VS Code

Add to your VS Code settings.json:

{
  "paradox.serverPath": "paradox",
  "paradox.serverArgs": ["lsp"]
}

You may also need to associate .dox files with the Paradox language:

{
  "files.associations": {
    "*.dox": "paradox"
  }
}

Neovim

With nvim-lspconfig

vim.api.nvim_create_autocmd("FileType", {
  pattern = "dox",
  callback = function()
    vim.lsp.start({
      name = "paradox",
      cmd = { "paradox", "lsp" },
      root_dir = vim.fs.dirname(
        vim.fs.find("dox.yaml", { upward = true })[1]
      ),
    })
  end,
})

File Type Detection

Add to your Neovim config:

vim.filetype.add({
  extension = {
    dox = "dox",
  },
})

Emacs

With lsp-mode:

(add-to-list 'auto-mode-alist '("\\.dox\\'" . prog-mode))

(with-eval-after-load 'lsp-mode
  (lsp-register-client
   (make-lsp-client
    :new-connection (lsp-stdio-connection '("paradox" "lsp"))
    :major-modes '(prog-mode)
    :server-id 'paradox-lsp)))

(add-hook 'prog-mode-hook
  (lambda ()
    (when (string-match-p "\\.dox\\'" buffer-file-name)
      (lsp))))

With eglot:

(add-to-list 'eglot-server-programs
             '(prog-mode . ("paradox" "lsp")))

Completion Trigger Characters

The LSP server triggers completion on:

  • . — field access and union construction

  • : — type annotations

  • Space — function application

See Also

  • CLI: lsp — LSP command reference