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

Can I set newlines in commentstrings? #53

Closed
reyniersbram opened this issue Dec 30, 2022 · 1 comment
Closed

Can I set newlines in commentstrings? #53

reyniersbram opened this issue Dec 30, 2022 · 1 comment

Comments

@reyniersbram
Copy link

I want my block comments for lua to be like this:

--[[
some commented-out text or code
--]]

So I thought it would be easy to just do something like this:

require("nvim-treesitter.config").setup{
    ...
    context_commentstring = {
	...
        config = {
            lua = {
                __default = "-- %s",
                __multiline = "--[[\n%s\n]]"
            },
        },
    },
}

but when commenting a block of code with Comment.nvim the newlines are replaced by spaces.

Am I doing something wrong, or is it just not possible to have newlines in a commentstring.

This is a link to the specific code in my dotfiles repo.

@JoosepAlviste
Copy link
Owner

Hey!

I tried this out myself too and couldn't get it to work with the Lua multiline strings either:

require('Comment').setup {
  pre_hook = function()
    return [=[--[[
%s
]]]=]
  end,
}

I think that this plugin can't do much about this though since the commenting plugin needs to handle the commentstring with new lines.

I found this issue in Comment.nvim that might be similar to your use case: numToStr/Comment.nvim#38 Maybe this helps?

But you could open an issue/feature request in the Comment.nvim repo since I don't think we could do anything about this in this plugin.

Let me know how it goes!

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

No branches or pull requests

2 participants