Problems with comments
smondet opened this issue · 8 comments
ocp-indent
says that comments starting with (*\n
would not be indented (unless strict_comments=true
), and indeed:
$ printf "(*\n\nsome comment\n\n*)\n" | ocp-indent -c 'strict_comments=false'
(*
some comment
*)
but with inside vim (even with g:ocp_indent_args
set to -c strict_comments=false
the default), the comment keeps being indented anyway:
(*
[_][_]some comment
*)
An option to say "don't do anything inside comments" would be great since ocp-indent
itself does not do the right thing sometimes …
PS:
I've tried with and without, this commit:
96de1cc
ocp-indent
doesn't behave well with unclosed comments (when indenting this file, it only receives "(*\n\nsome comment" as input). You shoud report on their page (as a fix, I can feed a few more lines to ocp-indent)
Feeding more lines will just push the problem further, right?
Right, if you make comment longer than this padding, the problem will happen again.
I am a bit worried about feeding the whole file. On big files (e.g. code from the compiler), the indent delay when editing at the end becomes quite noticeable, ok'ish but noticeable.
I would like to avoid feeding more than necessary.
I agree, as Vim users, we care about reactivity :-)
And, what about an option to just not call ocp-indent
on comments?
Yep, this might be a work-around. Still, this should be fixed upstream.
I wanted to keep this simple, this is a bit more involved.
(But I'll try to implement something along those lines)
OK, cool!
I'll see what I can do for unclosed comments after the opam release (they are very complicated to handle because ocamldoc verbatim and code blocks are properly indented).
As a side note, @def-lkb, I think you should always give at least one extra (non-empty) line to ocp-indent because the indent of a comment may depend on the next token in some cases:
let f x =
x
(* comment *)
let f x y =
x
(* comment *)
+ y