Coder Social home page Coder Social logo

Comments (6)

JoosepAlviste avatar JoosepAlviste commented on July 18, 2024 1

Hey!

It should not be required to have anything else configured for this plugin. Here's my configuration (very minimal):

-- ... nvim-treesitter config
  context_commentstring = {
    enable = true,
    enable_autocmd = false,
  },

-- Comment.nvim config
require('Comment').setup {
  pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(),
}

Which results in:

Screen.Recording.2022-12-27.at.18.38.09.mov

Where I'm visually selecting the lines and using gc (and gcj) to comment/uncomment.

I see that one difference we have is that in my case, the commentstring is applied on each line separately, but on yours, it's applied to the start of the first line and the ending of the second line. Maybe this has something to do with it?

Could you share your exact configuration and steps to reproduce (with specific keys pressed)?

from nvim-ts-context-commentstring.

diegoulloao avatar diegoulloao commented on July 18, 2024 1

Hey thanks for your response!
I'll do it when I have time, now trying to fix an urgent issue. I'll keep you updated on this okay?

from nvim-ts-context-commentstring.

diegoulloao avatar diegoulloao commented on July 18, 2024 1

Hey, yes, the difference is I'm using the visual mode with the block commenter:

comment.setup({
  -- toggle mappings in normal mode
  toggler = {
    -- line comment toggle keymap
    line = "<leader>c<leader>",
  },
  -- opleader mappings in visual mode
  opleader = {
    -- multiline comment toogle keymap
    block = "<leader>c<leader>",
  },
  -- nvim-ts-context-commentstring integration
  pre_hook = context_commentstring_integration.create_pre_hook(),
})

So if I'm the current line in normal mode it will work as line comment, if is visual mode, as block comment (for multiple line selecting).

Maybe that may be causing my issue?
BTW, I'm using the same keybinding for comment/uncomment (toggle) depending of the nvim mode.

from nvim-ts-context-commentstring.

JoosepAlviste avatar JoosepAlviste commented on July 18, 2024 1

Thanks for the example config! I was able to reproduce the issue with your Comment.nvim configuration.

It looks like we previously used the cursor location for calculating the commentstring, but we should have been using the visual selection start location. Not sure how this wasn't breaking with the default configuration 🤔

Anyways, I set up a PR: #54 Could you try it out and see if it fixes the issue for you as well?

from nvim-ts-context-commentstring.

diegoulloao avatar diegoulloao commented on July 18, 2024 1

Hey thank you for the quick fix! I've tested and is working for me. Also it seems isn't breaking other sort of comments 👌🏻

from nvim-ts-context-commentstring.

JoosepAlviste avatar JoosepAlviste commented on July 18, 2024 1

Sweet, thanks for the bug report and the help!

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.