summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md1
-rw-r--r--after/indent/objc.vim97
-rw-r--r--after/syntax/objc.vim23
-rwxr-xr-xbuild1
-rw-r--r--ftplugin/objc.vim10
5 files changed, 132 insertions, 0 deletions
diff --git a/README.md b/README.md
index b691109d..0694f470 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin, ftdetect)
- [markdown](https://github.com/tpope/vim-markdown) (syntax, ftplugin, ftdetect)
- [nginx](https://github.com/nginx/nginx) (syntax, indent, ftdetect)
+- [objc](https://github.com/b4winckler/vim-objc) (ftplugin, syntax, indent)
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
- [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin, ftdetect)
diff --git a/after/indent/objc.vim b/after/indent/objc.vim
new file mode 100644
index 00000000..64c7e79c
--- /dev/null
+++ b/after/indent/objc.vim
@@ -0,0 +1,97 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'objc') == -1
+
+" Vim indent file
+" Language: Objective-C
+" Maintainer: Bjorn Winckler <bjorn.winckler@gmail.com>
+" Last Change: 2012 Jan 01
+
+" Ensure 'cpo' is set to Vim default values and restore later
+let s:save_cpo = &cpo
+set cpo&vim
+
+" Only load this indent file when no other was loaded.
+"if exists("b:did_indent")
+" finish
+"endif
+"let b:did_indent = 1
+"setlocal cindent
+
+setl indentkeys=0{,0},:,0#,!^F,o,O,e,<:>
+
+setlocal indentexpr=GetObjCIndentImproved()
+
+" Top level statements which should not be indented, and which should not
+" cause next (non-blank) line to be indented either.
+let s:topLev = '^\s*@\%(class\|end\|implementation\|interface\|protocol\|\)\>'
+
+function! GetObjCIndentImproved()
+ " NOTE: Ignore leading white space to avoid having to deal with space vs.
+ " tab issues. Rely on the indent() function instead.
+ let thisLine = substitute(getline(v:lnum), '^\s*', '', '')
+
+ if thisLine =~# s:topLev || getline(prevnonblank(v:lnum - 1)) =~# s:topLev
+ return 0
+ endif
+
+ " If current line looks like an argument to a message dispatch, then line
+ " up colon with previous line. This will indent the second line so that
+ " the colons line up in
+ "
+ " [obj firstParameter:value
+ " paramB:value2];
+ "
+ " but it will not line up colons in
+ "
+ " if ([obj something:here])
+ " [obj other:here];
+ "
+ let thisColon = match(thisLine, '^\s*\K\k*\zs:')
+ if thisColon > 0
+ let prevLine = substitute(getline(v:lnum - 1), '^\s*', '', '')
+ let prevColon = match(prevLine, ':')
+ if prevColon > 0
+ " Try to align colons, always making sure line is indented at least
+ " one shiftwidth more than the indentation at the beginning of the
+ " message. Avoids situations like this:
+ "
+ " if ([obj a:x
+ " aLongParameter:y])
+ "
+ let [lnum,lcol] = searchpairpos('\[', '', '\]', 'b', 0,
+ \ max([1, v:lnum - 10]))
+ let minInd = &sw + (lnum > 0 ? indent(lnum) : 0)
+ let alignedInd = indent(v:lnum - 1) + prevColon - thisColon
+ return alignedInd > minInd ? alignedInd : minInd
+ endif
+ endif
+
+ let prevLnum = v:lnum - 1
+ let ind = indent(prevLnum)
+
+ " Indent one shiftwidth after opening block, e.g.:
+ "
+ " call_func_with_block(param, ^{
+ " do_stuff();
+ " });
+ "
+ let blockPat = '\^\s*\(([^)]*)\)\?\s*{$'
+ if thisLine =~ '^}'
+ norm '^%'
+ if getline(".") =~ blockPat
+ return indent(".")
+ endif
+ endif
+
+ if getline(prevLnum) =~ blockPat
+ return ind + &sw
+ endif
+
+ return cindent(v:lnum)
+endfunction
+
+
+" Restore 'cpo' options
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+endif
diff --git a/after/syntax/objc.vim b/after/syntax/objc.vim
new file mode 100644
index 00000000..7e64248d
--- /dev/null
+++ b/after/syntax/objc.vim
@@ -0,0 +1,23 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'objc') == -1
+
+" ARC type modifiers
+syn keyword objcTypeModifier __bridge __bridge_retained __bridge_transfer __autoreleasing __strong __weak __unsafe_unretained
+
+" Block modifiers
+syn keyword objcTypeModifier __block
+
+" Remote messaging modifiers
+syn keyword objcTypeModifier byref
+
+" Property keywords - these are only highlighted inside '@property (...)'
+syn keyword objcPropertyAttribute contained getter setter readwrite readonly strong weak copy assign retain nonatomic
+syn match objcProperty display "^\s*@property\>\s*([^)]*)" contains=objcPropertyAttribute
+
+" The @property directive must be defined after objcProperty or it won't be
+" highlighted
+syn match objcDirective "@property\|@synthesize\|@dynamic\|@package"
+
+" Highlight property attributes as if they were type modifiers
+hi def link objcPropertyAttribute objcTypeModifier
+
+endif
diff --git a/build b/build
index 533da3a7..e0c93c63 100755
--- a/build
+++ b/build
@@ -135,6 +135,7 @@ PACKS="
liquid:tpope/vim-liquid
markdown:tpope/vim-markdown
nginx:nginx/nginx::/contrib/vim/
+ objc:b4winckler/vim-objc
ocaml:jrk/vim-ocaml
octave:vim-scripts/octave.vim--
opencl:petRUShka/vim-opencl
diff --git a/ftplugin/objc.vim b/ftplugin/objc.vim
new file mode 100644
index 00000000..409fb1a2
--- /dev/null
+++ b/ftplugin/objc.vim
@@ -0,0 +1,10 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'objc') == -1
+
+" Use C++ style comment strings with commentary.vim
+setl commentstring=//%s
+
+" Search for include files inside frameworks (used for gf etc.)
+setl includeexpr=substitute(v:fname,'\\([^/]\\+\\)/\\(.\\+\\)','/System/Library/Frameworks/\\1.framework/Headers/\\2','')
+
+
+endif