Files
zeekay 3cc5b0fa92 Rebrand Cap'n Proto vim plugin to ZAP
Conservative, wire/library-compatible rebrand for the zap-proto fork:

- Rename plugin files keyed on the editor filetype:
  ftdetect/, syntax/, indent/ capnp.vim -> zap.vim
- Language id / filetype / b:current_syntax: capnp -> zap
- ftdetect maps BOTH *.zap and *.capnp -> filetype=zap (back-compat)
- Syntax group names capnp* -> zap* (plugin-internal, self-contained)
- Indent function CapnpIndent -> ZapIndent (self-contained)
- README: ZAP identity, repo URL -> github.com/zap-proto/vim,
  keep '.capnp' back-compat note

Preserve honest attribution that ZAP is a fork of Cap'n Proto
(https://capnproto.org), upstream authors, and the MIT license.
2026-06-19 14:53:33 -07:00

35 lines
659 B
VimL

if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal autoindent
setlocal nolisp
setlocal indentexpr=ZapIndent(v:lnum)
if exists('*ZapIndent')
finish
endif
function! ZapIndent(lineNum)
let l:prevLineNum = prevnonblank(a:lineNum - 1)
if l:prevLineNum == 0
return 0
endif
let l:prevLine = substitute(getline(l:prevLineNum), '#.*$', '', '')
let l:line = substitute(getline(a:lineNum), '#.*$', '', '')
let l:prevIndent = indent(l:prevLineNum)
let l:indent = l:prevIndent
if l:prevLine =~ '[({]\s*$'
let l:indent += shiftwidth()
endif
if l:line =~ '^\s*[)}]'
let l:indent -= shiftwidth()
endif
return l:indent
endfunction