diff --git a/rc/c-family.kak b/rc/c-family.kak index 81cb4f5d..27240a86 100644 --- a/rc/c-family.kak +++ b/rc/c-family.kak @@ -10,6 +10,10 @@ hook global BufCreate .*\.m %{ set buffer filetype objc } +hook global BufSetOption mimetype=text/x-objc %{ + set buffer filetype objc +} + def -hidden _c-family-indent-on-new-line %~ eval -draft -itersel %_ # preserve previous line indent @@ -46,9 +50,15 @@ def -hidden _c-family-indent-on-closing-curly-brace %[ # Regions definition are the same between c++ and objective-c %sh{ for ft in cpp objc; do + if [ "${ft}" = "objc" ]; then + maybe_at='@?' + else + maybe_at='' + fi + printf '%s' ' addhl -group / regions -default code FT \ - string %{(?|\ addhl -group /objc/code regex "\<(void|int|char|unsigned|float|bool|size_t|instancetype|BOOL|NSInteger|NSUInteger|CGFloat|NSString)\>" 0:type addhl -group /objc/code regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return)\>" 0:keyword addhl -group /objc/code regex "\<(const|auto|inline|static|volatile|struct|enum|union|typedef|extern|__block|@\w+)\>" 0:attribute +addhl -group /objc/code regex "\<(nonatomic|assign|copy|strong|retain|weak|readonly)\>" 0:attribute +addhl -group /objc/code regex "@(property|synthesize|interface|implementation|protocol|end|selector|autoreleasepool|try|catch|class|synchronized)\>" 0:attribute +addhl -group /objc/code regex "\<(IBAction|IBOutlet)\>" 0:attribute hook global WinSetOption filetype=(cpp|objc) %[ # cleanup trailing whitespaces when exiting insert mode