view runtime/indent/treetop.vim @ 32491:32c9b7396a75 v9.0.1577

patch 9.0.1577: MS-Windows: context menu translations may be wrong Commit: https://github.com/vim/vim/commit/1271572a35ae215fa023d97db9896c5745591024 Author: K.Takata <kentkt@csc.jp> Date: Thu May 25 16:43:27 2023 +0100 patch 9.0.1577: MS-Windows: context menu translations may be wrong Problem: MS-Windows: context menu translations may be wrong. Solution: Set the encoding before using gettext(). (Ken Takata, closes #12441, closes #12431)
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 May 2023 17:45:05 +0200
parents 4d76b3e07c07
children
line wrap: on
line source

" Vim indent file
" Language:		Treetop
" Maintainer:		Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer:	Nikolai Weibull <now@bitwi.se>
" Last Change:		2022 April 25

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

let b:undo_indent = "setl inde< indk< si<"

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\)\>'
    let ind += shiftwidth()
  endif

  let line = getline(v:lnum)
  if line =~ '^\s*end\>'
    let ind -= shiftwidth()
  end

  return ind
endfunction