1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-23 02:05:11 +01:00
vim/runtime/indent/treetop.vim

39 lines
708 B
VimL
Raw Normal View History

2011-03-22 14:05:35 +01:00
" Vim indent file
2017-03-05 17:04:09 +01:00
" Language: Treetop
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2011-03-14
2011-03-22 14:05:35 +01: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-03-16 17:41:02 +01:00
let ind += shiftwidth()
2011-03-22 14:05:35 +01:00
endif
let line = getline(v:lnum)
if line =~ '^\s*end\>'
2017-03-16 17:41:02 +01:00
let ind -= shiftwidth()
2011-03-22 14:05:35 +01:00
end
2021-09-09 21:55:11 +02:00
return ind
2011-03-22 14:05:35 +01:00
endfunction