GithubHelp home page GithubHelp logo

Comments (2)

DennisTheMenace780 avatar DennisTheMenace780 commented on May 19, 2024

Alright so this sucked to figure out, but I figured it out for anyone who comes across this.

Tl;DR the reason I could not get this plugin to work was because my cursor was not on an appropriate Tree Sitter node.

It felt like the plugin was just not hitting the appropriate nodes no matter what I tried, so I installed NvimTreesitter Playground to actually see what was happening behind the scenes. My problem was that I had my cursor at the start of whitespace but on the same line a JSX Element would be, and I thought that would allow me to just comment out what I wanted.

What needed to happen is that the cursor must be placed, literally, on the JSX tag or element for the commenting to work. Once I discovered that, everything worked beautifully.

from nvim-ts-context-commentstring.

JoosepAlviste avatar JoosepAlviste commented on May 19, 2024

Hey @DennisTheMenace780! This issue seems a bit odd since this plugin should definitely handle the case where your cursor is not exactly on the JSX node. For example, in this case:

(
  <div>
    <h1>Hello</h1>
^ -- cursor
  </div>
)

The comment character should be calculated based on the first non-whitespace character in the line:

(
  <div>
    <h1>Hello</h1>
    ^ -- this position is used to calculate the commentstring
  </div>
)

This should result in the {/* %s */} commentstring.

Could you maybe give a specific example of an unexpected use case?

from nvim-ts-context-commentstring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.