2014-07-10 21:05:51 -07:00
|
|
|
" Vim indent file
|
2017-11-05 21:05:54 -07:00
|
|
|
" Language: Treetop
|
|
|
|
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
|
|
|
" Latest Revision: 2011-03-14
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
if exists("b:did_indent")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let b:did_indent = 1
|
|
|
|
|
|
|
|
setlocal indentexpr=GetTreetopIndent()
|
|
|
|
setlocal indentkeys=0{,0},!^F,o,O,=end
|
|
|
|
setlocal nosmartindent
|
|
|
|
|
|
|
|
if exists("*GetTreetopIndent")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
function GetTreetopIndent()
|
|
|
|
let pnum = prevnonblank(v:lnum - 1)
|
|
|
|
if pnum == 0
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
let ind = indent(pnum)
|
|
|
|
let line = getline(pnum)
|
|
|
|
|
|
|
|
if line =~ '^\s*\%(grammar\|module\|rule\)\>'
|
2017-11-05 21:26:57 -07:00
|
|
|
let ind += shiftwidth()
|
2014-07-10 21:05:51 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
let line = getline(v:lnum)
|
|
|
|
if line =~ '^\s*end\>'
|
2017-11-05 21:26:57 -07:00
|
|
|
let ind -= shiftwidth()
|
2014-07-10 21:05:51 -07:00
|
|
|
end
|
|
|
|
|
2021-09-13 07:33:41 -07:00
|
|
|
return ind
|
2014-07-10 21:05:51 -07:00
|
|
|
endfunction
|