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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
785 B
VimL
Raw Permalink Normal View History

2011-03-22 14:05:35 +01:00
" Vim indent file
2022-04-27 15:25:03 +01:00
" Language: Treetop
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Last Change: 2022 April 25
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
2022-04-27 15:25:03 +01:00
let b:undo_indent = "setl inde< indk< si<"
2011-03-22 14:05:35 +01:00
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