Mercurial > vim
view runtime/indent/idlang.vim @ 26792:30d8377ea1b1 v8.2.3924
patch 8.2.3924: Vim9: no error if something follows :enddef
Commit: https://github.com/vim/vim/commit/7473a84cf935f64ddd4ea7fe7eee0f9c51c50b60
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 28 17:55:26 2021 +0000
patch 8.2.3924: Vim9: no error if something follows :enddef
Problem: Vim9: no error if something follows :enddef in a nested function.
Solution: Give an error. Move common code to a function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 28 Dec 2021 19:00:05 +0100 |
parents | 9c221ad9634a |
children | 6dd88e45d47d |
line wrap: on
line source
" IDL (Interactive Data Language) indent file. " Language: IDL (ft=idlang) " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com> (Invalid email address) " Doug Kearns <dougkearns@gmail.com> " Last change: 2017 Jun 13 " Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP setlocal indentexpr=GetIdlangIndent(v:lnum) " Only define the function once. if exists("*GetIdlangIndent") finish endif function GetIdlangIndent(lnum) " First non-empty line above the current line. let pnum = prevnonblank(v:lnum-1) " v:lnum is the first non-empty line -- zero indent. if pnum == 0 return 0 endif " Second non-empty line above the current line. let pnum2 = prevnonblank(pnum-1) " Current indent. let curind = indent(pnum) " Indenting of continued lines. if getline(pnum) =~ '\$\s*\(;.*\)\=$' if getline(pnum2) !~ '\$\s*\(;.*\)\=$' let curind = curind+shiftwidth() endif else if getline(pnum2) =~ '\$\s*\(;.*\)\=$' let curind = curind-shiftwidth() endif endif " Indenting blocks of statements. if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>' if getline(pnum) =~? 'begin\>' elseif indent(v:lnum) > curind-shiftwidth() let curind = curind-shiftwidth() else return -1 endif elseif getline(pnum) =~? 'begin\>' if indent(v:lnum) < curind+shiftwidth() let curind = curind+shiftwidth() else return -1 endif endif return curind endfunction