Skip to content
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 textobjects.scm #159

Merged
merged 8 commits into from
Nov 29, 2024
Merged

feat: add textobjects.scm #159

merged 8 commits into from
Nov 29, 2024

Conversation

mrdgo
Copy link
Contributor

@mrdgo mrdgo commented Nov 28, 2024

This PR implements the first queries for #119.

With this sample config, you can hit yaf (yank around function) to copy the closest function, dif (delete in function) to clear the contet of the closest function, with sourround-like plugins ysaSb (sourround around "()"-block) to sourround a statement with parentheses, or whatever keys you map to what query.

textobjects = {
    select = {
        enable = true,
        keymaps = {
            -- You can use the capture groups defined in textobjects.scm
            -- For example:
            -- Nushell only
            ["aP"] = "@pipeline.outer",
            ["iP"] = "@pipeline.inner", -- selects the closest pipeline element

            -- supported in other languages as well
            ["af"] = "@function.outer",
            ["if"] = "@function.inner",
            ["al"] = "@loop.outer",
            ["il"] = "@loop.inner",
            ["aC"] = "@conditional.outer",
            ["iC"] = "@conditional.inner",
            ["iS"] = "@statement.inner",
            ["aS"] = "@statement.outer",
        }, -- keymaps
    }, -- select
}, -- textobjects

To me, these queries are sufficient. I wouldn't setup any other ones, so I'd declare this as ready to merge. Feel free to request additional queries.

@mrdgo mrdgo marked this pull request as ready for review November 28, 2024 22:04
@fdncred
Copy link
Collaborator

fdncred commented Nov 29, 2024

Looks fun! Thanks!

@fdncred fdncred merged commit 7c0628f into nushell:main Nov 29, 2024
3 checks passed
@mrdgo mrdgo mentioned this pull request Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants