Skip to content

Commit

Permalink
fix(javascript)!: function expression
Browse files Browse the repository at this point in the history
drops support for older versions of tree-sitter-javascript
  • Loading branch information
bennypowers committed Apr 10, 2024
1 parent 8beb128 commit 6b8ca32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/splitjoin/languages/ecmascript/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ return {
join = ECMAScript.join_function,
},

['function'] = {
function_expression = {
split = ECMAScript.split_function,
join = ECMAScript.join_function,
},
Expand Down
4 changes: 2 additions & 2 deletions lua/splitjoin/languages/ecmascript/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion queries/javascript/splitjoin.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b8ca32

Please sign in to comment.