Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
objc.vim80 linesDownload Raw Back to indent
1"   Vim indent file2"   Language:	    Objective-C3"   Maintainer:	    Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>4"   Last Change:    2022 Apr 065 6" Only load this indent file when no other was loaded.7if exists("b:did_indent")8    finish9endif10let b:did_indent = 111setlocal cindent12 13" Set the function to do the work.14setlocal indentexpr=GetObjCIndent()15 16" To make a colon (:) suggest an indentation other than a goto/switch label,17setlocal indentkeys-=:18setlocal indentkeys+=<:>19 20let b:undo_indent = "setl cin< inde< indk<"21 22" Only define the function once.23if exists("*GetObjCIndent")24    finish25endif26 27function s:GetWidth(line, regexp)28    let end = matchend(a:line, a:regexp)29    let width = 030    let i = 031    while i < end32	if a:line[i] != "\t"33	    let width = width + 134	else35	    let width = width + &ts - (width % &ts)36	endif37	let i = i + 138    endwhile39    return width40endfunction41 42function s:LeadingWhiteSpace(line)43    let end = strlen(a:line)44    let width = 045    let i = 046    while i < end47	let char = a:line[i]48	if char != " " && char != "\t"49	    break50	endif51	if char != "\t"52	    let width = width + 153	else54	    let width = width + &ts - (width % &ts)55	endif56	let i = i + 157    endwhile58    return width59endfunction60 61 62function GetObjCIndent()63    let theIndent = cindent(v:lnum)64 65    let prev_line = getline(v:lnum - 1)66    let cur_line = getline(v:lnum)67 68    if prev_line !~# ":" || cur_line !~# ":"69	return theIndent70    endif71 72    if prev_line !~# ";"73	let prev_colon_pos = s:GetWidth(prev_line, ":")74	let delta = s:GetWidth(cur_line, ":") - s:LeadingWhiteSpace(cur_line)75	let theIndent = prev_colon_pos - delta76    endif77 78    return theIndent79endfunction80 
codekingpro/portable-devtools · Team Ai