This commit is contained in:
Adam Stankiewicz
2020-08-06 13:22:17 +02:00
parent 56121b4e27
commit 1e533e5982
10 changed files with 1073 additions and 962 deletions

View File

@@ -31,6 +31,8 @@ let s:close_patt = '\C\%(\<\%(end\|until\)\>\|)\|}\)'
let s:anon_func_start = '\S\+\s*[({].*\<function\s*(.*)\s*$'
let s:anon_func_end = '\<end\%(\s*[)}]\)\+'
let s:chained_func_call = "^\\v\\s*[:.]\\w+[({\"']"
" Expression used to check whether we should skip a match with searchpair().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~# 'luaComment\\|luaString'"
@@ -100,6 +102,16 @@ function GetLuaIndent()
let i += 1
endif
" if the current line chains a function call to previous unchained line
if contents_prev !~# s:chained_func_call && contents_cur =~# s:chained_func_call
let i += 1
endif
" if the current line chains a function call to previous unchained line
if contents_prev =~# s:chained_func_call && contents_cur !~# s:chained_func_call
let i -= 1
endif
" special case: call(with, {anon = function() -- should indent only once
if i > 1 && contents_prev =~# s:anon_func_start
let i = 1