Skip to content

Commit

Permalink
Rename parameter textobject to argument
Browse files Browse the repository at this point in the history
Primarily to work around p being used for paragraph textobject
  • Loading branch information
sudormrfbin committed Feb 25, 2022
1 parent 6a6a9ab commit d6f59fe
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion book/src/guides/textobject.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The following [captures][tree-sitter-captures] are recognized:
| `function.around` |
| `class.inside` |
| `class.around` |
| `parameter.inside` |
| `argument.inside` |

[Example query files][textobject-examples] can be found in the helix GitHub repository.

Expand Down
4 changes: 2 additions & 2 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
| `[f` | Go to previous function (**TS**) | `goto_prev_function` |
| `]c` | Go to next class (**TS**) | `goto_next_class` |
| `[c` | Go to previous class (**TS**) | `goto_prev_class` |
| `]p` | Go to next parameter (**TS**) | `goto_next_parameter` |
| `[p` | Go to previous parameter (**TS**) | `goto_prev_parameter` |
| `]a` | Go to next argument (**TS**) | `goto_next_parameter` |
| `[a` | Go to previous argument (**TS**) | `goto_prev_parameter` |
| `[space` | Add newline above | `add_newline_above` |
| `]space` | Add newline below | `add_newline_below` |

Expand Down
6 changes: 3 additions & 3 deletions book/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Multiple characters are currently not supported, but planned.

## Textobjects

Currently supported: `word`, `surround`, `function`, `class`, `parameter`.
Currently supported: `word`, `surround`, `function`, `class`, `argument`.

![textobject-demo](https://user-images.githubusercontent.com/23398472/124231131-81a4bb00-db2d-11eb-9d10-8e577ca7b177.gif)
![textobject-treesitter-demo](https://user-images.githubusercontent.com/23398472/132537398-2a2e0a54-582b-44ab-a77f-eb818942203d.gif)
Expand All @@ -68,7 +68,7 @@ Currently supported: `word`, `surround`, `function`, `class`, `parameter`.
| `(`, `[`, `'`, etc | Specified surround pairs |
| `f` | Function |
| `c` | Class |
| `p` | Parameter |
| `a` | Argument |

> NOTE: `f`, `c`, etc need a tree-sitter grammar active for the current
document and a special tree-sitter query file to work properly. [Only
Expand All @@ -77,7 +77,7 @@ Contributions are welcome!

## Tree-sitter Textobject Based Navigation

Navigating between functions, classes, parameters, etc is made
Navigating between functions, classes, arguments, etc is made
possible by leveraging tree-sitter and textobjects queries. For
example to move to the next function use `]f`, to move to previous
class use `[c`, and so on.
Expand Down
14 changes: 7 additions & 7 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ impl MappableCommand {
goto_prev_function, "Goto previous function",
goto_next_class, "Goto next class",
goto_prev_class, "Goto previous class",
goto_next_parameter, "Goto next parameter",
goto_prev_parameter, "Goto previous parameter",
goto_next_argument, "Goto next argument",
goto_prev_argument, "Goto previous argument",
dap_launch, "Launch debug target",
dap_toggle_breakpoint, "Toggle breakpoint",
dap_continue, "Continue program execution",
Expand Down Expand Up @@ -5335,12 +5335,12 @@ fn goto_prev_class(cx: &mut Context) {
goto_ts_object_impl(cx, "class", Direction::Backward)
}

fn goto_next_parameter(cx: &mut Context) {
goto_ts_object_impl(cx, "parameter", Direction::Forward)
fn goto_next_argument(cx: &mut Context) {
goto_ts_object_impl(cx, "argument", Direction::Forward)
}

fn goto_prev_parameter(cx: &mut Context) {
goto_ts_object_impl(cx, "parameter", Direction::Backward)
fn goto_prev_argument(cx: &mut Context) {
goto_ts_object_impl(cx, "argument", Direction::Backward)
}

fn select_textobject_around(cx: &mut Context) {
Expand Down Expand Up @@ -5381,7 +5381,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
'W' => textobject::textobject_word(text, range, objtype, count, true),
'c' => textobject_treesitter("class", range),
'f' => textobject_treesitter("function", range),
'p' => textobject_treesitter("parameter", range),
'a' => textobject_treesitter("argument", range),
'm' => {
let ch = text.char(range.cursor(text));
if !ch.is_ascii_alphanumeric() {
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,15 @@ impl Default for Keymaps {
"D" => goto_first_diag,
"f" => goto_prev_function,
"c" => goto_prev_class,
"p" => goto_prev_parameter,
"a" => goto_prev_argument,
"space" => add_newline_above,
},
"]" => { "Right bracket"
"d" => goto_next_diag,
"D" => goto_last_diag,
"f" => goto_next_function,
"c" => goto_next_class,
"p" => goto_next_parameter,
"a" => goto_next_argument,
"space" => add_newline_below,
},

Expand Down
2 changes: 1 addition & 1 deletion runtime/queries/c/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
(union_specifier
body: (_) @class.inside) @class.around

(parameter_declaration) @parameter.inside
(parameter_declaration) @argument.inside
2 changes: 1 addition & 1 deletion runtime/queries/cmake/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(macro_def) @function.around

(argument) @parameter.inside
(argument) @argument.inside
4 changes: 2 additions & 2 deletions runtime/queries/go/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(type_spec (type_identifier) (interface_type (method_spec_list (_)?) @class.inside))) @class.around

(parameter_list
(_) @parameter.inside)
(_) @argument.inside)

(argument_list
(_) @parameter.inside)
(_) @argument.inside)
2 changes: 1 addition & 1 deletion runtime/queries/llvm-mir/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(basic_block) @function.around

(argument) @parameter.inside
(argument) @argument.inside
2 changes: 1 addition & 1 deletion runtime/queries/llvm/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
(vector_type
(array_vector_body) @class.inside) @class.around

(argument) @parameter.inside
(argument) @argument.inside
2 changes: 1 addition & 1 deletion runtime/queries/perl/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
(_) @function.inside) @function.around

(argument
(_) @parameter.inside)
(_) @argument.inside)
2 changes: 1 addition & 1 deletion runtime/queries/php/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
(simple_parameter)
(variadic_parameter)
(property_promotion_parameter)
] @parameter.inside)
] @argument.inside)
6 changes: 3 additions & 3 deletions runtime/queries/python/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
body: (block)? @class.inside) @class.around

(parameters
(_) @parameter.inside)
(_) @argument.inside)

(lambda_parameters
(_) @parameter.inside)
(_) @argument.inside)

(argument_list
(_) @parameter.inside)
(_) @argument.inside)
6 changes: 3 additions & 3 deletions runtime/queries/rust/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
body: (_) @class.inside) @class.around

(parameters
(_) @parameter.inside)
(_) @argument.inside)

(closure_parameters
(_) @parameter.inside)
(_) @argument.inside)

(arguments
(_) @parameter.inside)
(_) @argument.inside)
2 changes: 1 addition & 1 deletion runtime/queries/tablegen/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
(multiclass
body: (_) @class.inside) @class.around

(_ argument: _ @parameter.inside)
(_ argument: _ @argument.inside)

0 comments on commit d6f59fe

Please sign in to comment.