Closed ben-turner closed 1 year ago
Thanks for your report!
I've tried reproducing your issue by inserting include /etc/nginx/conf.d/*.nginx;
into one of my nginx config files, but it worked as expected. Also trying /*
at random places hat no effect on the syntax.
Can you double-check whether there are other plugins active, or a special vim configuration on your end? /* comment */
is used in C-style languages, so maybe that's a hint where to look for?
I don't immediately see any other plugins that could be causing that but I'll look some more.
I probably should have included this in the initial issue, but I can reproduce the issue like this:
:new
:set ft=nginx
i
(insert mode in new file)include /etc/nginx/conf.d/*.nginx
I can confirm that it's cindent treating the /*
as a comment because if I add # */
to the end of the "include" line, it seems to fix the problem.
Thank you for the clarification and the instructions! I could reproduce the problem. This looks indeed like a bug.
I'm currently not aware of fiddeling with /* */
somewhere, but I'll dig into it.
This is due to the setlocal cindent
statement in indent/nginx.vim
.
A fast solution would be to drop cindent
in favor of smartindent. This solves your problem, but I'd apprechiate feedback whether this actually messes other indention up:
indent/nginx.vim
setlocal smartindent " instead of setlocal cindent
cindent definitely messes with comments. It might be possible to use cinoptions c
or C
setting to fix this.
cN Indent comment lines after the comment opener, when there is no other text with which to align, N characters from the comment opener. (default 3). See also |format-comments|.
cino= cino=c5
/* /*
text. text.
*/ */
CN When N is non-zero, indent comment lines by the amount specified with the c flag above even if there is other text behind the comment opener. (default 0).
cino=c0 cino=c0,C1
/******** /********
text. text.
********/ ********/
Digging in further, it looks like the comments setting might help. Just trying to find the correct setting now.
I've actually tried this, but as far as I understood/ tested cino=cN
is a relative setting. This results in the following:
#c3 (standard)
test /*
test
# c0
test /*
test
That's also how I understood it too. I'm thinking if we can :set comments
to the right value we should be able to disable that type of comment.
set comments=b:#
and set comments=
don't make a difference here. I assume that cindent
overrides a lot of formatting-options (I think I saw something like that when skipping through the documentation).
My current guess is to try smartindent
, and if that turns out to be not enough, write a custom indentexpr
.
Curious whether you have more luck though.
Fixed by https://github.com/chr4/nginx.vim/pull/20. Can this issue be closed and the PR merged?
Thanks!
PR merged. Thanks for contributing!
First off, thank you for publishing this plugin—syntax highlighting is super nice to have.
However, I've had to turn off indenting because of how the plugin deals with
/*
. I often use patterns likeinclude /etc/nginx/conf.d/*.nginx
but it seems that cindent treats this as the start of a multi-line comment and ruins the formatting for the entire file.Not being much of a vim wizard, I can't find a solution to fix it myself and create a PR so I'm hoping someone else can fix it.