runtime(lua): fix whitespace style issues in lua ftplugin

related: #17049

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-04-07 14:07:28 +02:00
parent 00b927b295
commit 2ffb4d0298

View File

@ -1,13 +1,14 @@
" Vim filetype plugin file. " Vim filetype plugin file.
" Language: Lua
" Maintainer: Doug Kearns <dougkearns@gmail.com> " Language: Lua
" Previous Maintainer: Max Ischenko <mfi@ukr.net> " Maintainer: Doug Kearns <dougkearns@gmail.com>
" Contributor: Dorai Sitaram <ds26@gte.com> " Previous Maintainer: Max Ischenko <mfi@ukr.net>
" C.D. MacEachern <craig.daniel.maceachern@gmail.com> " Contributor: Dorai Sitaram <ds26@gte.com>
" Tyler Miller <tmillr@proton.me> " C.D. MacEachern <craig.daniel.maceachern@gmail.com>
" Phạm Bình An <phambinhanctb2004@gmail.com> " Tyler Miller <tmillr@proton.me>
" @konfekt " Phạm Bình An <phambinhanctb2004@gmail.com>
" Last Change: 2025 Apr 04 " @konfekt
" Last Change: 2025 Apr 04
if exists("b:did_ftplugin") if exists("b:did_ftplugin")
finish finish
@ -42,11 +43,11 @@ let b:undo_ftplugin = "setl cms< com< def< fo< inc< inex< sua<"
if exists("loaded_matchit") && !exists("b:match_words") if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0 let b:match_ignorecase = 0
let b:match_words = let b:match_words =
\ '\<\%(do\|function\|if\)\>:' .. \ '\<\%(do\|function\|if\)\>:' ..
\ '\<\%(return\|else\|elseif\)\>:' .. \ '\<\%(return\|else\|elseif\)\>:' ..
\ '\<end\>,' .. \ '\<end\>,' ..
\ '\<repeat\>:\<until\>,' .. \ '\<repeat\>:\<until\>,' ..
\ '\%(--\)\=\[\(=*\)\[:]\1]' \ '\%(--\)\=\[\(=*\)\[:]\1]'
let b:undo_ftplugin ..= " | unlet! b:match_words b:match_ignorecase" let b:undo_ftplugin ..= " | unlet! b:match_words b:match_ignorecase"
endif endif
@ -88,15 +89,15 @@ function s:LuaInclude(fname) abort
endfunction endfunction
let s:patterns = [ let s:patterns = [
\ ['do', 'end'], \ ['do', 'end'],
\ ['if\s+.+\s+then', 'end'], \ ['if\s+.+\s+then', 'end'],
\ ['repeat', 'until\s+.+'], \ ['repeat', 'until\s+.+'],
\ ['for\s+.+\s+do', 'end'], \ ['for\s+.+\s+do', 'end'],
\ ['while\s+.+\s+do', 'end'], \ ['while\s+.+\s+do', 'end'],
\ ['function.+', 'end'], \ ['function.+', 'end'],
\ ['return\s+function.+', 'end'], \ ['return\s+function.+', 'end'],
\ ['local\s+function\s+.+', 'end'], \ ['local\s+function\s+.+', 'end'],
\ ] \ ]
function s:LuaFold() abort function s:LuaFold() abort
if b:lua_lasttick == b:changedtick if b:lua_lasttick == b:changedtick
@ -114,17 +115,17 @@ function s:LuaFold() abort
let tagopen = '\v^\s*' .. t[0] ..'\s*$' let tagopen = '\v^\s*' .. t[0] ..'\s*$'
let tagend = '\v^\s*' .. t[1] ..'\s*$' let tagend = '\v^\s*' .. t[1] ..'\s*$'
if line =~# tagopen if line =~# tagopen
call add(foldlist, t) call add(foldlist, t)
let open = 1 let open = 1
break break
elseif line =~# tagend elseif line =~# tagend
if len(foldlist) > 0 && line =~# foldlist[-1][1] if len(foldlist) > 0 && line =~# foldlist[-1][1]
call remove(foldlist, -1) call remove(foldlist, -1)
let end = 1 let end = 1
else else
let foldlist = [] let foldlist = []
endif endif
break break
endif endif
endfor endfor
let prefix = "" let prefix = ""
@ -160,17 +161,17 @@ def s:LuaFold(): string
var tagopen = '\v^\s*' .. t[0] .. '\s*$' var tagopen = '\v^\s*' .. t[0] .. '\s*$'
var tagend = '\v^\s*' .. t[1] .. '\s*$' var tagend = '\v^\s*' .. t[1] .. '\s*$'
if line =~# tagopen if line =~# tagopen
add(foldlist, t) add(foldlist, t)
open = 1 open = 1
break break
elseif line =~# tagend elseif line =~# tagend
if len(foldlist) > 0 && line =~# foldlist[-1][1] if len(foldlist) > 0 && line =~# foldlist[-1][1]
end = 1 end = 1
remove(foldlist, -1) remove(foldlist, -1)
else else
foldlist = [] foldlist = []
endif endif
break break
endif endif
endfor endfor
var prefix = "" var prefix = ""
@ -183,4 +184,5 @@ enddef
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
" vim: nowrap sw=2 sts=2 ts=8 noet: " vim: nowrap sw=2 sts=2 ts=8 noet: