diff --git a/book/src/guides/textobject.md b/book/src/guides/textobject.md index 7200a5144de20..e9b441be3d75f 100644 --- a/book/src/guides/textobject.md +++ b/book/src/guides/textobject.md @@ -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. diff --git a/book/src/keymap.md b/book/src/keymap.md index 5de4edf93f88d..ce9a7491876a0 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -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` | diff --git a/book/src/usage.md b/book/src/usage.md index 039628bf86929..743c3d737546d 100644 --- a/book/src/usage.md +++ b/book/src/usage.md @@ -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) @@ -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 @@ -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. diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3839cbe6a0e2d..e5eb8a8058370 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -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", @@ -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) { @@ -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() { diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 0147f58e14738..13111c19448ca 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -607,7 +607,7 @@ 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" @@ -615,7 +615,7 @@ impl Default for Keymaps { "D" => goto_last_diag, "f" => goto_next_function, "c" => goto_next_class, - "p" => goto_next_parameter, + "a" => goto_next_argument, "space" => add_newline_below, }, diff --git a/runtime/queries/c/textobjects.scm b/runtime/queries/c/textobjects.scm index b0f0366850239..668873c28fb42 100644 --- a/runtime/queries/c/textobjects.scm +++ b/runtime/queries/c/textobjects.scm @@ -10,4 +10,4 @@ (union_specifier body: (_) @class.inside) @class.around -(parameter_declaration) @parameter.inside +(parameter_declaration) @argument.inside diff --git a/runtime/queries/cmake/textobjects.scm b/runtime/queries/cmake/textobjects.scm index b0d1b10834d69..fa9bf7792edbc 100644 --- a/runtime/queries/cmake/textobjects.scm +++ b/runtime/queries/cmake/textobjects.scm @@ -1,3 +1,3 @@ (macro_def) @function.around -(argument) @parameter.inside +(argument) @argument.inside diff --git a/runtime/queries/go/textobjects.scm b/runtime/queries/go/textobjects.scm index 9bcfc69030f72..0525dbc23faa9 100644 --- a/runtime/queries/go/textobjects.scm +++ b/runtime/queries/go/textobjects.scm @@ -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) diff --git a/runtime/queries/llvm-mir/textobjects.scm b/runtime/queries/llvm-mir/textobjects.scm index 73f6f7728dc12..3b0c27ac07924 100644 --- a/runtime/queries/llvm-mir/textobjects.scm +++ b/runtime/queries/llvm-mir/textobjects.scm @@ -1,3 +1,3 @@ (basic_block) @function.around -(argument) @parameter.inside +(argument) @argument.inside diff --git a/runtime/queries/llvm/textobjects.scm b/runtime/queries/llvm/textobjects.scm index 3738a3bb92181..2414b1010f40e 100644 --- a/runtime/queries/llvm/textobjects.scm +++ b/runtime/queries/llvm/textobjects.scm @@ -13,4 +13,4 @@ (vector_type (array_vector_body) @class.inside) @class.around -(argument) @parameter.inside +(argument) @argument.inside diff --git a/runtime/queries/perl/textobjects.scm b/runtime/queries/perl/textobjects.scm index 988e22b49bcc5..63d97ab7a5350 100644 --- a/runtime/queries/perl/textobjects.scm +++ b/runtime/queries/perl/textobjects.scm @@ -5,4 +5,4 @@ (_) @function.inside) @function.around (argument - (_) @parameter.inside) + (_) @argument.inside) diff --git a/runtime/queries/php/textobjects.scm b/runtime/queries/php/textobjects.scm index 04ffefd221370..749ced5cf3ce0 100644 --- a/runtime/queries/php/textobjects.scm +++ b/runtime/queries/php/textobjects.scm @@ -27,4 +27,4 @@ (simple_parameter) (variadic_parameter) (property_promotion_parameter) - ] @parameter.inside) + ] @argument.inside) diff --git a/runtime/queries/python/textobjects.scm b/runtime/queries/python/textobjects.scm index a52538afd6259..aa8a8bde5bc02 100644 --- a/runtime/queries/python/textobjects.scm +++ b/runtime/queries/python/textobjects.scm @@ -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) diff --git a/runtime/queries/rust/textobjects.scm b/runtime/queries/rust/textobjects.scm index e3132687af128..a398769a4518f 100644 --- a/runtime/queries/rust/textobjects.scm +++ b/runtime/queries/rust/textobjects.scm @@ -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) diff --git a/runtime/queries/tablegen/textobjects.scm b/runtime/queries/tablegen/textobjects.scm index 2cb802688031d..2313eca4f408d 100644 --- a/runtime/queries/tablegen/textobjects.scm +++ b/runtime/queries/tablegen/textobjects.scm @@ -4,4 +4,4 @@ (multiclass body: (_) @class.inside) @class.around -(_ argument: _ @parameter.inside) +(_ argument: _ @argument.inside)