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

Adding live templates for OCaml #343

Merged
merged 7 commits into from
Sep 11, 2021
Merged

Adding live templates for OCaml #343

merged 7 commits into from
Sep 11, 2021

Conversation

QuentinRa
Copy link
Contributor

@QuentinRa QuentinRa commented Sep 10, 2021

Adding live templates for OCaml

  • begin
  • class
  • doc
  • for
  • fun
  • func
  • if
  • let
  • lin
  • match
  • method
  • module sig msig
  • module struct mstruct
  • mtype
  • thread
  • try
  • type
  • while
  • |
  • ~f

As explained in #342 . I was quite easy by the way, I mean, running your project 👍 and testing.

@QuentinRa QuentinRa changed the title Patch 1 Adding live templates for OCaml Sep 10, 2021
@QuentinRa
Copy link
Contributor Author

QuentinRa commented Sep 10, 2021

What I did to test

  • create a file.ml
  • writing one of the live templates
  • create Test.re
  • testing that the Reason template is still working


@Override
public boolean isInContext(@NotNull TemplateActionContext templateActionContext) {
return templateActionContext.getFile().getName().endsWith(".ml");
Copy link
Owner

@giraud giraud Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it could also work with mli interface files

@giraud
Copy link
Owner

giraud commented Sep 11, 2021

Thanks, I really appreciate.

small remarks:

  • I prefer to not include | and ~f in the default template, they look too small, too specific
  • module struct and module sig are too complex, I prefer names like mtype, so maybe mstruct, msig
  • doc look very specfic to your needs and I'm not sure it's a good thing as a default

@QuentinRa
Copy link
Contributor Author

QuentinRa commented Sep 11, 2021

Thank you! It seems that I have rushed things a bit, sorry this is my first PR.

The operator "|" is used quite a lot (match/type/...), it would save a lot of time. I could remove it, but I don't think this is too specific. Should I remove it?

As for ~f, this was for labels, but I will remove it.

For module struct/module sig, I pondered a bit to find a suitable name (I picked module struct because they will both show up when writing module, or struct/sig). Well, I will change as you want.

For doc, I believe this is for this, but I will remove it (as I never used this).

I took the ones that I had on sublime-text. I will check everything, and make a patch 👍.

@giraud
Copy link
Owner

giraud commented Sep 11, 2021

It's just that they are default values that everybody will get, so I prefer to play safe.
That shouldn't be a problem because you can still add your own bindings in addition to these ones.

@QuentinRa
Copy link
Contributor Author

Okay, no problem. I will remove "|" too.

@QuentinRa
Copy link
Contributor Author

QuentinRa commented Sep 11, 2021

Done! I wrote a file in which I listed (and tested) every live template. Maybe, you could use if you want to add something in the documentation (or you can remove it if this is useless).

@giraud giraud merged commit bc318f3 into giraud:master Sep 11, 2021
@QuentinRa QuentinRa deleted the patch-1 branch September 14, 2021 16:53
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

Successfully merging this pull request may close these issues.

2 participants