-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add motions and textobjects #21
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Created `get_cursor` function to retrieve cursor information for the current position in the buffer. - The `get_cursor` function checks if the current line is a comment or a valid CSV row and returns cursor information including CSV row/column and an "anchor" state.
- Added `is_valid_row` method to check if the row index is valid. - Added `is_empty_field` method to check if the column is empty. - Added `is_last_col` method to check if the cursor is at the last column. - Added `col_idx_to_byte` method to get byte offset from column index. - Added `byte_to_col_idx` method to get column index from byte position.
- Implemented motion module with functions for navigating CSV fields. - Added textobject module to select current field in visual mode. - Included utility functions for clamping values and checking row validity. - Enhanced cursor movement with options for relative and absolute positioning. - Improved user experience with customizable jump options.
Add unit tests for the textobject module in csvview. These tests cover various scenarios including selecting fields with and without delimiters, handling comments, and empty lines.
Add tests for the motion module to ensure correct cursor movements within CSV files. These tests cover various scenarios including relative and absolute positioning, skipping comments, and handling empty lines.
The previous implementation had an issue where the cursor would not correctly jump to the previous end of the field. This change ensures that the cursor moves accurately by adjusting the column increases appropriately.
cedcec2
to
b36f251
Compare
- Added keymaps and actions support to csvview. - Renamed motion.lua to jump.lua for better clarity. - Updated tests to reflect the changes in function names.
- Added new fields to `CsvView.Options` class. - Updated `CsvView.Options` to `CsvView.InternalOptions` in various functions and classes.
Updated README.md to include new keymaps for text objects and Excel-like navigation. Added detailed configuration options and examples for better customization and usage.
f2ec35f
to
3dd22d3
Compare
3dd22d3
to
70e0410
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces new motion- and textobject-related APIs designed to enhance CSV navigation and selection in csvview.nvim.
The two primary additions are:
field()
function injump.lua
, enabling cursor movements based on CSV row/column coordinates (both relative and absolute).field()
textobject intextobject.lua
, allowing you to select the current CSV field (with optional delimiter inclusion).Additionally, several supporting changes are included:
jump.lua
(e.g.,next_field_end
,prev_field_end
, etc.) that behave like Vim's native motions (w
,b
,e
,ge
) but specifically for CSV fields.get_cursor()
function inutil.lua
that retrieves the cursor’s position with CSV-awareness (i.e., which row/column in the CSV, whether on a delimiter, etc.).1.
field()
injump.lua
pos = { row_offset, col_offset }
from the current field.mode = "absolute"
interpretspos
as 1-based row/column."start"
, place the cursor at field start;"end"
jumps to field end.For convenience, there are also shorthand motions such as:
2.
field()
textobject intextobject.lua
include_delimiter = true
if you want to include the trailing or preceding comma in your selection.References: #16