diff --git a/lua/splitjoin/languages/ecmascript/defaults.lua b/lua/splitjoin/languages/ecmascript/defaults.lua index cc14bfd..4c4d6b7 100644 --- a/lua/splitjoin/languages/ecmascript/defaults.lua +++ b/lua/splitjoin/languages/ecmascript/defaults.lua @@ -52,7 +52,7 @@ return { join = ECMAScript.join_function, }, - ['function'] = { + function_expression = { split = ECMAScript.split_function, join = ECMAScript.join_function, }, diff --git a/lua/splitjoin/languages/ecmascript/functions.lua b/lua/splitjoin/languages/ecmascript/functions.lua index 38cd95b..00882fd 100644 --- a/lua/splitjoin/languages/ecmascript/functions.lua +++ b/lua/splitjoin/languages/ecmascript/functions.lua @@ -11,7 +11,7 @@ function ECMAScript.split_function(node, options) local type = child:type() if type == 'formal_parameters' then append(get_text(child)) elseif type == 'statement_block' then append(' {\n',indent, get_text(child):gsub('^{%s*', ''):gsub('%s*}$', ''), '\n}') - elseif type == 'function' then + elseif vim.startswith(type, 'function') then append('function') if node:type() == 'function_declaration' then append(' ') @@ -55,7 +55,7 @@ function ECMAScript.join_function(node, options) for child in node:iter_children() do local type = child:type() if type == 'formal_parameters' then append(get_text(child), ' ') - elseif type == 'function' then + elseif vim.startswith(type, 'function') then append('function') if node:type() == 'function_declaration' then append(' ') end elseif type == 'statement_block' then diff --git a/queries/javascript/splitjoin.scm b/queries/javascript/splitjoin.scm index d9ba1db..71049a2 100644 --- a/queries/javascript/splitjoin.scm +++ b/queries/javascript/splitjoin.scm @@ -7,7 +7,7 @@ ; functions (function_declaration) @splitjoin.javascript.function.declaration -(function) @splitjoin.javascript.function.lambda +(function_expression) @splitjoin.javascript.function.lambda (arrow_function) @splitjoin.javascript.function.arrow (arguments) @splitjoin.javascript.function.arguments (formal_parameters) @splitjoin.javascript.function.parameters