Skip to content

Abort visual commenting if it makes no sense #193

Closed
@RaafatTurki

Description

@RaafatTurki

Hey there, awesome plugin BTW!
This might not be strictly Comment.nvim specific but I'd love a pointer in the right direction.

This issue is about nested filetype support so as the readme says I'm using nvim-ts-context-commentstring which integrates great with the readme pre_hook snippet

Consider the following example

1   <html>
2     <body>
3       <script>
4       let name = "raafat"
5       function print_name(name) {
6         console.log(name)
7       }
8       </script>
9     </body>
10  </html>

Visually selecting lines 1 through 5 and commenting produces an unwanted mess:

<!-- <html> -->
<!--   <body> -->
<!--     <script> -->
<!--     let name = "Raafat" -->
<!--     function print_name(name) { -->
      console.log(name)
    }
    </script>
  </body>
</html>

My aim is to calculate the commentstring at the start and end of the visual selection and only comment if they match.
I've found out that returning %s in the pre_hook results in "aborting" (is there a proper way to do this?).
Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion related to integration and other stuff

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions