From 129af41240eea9c0f64dd3c0076c80701edd867b Mon Sep 17 00:00:00 2001 From: ryanford-frontend Date: Sun, 17 Sep 2017 17:09:58 +0800 Subject: [PATCH 1/3] Support shorthand if correct indents --- indent/pico8.vim | 9 ++++++--- syntax/pico8.vim | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/indent/pico8.vim b/indent/pico8.vim index d1d2c0d..dcd3fba 100644 --- a/indent/pico8.vim +++ b/indent/pico8.vim @@ -36,11 +36,14 @@ function! GetLuaIndent() " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' let ind = indent(prevlnum) let prevline = getline(prevlnum) - let midx = match(prevline, '^\s*\%(if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)') + let midx = match(prevline, '^\s*\%(for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>)') if midx == -1 - let midx = match(prevline, '{\s*$') + let midx = match(prevline, 'then\s*\(--.*\)*$') if midx == -1 - let midx = match(prevline, '\\s*\%(\k\|[.:]\)\{-}\s*(') + let midx = match(prevline, '{\s*$') + if midx == -1 + let midx = match(prevline, '\\s*\%(\k\|[.:]\)\{-}\s*(') + endif endif endif diff --git a/syntax/pico8.vim b/syntax/pico8.vim index 42de77d..143cab3 100644 --- a/syntax/pico8.vim +++ b/syntax/pico8.vim @@ -46,10 +46,10 @@ syn match luaError "}" syn match luaError "\<\%(end\|else\|elseif\|then\|until\|in\)\>" " Function declaration -syn region luaFunctionBlock transparent matchgroup=luaFunction start="\" end="\" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd,luaRepeat +syn region luaFunctionBlock transparent matchgroup=luaFunction start="\" end="\" contains=ALL " if then else elseif end -syn keyword luaCond contained else +syn keyword luaCond contained else if " then ... end syn region luaCondEnd contained transparent matchgroup=luaCond start="\" end="\" contains=ALLBUT,luaTodo,luaSpecial,luaRepeat From 101f55102df569c2b89cd11d98335102ba2e9836 Mon Sep 17 00:00:00 2001 From: ryanford-frontend Date: Mon, 18 Sep 2017 00:10:57 +0800 Subject: [PATCH 2/3] Fix dropped backslash --- indent/pico8.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/pico8.vim b/indent/pico8.vim index dcd3fba..82d691f 100644 --- a/indent/pico8.vim +++ b/indent/pico8.vim @@ -36,7 +36,7 @@ function! GetLuaIndent() " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' let ind = indent(prevlnum) let prevline = getline(prevlnum) - let midx = match(prevline, '^\s*\%(for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>)') + let midx = match(prevline, '^\s*\%(for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>)\') if midx == -1 let midx = match(prevline, 'then\s*\(--.*\)*$') if midx == -1 From f6bd12c71d60910060c0a02b53030e828507faaf Mon Sep 17 00:00:00 2001 From: ryanford-frontend Date: Mon, 18 Sep 2017 00:18:58 +0800 Subject: [PATCH 3/3] Fix dropped backslash --- indent/pico8.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/pico8.vim b/indent/pico8.vim index 82d691f..825e8a1 100644 --- a/indent/pico8.vim +++ b/indent/pico8.vim @@ -36,7 +36,7 @@ function! GetLuaIndent() " 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{' let ind = indent(prevlnum) let prevline = getline(prevlnum) - let midx = match(prevline, '^\s*\%(for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>)\') + let midx = match(prevline, '^\s*\%(for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\|then\>\)') if midx == -1 let midx = match(prevline, 'then\s*\(--.*\)*$') if midx == -1