NemerleはCに似た言語であり、ほとんどの場合、で非常にうまく機能しcindent
ます。ただし、に類似したその構成は次のようswitch
に呼ばれmatch
ます。
match (x) // switch (x)
{ // {
| "Hello World" => ... // case "Hello World": ...
| _ => ... // default: ...
} // }
cinoptions
代わりに、 forswitch
ステートメントをこの構成に適用することは可能ですか?どこかに設定できる正規表現があるかもしれません。そうでない場合は、垂直バーを別の方法でブレースに揃えることができますか?
アップデート
これが私が思いついたものです:
" Vim indent file
" Language: Nemerle
" Maintainer: Alexey Badalov
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
" Nemerle is C-like, but without switch statements or labels.
setlocal cindent cinoptions=L0
" Enable '|', disable ':'.
setlocal indentkeys=0{,0},0),0#,0\|,!^F,o,O,e
setlocal indentexpr=GetNemerleIndent()
let b:undo_indent = "setl cin< cino< indentkeys< indentexpr<"
function! GetNemerleIndent()
" Nemerle is C-like; use built-in C indentation as a basis.
let indent = cindent(v:lnum)
" Set alignment for lines starting with '|' in line with the opening
" brace. Use default indentation outside of blocks.
if getline(v:lnum) =~ '^\s*|'
call cursor(v:lnum, 1)
silent! normal [{
if line('.') == v:lnum
return indent
endif
return indent(line('.'))
endif
return indent
endfunction