Skip to content

Support markdown scope for targeting code blocks #1992

Closed

Description

@fidgetingbits

It would be useful to have a scope to target markdown blocks of code inside ``` pairs. I regularly find myself wanting to chuck them, change inside them, or move out of them, and it's often in a scenario where there's no visible ` characters to use instance with.

Activity

  1. auscompgeek commented on Nov 3, 2023

    @auscompgeek
    Member

    Wouldn't change inside skis work in this scenario?

  2. fidgetingbits commented on Nov 3, 2023

    @fidgetingbits
    CollaboratorAuthor

    It doesn't work for me no.

  3. josharian commented on Nov 3, 2023

    @josharian
    Collaborator

    Bringing over some comments from Slack:

    I do a lot of work in a templating language with no cursorless support. There are lots of paired {{ and }}. I wonder whether more general text-based support for multiple paired delimiters would be helpful. That’d also handle Python’s “”” … “””.

    ya I suppose I should try a regex scope in the meantime. haven't used one before so an excuse to dabble I guess.

    some general text-based support seems like it coild be good. more examples: nix language uses double ticks ''foo'' for multi-line strings, lua uses [[foo]].

  4. added
    lang-markdown
    on Nov 6, 2023
  5. auscompgeek commented on Nov 6, 2023

    @auscompgeek
    Member

    In light of #1980, it might make sense to call code blocks "notebook cells". That'd be consistent with various literate programming formats.

  6. fidgetingbits commented on Nov 7, 2023

    @fidgetingbits
    CollaboratorAuthor

    Ya I think that makes sense.

  7. pokey commented on Nov 7, 2023

    @pokey
    Member

    huh that's an interesting idea. I guess one problem thing to think about is what happens if there a markdown cell in a notebook, that itself contains a code block. Arguably that could just be a nested scope, but might be surprising? Idk, generally speaking I'm in favour of fewer scopes so I think it's fine, just can't help but point out corner cases 😅

  8. fidgetingbits commented on Nov 8, 2023

    @fidgetingbits
    CollaboratorAuthor

    Has there been discussion of something like 'outside' or 'parent' modifier similar to 'inside' where you target the parent scope?

    I've never used jupyter so not sure, but say you were in a cell containing markdown containing a code block but the block was big enough you couldn't see any part of the parent jupyter cell but then wanted to target it, I believe atm you couldn't?

    I wonder if something like that would make this type of problem you mention slightly more natural to deal with.

    This type of modifier could help in other similar situations I suppose like if you are in a big python closure and have no hats from the containing function, but want to reference it? Similar how you can jump to a class from its method.

    That also raises the question in relation to your counter example: if you are in a nested language that triggers a new treesitter parser, does that show up cleanly in the node tree in a way that we could query? And even if it did, I'm not sure if/how cursorless deals with nested languages atm.

  9. auscompgeek commented on Nov 8, 2023

    @auscompgeek
    Member

    if you are in a nested language that triggers a new treesitter parser

    I believe Cursorless currently doesn't support nested languages. Definitely a feature everyone wants, and potentially doable after everything is moved to tree-sitter queries…

  10. pokey commented on Nov 8, 2023

    @pokey
    Member

    if you are in a nested language that triggers a new treesitter parser

    I believe Cursorless currently doesn't support nested languages. Definitely a feature everyone wants, and potentially doable after everything is moved to tree-sitter queries…

    Almost certainly doable, and technically doesn't need to wait for everything to be moved to tree-sitter queries. But it will definitely be a big effort. Follow #409 to track the effort

    Has there been discussion of something like 'outside' or 'parent' modifier similar to 'inside' where you target the parent scope?

    I've never used jupyter so not sure, but say you were in a cell containing markdown containing a code block but the block was big enough you couldn't see any part of the parent jupyter cell but then wanted to target it, I believe atm you couldn't?

    I wonder if something like that would make this type of problem you mention slightly more natural to deal with.

    This type of modifier could help in other similar situations I suppose like if you are in a big python closure and have no hats from the containing function, but want to reference it? Similar how you can jump to a class from its method.

    That's tracked in #124

  11. saidelike commented on Jun 12, 2024

    @saidelike
    Collaborator

    same here
    image
    I would like it to select the whole code snippet starting from the three backticks starting at row 3306 up to the last three backticks ending at row 3309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang-markdown

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions