diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 92d70f8de..7327180e7 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -376,6 +376,9 @@ + + + diff --git a/resources/liveTemplates/OCaml-doc.md b/resources/liveTemplates/OCaml-doc.md new file mode 100644 index 000000000..cd9241dee --- /dev/null +++ b/resources/liveTemplates/OCaml-doc.md @@ -0,0 +1,129 @@ +# Documentation of OCaml Live templates + +**Scope**: `*.ml` and `*.mli`. + +- `begin` + +```ocaml +begin + +end +``` + +- `class` + +```ocaml +class name = + object (self) + contents + end +``` + +- `for` + +```ocaml +for i = starval to endval do + code +done +``` + +- `fun` + +```ocaml +(fun () -> body) +``` + +- `func` + +```ocaml +(function +| patt1 -> expr1 +| patt2 -> expr2) +``` + +- `if` + +```ocaml +if (cond) then expr else expr2 +``` + +- `let` + +```ocaml +let var(s) = expr +``` + +- `lin` + +```ocaml +let var(s) = expr in expr2 +``` + +- `match` + +```ocaml +match value with +| patt -> expr +| _ -> expr2 +``` + +- `method` + +```ocaml +method name = +``` + +- `msig` + +```ocaml +module Name : sig + +end +``` + +- `mstruct` + +```ocaml +module Name = struct + +end +``` + +- `mtype` + +```ocaml +module type Name = sig + +end +``` + +- `thread` + +```ocaml +ignore (Thread.create (fun () -> + + ) ()) +``` + +- `try` + +```ocaml +try + +with + | _ -> failwith "Unknown" +``` + +- `type` + +```ocaml +type name = expr +``` + +- `while` + +```ocaml +while condition do + +done +``` diff --git a/resources/liveTemplates/OCaml.xml b/resources/liveTemplates/OCaml.xml new file mode 100644 index 000000000..7721d58df --- /dev/null +++ b/resources/liveTemplates/OCaml.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/reason/ide/template/OCamlContentType.java b/src/com/reason/ide/template/OCamlContentType.java new file mode 100644 index 000000000..2c5656b0c --- /dev/null +++ b/src/com/reason/ide/template/OCamlContentType.java @@ -0,0 +1,21 @@ +package com.reason.ide.template; + +import com.intellij.codeInsight.template.TemplateActionContext; +import com.intellij.codeInsight.template.TemplateContextType; +import org.jetbrains.annotations.NotNull; + +/** + * Every "*.ml" kind of file is considered to be a part of the OCaml context + */ +public class OCamlContentType extends TemplateContextType { + + protected OCamlContentType() { + super("OCAML", "Ocaml"); + } + + @Override + public boolean isInContext(@NotNull TemplateActionContext templateActionContext) { + final String name = templateActionContext.getFile().getName(); + return name.endsWith(".ml") || name.endsWith(".mli"); + } +} diff --git a/website/docs/contributing/plugin-development.md b/website/docs/contributing/plugin-development.md index 8a93c55bc..d0677d81d 100644 --- a/website/docs/contributing/plugin-development.md +++ b/website/docs/contributing/plugin-development.md @@ -12,7 +12,7 @@ Follow the steps below to get the plugin running locally for development. ### Prepare your Environment 1. Install the [plugin prerequisites](http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/prerequisites.html), ensuring that the Plugin DevKit plugin is enabled and [PsiViewer](https://plugins.jetbrains.com/plugin/227-psiviewer) is installed and enabled. -2. Clone the project `git clone https://github.com/JetBrains/intellij-community.git` +2. Clone the project `git clone https://github.com/giraud/reasonml-idea-plugin.git` 3. Import the project into Intellij as a Gradle project. This should auto-configure everything else needed to run the plugin. 4. If prompted, download the Intellij SDK source files. This is useful for debugging the Intellij platform code.