diff --git a/lua/treesj/langs/r.lua b/lua/treesj/langs/r.lua index 4b8cd98..6225c8b 100644 --- a/lua/treesj/langs/r.lua +++ b/lua/treesj/langs/r.lua @@ -3,14 +3,17 @@ local lang_utils = require('treesj.langs.utils') return { arguments = lang_utils.set_preset_for_args({ both = { - non_bracket_node = true, + separator = 'comma', }, split = { recursive_ignore = { 'subset' }, }, }), - formal_parameters = lang_utils.set_preset_for_args({ + parameters = lang_utils.set_preset_for_args({ + both = { + separator = 'comma', + }, split = { recursive_ignore = { 'subset' }, }, @@ -59,8 +62,8 @@ return { target_nodes = { 'arguments' }, }, - binary = { - target_nodes = { 'arguments' }, + binary_operator = { + target_nodes = { 'arguments', 'parameters' }, }, pipe = { diff --git a/tests/langs/r/r_join_spec.lua b/tests/langs/r/r_join_spec.lua index 402f068..5032647 100644 --- a/tests/langs/r/r_join_spec.lua +++ b/tests/langs/r/r_join_spec.lua @@ -19,7 +19,7 @@ local data_for_join = { mode = 'join', lang = LANG, desc = 'lang "%s", node "arguments", cursor at subset', - cursor = { 16, 3 }, + cursor = { 16, 2 }, expected = { 11, 12 }, result = { 14, 15 }, }, @@ -28,7 +28,7 @@ local data_for_join = { path = PATH, mode = 'join', lang = LANG, - desc = 'lang "%s", node "formal_parameters"', + desc = 'lang "%s", node "parameters"', cursor = { 26, 0 }, expected = { 20, 23 }, result = { 25, 28 }, @@ -108,7 +108,7 @@ local data_for_join = { path = PATH, mode = 'join', lang = LANG, - desc = 'lang "%s", node "binary"', + desc = 'lang "%s", node "binary_operator"', cursor = { 118, 0 }, expected = { 112, 114 }, result = { 116, 118 }, diff --git a/tests/langs/r/r_split_spec.lua b/tests/langs/r/r_split_spec.lua index 6ad6eaa..3b2dc00 100644 --- a/tests/langs/r/r_split_spec.lua +++ b/tests/langs/r/r_split_spec.lua @@ -19,7 +19,7 @@ local data_for_split = { mode = 'split', lang = LANG, desc = 'lang "%s", node "arguments", cursor at subset', - cursor = { 12, 6 }, + cursor = { 12, 5 }, expected = { 14, 18 }, result = { 11, 15 }, }, @@ -28,7 +28,7 @@ local data_for_split = { path = PATH, mode = 'split', lang = LANG, - desc = 'lang "%s", node "formal_parameters"', + desc = 'lang "%s", node "parameters"', cursor = { 21, 0 }, expected = { 25, 31 }, result = { 20, 26 }, @@ -108,7 +108,7 @@ local data_for_split = { path = PATH, mode = 'split', lang = LANG, - desc = 'lang "%s", node "binary"', + desc = 'lang "%s", node "binary_operator"', cursor = { 114, 0 }, expected = { 116, 120 }, result = { 112, 116 }, diff --git a/tests/sample/index.R b/tests/sample/index.R index ab76b08..ce2b6a5 100644 --- a/tests/sample/index.R +++ b/tests/sample/index.R @@ -17,12 +17,12 @@ mean( na.rm = TRUE ) -# RESULT OF JOIN (node "formal_parameters") +# RESULT OF JOIN (node "parameters") my_func <- function(xs = x[, 1], ys = y[, 2]) { sum(xs, ys) } -# RESULT OF SPLIT (node "formal_parameters") +# RESULT OF SPLIT (node "parameters") my_func <- function( xs = x[, 1], ys = y[, 2] @@ -109,11 +109,11 @@ ggplot( aes(x = Sepal.Width, y = Sepal.Length) ) -# RESULT OF JOIN (node "binary") +# RESULT OF JOIN (node "binary_operator") b %>% sum(c(4, 5, 6)) -# RESULT OF SPLIT (node "binary") +# RESULT OF SPLIT (node "binary_operator") b %>% sum( c(4, 5, 6)