neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

treetop.vim (785B)


      1 " Vim indent file
      2 " Language:		Treetop
      3 " Maintainer:		Doug Kearns <dougkearns@gmail.com>
      4 " Previous Maintainer:	Nikolai Weibull <now@bitwi.se>
      5 " Last Change:		2022 April 25
      6 
      7 if exists("b:did_indent")
      8  finish
      9 endif
     10 let b:did_indent = 1
     11 
     12 setlocal indentexpr=GetTreetopIndent()
     13 setlocal indentkeys=0{,0},!^F,o,O,=end
     14 setlocal nosmartindent
     15 
     16 let b:undo_indent = "setl inde< indk< si<"
     17 
     18 if exists("*GetTreetopIndent")
     19  finish
     20 endif
     21 
     22 function GetTreetopIndent()
     23  let pnum = prevnonblank(v:lnum - 1)
     24  if pnum == 0
     25    return 0
     26  endif
     27 
     28  let ind = indent(pnum)
     29  let line = getline(pnum)
     30 
     31  if line =~ '^\s*\%(grammar\|module\|rule\)\>'
     32    let ind += shiftwidth()
     33  endif
     34 
     35  let line = getline(v:lnum)
     36  if line =~ '^\s*end\>'
     37    let ind -= shiftwidth()
     38  end
     39 
     40  return ind
     41 endfunction