robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
c3defb4b45
master
1" Vim indent file 2" Language: eRuby 3" Maintainer: Tim Pope <vimNOSPAM@tpope.org> 4" URL: https://github.com/vim-ruby/vim-ruby 5" Last Change: 2019 Jan 06 6 7if exists ( "b:did_indent" ) 8finish 9endif 10 11runtime ! indent/ruby.vim 12unlet ! b: did_indent 13setlocal indentexpr = 14 15if exists ( "b:eruby_subtype" ) && b: eruby_subtype != '' && b: eruby_subtype !=# 'eruby' 16exe "runtime! indent/" . b: eruby_subtype . ".vim" 17else 18runtime ! indent/html.vim 19endif 20unlet ! b: did_indent 21 22" Force HTML indent to not keep state. 23let b: html_indent_usestate = 0 24 25if & l: indentexpr == '' 26if & l: cindent 27let & l: indentexpr = 'cindent(v:lnum)' 28else 29let & l: indentexpr = 'indent(prevnonblank(v:lnum-1))' 30endif 31endif 32let b: eruby_subtype_indentexpr = & l: indentexpr 33 34let b: did_indent = 1 35 36setlocal indentexpr = GetErubyIndent () 37setlocal indentkeys = o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when 38 39" Only define the function once. 40if exists ( "*GetErubyIndent" ) 41finish 42endif 43 44" this file uses line continuations 45let s: cpo_sav = & cpo 46set cpo & vim 47 48function ! GetErubyIndent (...) 49" The value of a single shift-width 50if exists ( '*shiftwidth' ) 51let sw = shiftwidth () 52else 53let sw = & sw 54endif 55 56if a: 0 && a: 1 == '.' 57let v: lnum = line ( '.' ) 58elseif a: 0 && a: 1 =~ '^\d' 59let v: lnum = a: 1 60endif 61let vcol = col ( '.' ) 62call cursor ( v: lnum , 1 ) 63let inruby = searchpair ( '<%' , '' , '%>' , 'W' ) 64call cursor ( v: lnum , vcol ) 65if inruby && getline ( v: lnum ) !~ '^<%\|^\s*[-=]\=%>' 66let ind = GetRubyIndent ( v: lnum ) 67else 68exe "let ind = " . b: eruby_subtype_indentexpr 69 70" Workaround for Andy Wokula's HTML indent. This should be removed after 71" some time, since the newest version is fixed in a different way. 72if b: eruby_subtype_indentexpr =~# '^HtmlIndent(' 73 \&& exists ( 'b:indent' ) 74 \&& type ( b: indent ) == type ({}) 75 \&& has_key ( b: indent , 'lnum' ) 76" Force HTML indent to not keep state 77let b: indent . lnum = -1 78endif 79endif 80let lnum = prevnonblank ( v: lnum - 1 ) 81let line = getline ( lnum ) 82let cline = getline ( v: lnum ) 83if cline =~# '^\s*<%[-=]\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%([-=]\=%>\|$\)' 84let ind = ind - sw 85endif 86if line =~# '\S\s*<%[-=]\=\s*\%(}\|end\).\{-\}\s*\%([-=]\=%>\|$\)' 87let ind = ind - sw 88endif 89if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*[-=]\=%>' 90let ind = ind + sw 91elseif line =~# '<%[-=]\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>' 92let ind = ind + sw 93endif 94if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>' 95let ind = ind + sw 96endif 97if line !~# '^\s*<%' && line =~# '%>\s*$' && line !~# '^\s*end\>' 98 \&& synID ( v: lnum , match ( cline , '\S' ) + 1 , 1 ) != hlID ( 'htmlEndTag' ) 99let ind = ind - sw 100endif 101if cline =~# '^\s*[-=]\=%>\s*$' 102let ind = ind - sw 103endif 104return ind 105endfunction 106 107let & cpo = s: cpo_sav 108unlet ! s: cpo_sav 109 110" vim:set sw=2 sts=2 ts=8 noet: