-
Notifications
You must be signed in to change notification settings - Fork 40
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
Syntax: Don't highlight the LHS of type decl as types #81
base: master
Are you sure you want to change the base?
Conversation
Ping @Maelan |
Thanks @Julow! I’m fine either way. I’m just slightly concerned by adding complexity to that already complex piece, but I let our maintainers judge. You’d also have to deal with |
\ matchgroup=ocamlTypedef end="\<\(\w\|'\)*\>" | ||
\ contains=@ocamlAllErrs,ocamlComment,ocamlTypeVariance,ocamlTypeVar | ||
\ skipwhite skipempty | ||
\ nextgroup=ocamlTypeDefImpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note that with this technique, there must be no comment (* *)
between the defined type name and the equal sign =
, which may be acceptable (we already have that limitation elsewhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this. Perhaps because the end
regex don't contain \@=
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven’t actually tested your code, but from what I understand about nextgroup=
and contained
, the ocamlTypeDefImpl
group will never be tried except immediately after the end of the ocamlTypeDef
group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what skipwhite
is doing, from the :h
:
These arguments are only used in combination with "nextgroup". They can be
used to allow the next group to match after skipping some text:
skipwhite skip over space and tab characters
skipnl skip over the end of a line
skipempty skip over empty lines (implies a "skipnl")
I took thought this was doing something between start
and end
and nothing outside but it's actually the opposite, they take effect after end
and do nothing inside the region (whitespace are skipped by default it seems).
Fundamentally this change is fine, but I think we leave the current behavior configurable (personally, I prefer the current behavior). This seems to break some things, in particular (from type-linter-test.ml): type ('a, 'b) t = 'a list * ('a, 'b) result (* the left pair of parenthesis *)
type nonrec 'a o = 'a option = private None | Some of 'a (* the second equal sign *)
type t += C of int (* the of *) The module-rec-and find is interesting, would you mind adding it to type-linter-test.ml with a fixme? |
I missed type-linter-test.ml, thanks. I've added a way to get back the current behavior, what should be the default ? This is governed by I've fixed the bugs with type params and equal signs but I introduced new bugs around let-bindings, which are matched as type decl. I would like |
I would expect 'ocamlTypeConstr' to apply only to type constructors within type expressions, not to the identifier after 'type' in: type foo = 'a bar list This makes the LHS of types, exceptions and constraints be matched as 'ocamlTypedef', which is not highlighted by default. Variance and type variables on the LHS remain highlighted as before.
Have stricter rules for the identifiers and allow exception constructors to be highlighted as before.
A new region is used to avoid matching the 'and' keyword too often (that would interfere with let-and and module-rec-and.
Fix tupled type params, += and whitespaces around keywords. Add examples to the test file.
Using the commit date instead of the author date.
@copy do you want to make the call on this? |
This change and the mechanism to configure it looks good. However, it causes some problems with the highlighting of number literals (highlighted as error across the type-linter-test.ml file), the |
It's a `contained` region but was not added to `ocamlContained`.
This is a styling change.
Thanks for the review! I fixed this issue, it was a missing |
Thanks! Super-minor, but it still removes the type highlighting from the following (on the int): type t (*c*) = int |
Good catch! I'm failing to fix it. The |
This comment from @Maelan looks relevant: #81 (comment) |
Sorry for the slow reply. I managed to handle the comment at this location while keeping |
The latest commit seems to have broken the highlighting of identifiers in some places (e.g. the |
It was missing from the ocamlTypeContained group.
I think I managed to fix the identifier issue. The TOhtml diff seems fine now. The added |
On the last commit (817e8f7), some highlights are still incorrect (e.g. the |
I would expect
ocamlTypeConstr
to apply only to type constructorswithin type expressions, not to the identifier after
type
in:foo
is not highlighted with:This makes the LHS of types, exceptions and constraints be matched as
ocamlTypedef
, which is not highlighted by default.Variance and type variables on the LHS remain highlighted as before.