-
-
Notifications
You must be signed in to change notification settings - Fork 158
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't use // line comments in C #489
Comments
should use get and set instead require('Comment.ft').set('c', {'//%s', '//%s'}) And I don't think this make any sense? the second element is for block commenting, you can never use |
I got it working with this: vim.api.nvim_create_autocmd('Filetype', {
pattern = 'c',
callback = function()
vim.bo.commentstring = '//%s'
end,
group = comment_augroup
}) Does Comment.ft get ignored for filetypes which have a commentstring? |
Comment.nvim/lua/Comment/utils.lua Lines 173 to 185 in e30b7f2
|
ft.set works, thanks. I thought I could assign to ft.c because of the examples for javascript and yaml in README.md, where it says "Metatable magic". Are those examples wrong? If not, why does that syntax work for yaml and javascript, but not c? |
I never noticed that usage, it actually should work since it uses set too. Comment.nvim/lua/Comment/ft.lua Lines 310 to 314 in e30b7f2
But it's set only, you can't get the value with the same form. |
Hi, I'm quite new to nvim. And I have a similar issue with cpp files. They do not work. If I understand this code correctly cpp should be supported -> https://github.com/numToStr/Comment.nvim/blob/master/lua/Comment/ft.lua#L58 adding #489 (comment) kind of works but the block comments still do not work. So is this a plugin bug or did I not configure something correctly? |
@git-dimiz can you provide more details of how you do block commenting? I don't quite understand what is do not work. From what I can tell, you can test by following step:
Edit: I see, the dafault |
So, by not working I refer to the same problem that @realh mentioned but for If I execute: Deleting the keymaps causes some strange behavior where it delets the line. I've added cpp to the |
Make sure they're deleted before comment.nvim loads, in your case they seems to be removed completely as well as keymaps from comment.nvim. And I forgot to mention that you can check the source of keymap by |
Ahh! Thanks! So there I see that it is using the default vim bindings and not the ones from the plugin. Apparently I've used this plugin wrong in combination with lazy plugin manager. In the README of this project it just states:
I thought this is sufficient:
And it would use some default values. But I had to populate the opts field with values. Now it is working properly. |
Congrats :) The reason is as the readme states:
|
I want to use // for my C comments, but the plugin seems to be hardwired to use /* */ for C. This config has no effect:
The text was updated successfully, but these errors were encountered: