Skip to content

Commit

Permalink
feat: update R treesitter nodes naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Wansmer committed Jul 4, 2024
1 parent f98deb3 commit dda3747
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
11 changes: 7 additions & 4 deletions lua/treesj/langs/r.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
},
Expand Down Expand Up @@ -59,8 +62,8 @@ return {
target_nodes = { 'arguments' },
},

binary = {
target_nodes = { 'arguments' },
binary_operator = {
target_nodes = { 'arguments', 'parameters' },
},

pipe = {
Expand Down
6 changes: 3 additions & 3 deletions tests/langs/r/r_join_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
Expand All @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
6 changes: 3 additions & 3 deletions tests/langs/r/r_split_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
Expand All @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
8 changes: 4 additions & 4 deletions tests/sample/index.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dda3747

Please sign in to comment.