Skip to content

Commit

Permalink
fix(chainMember): do not ignore leading chain member
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Dec 1, 2024
1 parent 73976a8 commit ed38e52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Bundle of more than 30 new textobjects for Neovim.
| `number` | numbers, similar to `<C-a>` | inner: only pure digits, outer: number including minus sign and decimal point | small | `in`/`an` | all |
| `diagnostic` | LSP diagnostic (requires built-in LSP) | \- || `!` | all |
| `closedFold` | closed fold | outer includes one line after the last folded line | big | `iz`/`az` | all |
| `chainMember` | field with optional call, like `.foo(param)` or `.bar` | outer includes the leading `.` (or `:`) | small | `im`/`am` | all |
| `chainMember` | section of a chain connected with `.` like `foo.bar` or `foo.baz(para)` | outer includes the leading `.` (or `:`) | small | `im`/`am` | all |
| `visibleInWindow` | all lines visible in the current window | \- | \- | `gw` | all |
| `restOfWindow` | from the cursorline to the last line in the window | \- | \- | `gW` | all |
| `lastChange` | Last non-deletion-change, yank, or paste.[^2] | \- | \- | `g;` | all |
Expand Down
7 changes: 4 additions & 3 deletions lua/various-textobjs/charwise-textobjs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ end
M.urlPattern = "%l%l%l-://[A-Za-z0-9_%-/.#%%=?&'@+*:]+"
function M.url() M.selectTextobj(M.urlPattern, "outer", config.lookForwardBig) end

---see #26
---@param scope "inner"|"outer" inner excludes the leading dot
function M.chainMember(scope)
local patterns = {
"([:.])[%w_][%a_]-%b()()", -- with call
"([:.])[%w_][%a_]*()", -- without call
"()[%w_][%w_]-([:.])", -- leading member w/o call
"()[%w_][%w_]-%b()([:.])", -- leading member w/o call
"([:.])[%w_][%w_]-()", -- following member w/ call
"([:.])[%w_][%w_]-%b()()", -- following member w/ call
}
M.selectTextobj(patterns, scope, config.lookForwardSmall)
end
Expand Down

0 comments on commit ed38e52

Please sign in to comment.