Skip to content

puremourning/capnp.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

capnp.vim

Vim plugin for Cap'n Proto schema files (.capnp).

Features

  • Syntax highlighting – keywords, types, literals, annotations, file IDs, field ordinals, strings, hex data, numbers, and comments
  • Indentation – smart 2-space indentation based on Cap'n Proto block structure
  • Compiler integration – run capnp compile from inside Vim and parse errors into the quickfix list
  • File type settings – comment string, folding, gf navigation on imports
  • Utility commands – encode/decode messages, evaluate constants, and auto-number field ordinals

Requirements

  • Vim 8+ or Neovim
  • The capnp command-line tool must be on your $PATH for compiler integration and the utility commands

Installation

Use your favourite plugin manager.

vim-plug

Plug 'capnproto/capnp.vim'

lazy.nvim

{ 'capnproto/capnp.vim' }

Manual – copy the directories into your ~/.vim (Vim) or ~/.config/nvim (Neovim) folder.

Usage

The plugin activates automatically for any file with the .capnp extension.

Commands

Command Description
:CapnpId Insert a new unique file ID at the cursor
:CapnpEncode Encode the buffer (or visual selection) to binary Cap'n Proto
:CapnpDecode Decode a binary Cap'n Proto buffer to text
:CapnpEval [const] Evaluate a Cap'n Proto constant expression
:CapnpSetOrdinals [n] Replace @? placeholders with sequential ordinals

Compiler

The capnp compiler is set automatically for .capnp buffers. Use :make to compile the current file and :copen to inspect errors.

Customise the flags passed to capnp compile:

" Global default (syntax-check only by default: -ocapnp)
let g:capnp_compiler_flags = '-I/usr/local/include -oc++'

" Buffer-local override (takes precedence)
let b:capnp_compiler_flags = '-oc++'

Encode / Decode

Set the schema and type name for the current buffer before calling :CapnpEncode or :CapnpDecode:

let b:capnp_schema    = '/path/to/schema.capnp'
let b:capnp_type_name = 'MyMessage'

If these variables are not set the commands will prompt you interactively.

License

BSD 2-Clause. See LICENSE.

About

Vim plugin for authoring capnproto schema files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors