Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 2.28 KB

File metadata and controls

91 lines (64 loc) · 2.28 KB

Zen C Language Server Protocol (LSP)

Zen C comes with a built-in Language Server (LSP) to provide editor features like autocompletion, go-to-definition, and error diagnostics.

Starting the Server

The Language Server is built into the zc compiler key. You can start it manually (though your editor usually handles this) with:

zc lsp

It communicates over standard input/output (stdio).

Editor Configuration

VS Code

For Visual Studio Code, use the official Zen C extension:

Install the extension directly from the Visual Studio Code Marketplace.

Alternatively, you can build the .vsix from source.

Vim / Neovim

Support for Vim and Neovim is provided via the Zen-C.vim plugin, which includes syntax highlighting and LSP configuration helpers.

Neovim (lazy.nvim example)

If you are using nvim-lspconfig, you can register zc as a custom server:

local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')

if not configs.zenc then
  configs.zenc = {
    default_config = {
      cmd = { 'zc', 'lsp' },
      filetypes = { 'zenc', 'zc' },
      root_dir = lspconfig.util.root_pattern('.git', 'build.bat', 'Makefile'),
      settings = {},
    },
  }
end

lspconfig.zenc.setup {}

Zed

To configure Zen C in Zed, add the following to your settings.json or language configuration:

{
  "lsp": {
    "zenc": {
      "binary": {
        "path": "zc",
        "arguments": ["lsp"]
      }
    }
  },
  "languages": {
    "Zen C": {
      "language_servers": ["zenc"]
    }
  }
}

Generic Editors (Sublime, Emacs, etc.)

For any editor that supports generic LSP clients:

  1. Command: zc
  2. Arguments: lsp
  3. Transport: stdio
  4. File Extensions: .zc

Features

  • Diagnostics: Real-time syntax and type errors.
  • Go to Definition: Jump to struct, function, and variable definitions.
  • Autocompletion: Context-aware suggestions for fields and methods.
  • Hover: Type information and documentation on hover (including custom DSL plugins).