Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
tools
unittests
utils
FileCheck
KillTheDoctor
LLVMVisualizers
Misc
PerfectShuffle
TableGen
Target
bugpoint
count
crosstool
docker
emacs
fpcmp
gdb-scripts
git
git-svn
jedit
kate
lint
lit
llvm-build
llvm-lit
not
release
sanitizers
testgen
textmate
unittest
valgrind
vim
ftdetect
ftplugin
indent
llvm.vim
syntax
README
vimrc
vscode
yaml-bench
DSAclean.py
DSAextract.py
GenLibDeps.pl
GetRepositoryPath
GetSourceVersion
LLVMBuild.txt
UpdateCMakeLists.pl
abtest.py
bisect
bisect-skip-count
check-each-file
clang-parse-diagnostics-file
codegen-diff
countloc.sh
create_ladder_graph.py
extract_symbols.py
findmisopt
findoptdiff
findsym.pl
getsrcs.sh
lldbDataFormatters.py
llvm-compilers-check
llvm-gisel-cov.py
llvm-native-gxx
llvm.grm
llvmdo
llvmgrep
makellvm
prepare-code-coverage-artifact.py
schedcover.py
shuffle_fuzz.py
shuffle_select_fuzz_tester.py
sort_includes.py
update_llc_test_checks.py
update_mir_test_checks.py
update_test_checks.py
wciia.py
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm/utils/vim/indent/llvm.vim

73 lines
2.0 KiB
VimL
Raw Normal View History

" Vim indent file
" Language: llvm
" Maintainer: The LLVM team, http://llvm.org/
" What this indent plugin currently does:
" - If no other rule matches copy indent from previous non-empty,
" non-commented line
" - On '}' align the same as the line containing the matching '{'
" - If previous line ends with ':' increase indentation
" - If the current line ends with ':' indent at the same level as the
" enclosing '{'/'}' block
" Stuff that would be nice to add:
" - Continue comments on next line
" - If there is an opening+unclosed parenthesis on previous line indent to that
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal shiftwidth=2 expandtab
setlocal indentkeys=0{,0},<:>,!^F,o,O,e
setlocal indentexpr=GetLLVMIndent()
if exists("*GetLLVMIndent")
finish
endif
function! FindOpenBrace(lnum)
call cursor(a:lnum, 1)
return searchpair('{', '', '}', 'bW')
endfun
function! GetLLVMIndent()
" On '}' align the same as the line containing the matching '{'
let thisline = getline(v:lnum)
if thisline =~ '^\s*}'
call cursor(v:lnum, 1)
silent normal %
let opening_lnum = line('.')
if opening_lnum != v:lnum
return indent(opening_lnum)
endif
endif
" Indent labels the same as the current opening block
if thisline =~ ':\s*$'
let blockbegin = FindOpenBrace(v:lnum)
if blockbegin > 0
return indent(blockbegin)
endif
endif
" Find a non-blank not-completely commented line above the current line.
let prev_lnum = prevnonblank(v:lnum - 1)
while prev_lnum > 0 && synIDattr(synID(prev_lnum, indent(prev_lnum)+1, 0), "name") =? "string\|comment"
let prev_lnum = prevnonblank(prev_lnum-1)
endwhile
" Hit the start of the file, use zero indent.
if prev_lnum == 0
return 0
endif
let ind = indent(prev_lnum)
let prevline = getline(prev_lnum)
" Add a 'shiftwidth' after lines that start a block or labels
if prevline =~ '{\s*$' || prevline =~ ':\s*$'
let ind = ind + &shiftwidth
endif
return ind
endfunction