From 7b9e11ad89549f08e1c750fc46bff0a03f059d95 Mon Sep 17 00:00:00 2001 From: William Chargin Date: Wed, 30 Dec 2015 16:43:57 -0800 Subject: [PATCH] Make arrow-functions one-liners Summary: This fixes the indentation for expression arrow functions that are continued on multiple lines. This does not affect the `FunctionBody` variant of arrow functions, which were already correct due to the opening brace. Resolves pangloss/vim-javascript#332. Test Plan: Type ```javascript const myNiftyArrowFunction = (foo, bar) => foo + bar; myNiftyArrowFunction(1, 2); ``` and note that it's indented correctly as you type. Then run `gg=G` and make sure that it stays indented correctly. Note also that the indentation of ```javascript const myFunctionBodiedArrowFunction = (foo, bar) => { doAThing(); return foo + bar; }; myFunctionBodiedArrowFunction(1, 2); ``` is still correct. --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 0f526db9..6ce1db8f 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -55,7 +55,7 @@ let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@[^{;]*' . s:line_term +let s:one_line_scope_regex = '\%(\<\%(if\|else\|for\|while\)\>\|=>\)[^{;]*' . s:line_term " Regex that defines blocks. let s:block_regex = '\%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term