diff --git a/.gitignore b/.gitignore index 247af90..c7725cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,3 @@ -# -# zed-ocaml -# - +grammars/ *.wasm - -# -# Rust -# - /target diff --git a/extension.toml b/extension.toml index 6738fc5..28f8762 100644 --- a/extension.toml +++ b/extension.toml @@ -15,11 +15,19 @@ repository = "https://github.com/tree-sitter/tree-sitter-ocaml" commit = "0b12614ded3ec7ed7ab7933a9ba4f695ba4c342e" path = "grammars/ocaml" -[grammars.ocaml_interface] -repository = "https://github.com/tree-sitter/tree-sitter-ocaml" -commit = "0b12614ded3ec7ed7ab7933a9ba4f695ba4c342e" -path = "grammars/interface" +# [grammars.ocaml_interface] +# repository = "https://github.com/tree-sitter/tree-sitter-ocaml" +# commit = "0b12614ded3ec7ed7ab7933a9ba4f695ba4c342e" +# path = "grammars/interface" + +# [grammars.dune] +# repository = "https://github.com/WHForks/tree-sitter-dune" +# commit = "b3f7882e1b9a1d8811011bf6f0de1c74c9c93949" + +[grammars.menhir] +repository = "https://github.com/Kerl13/tree-sitter-menhir" +commit = "be8866a6bcc2b563ab0de895af69daeffa88fe70" -[grammars.dune] -repository = "https://github.com/WHForks/tree-sitter-dune" -commit = "b3f7882e1b9a1d8811011bf6f0de1c74c9c93949" +[grammars.ocamllex] +repository = "https://github.com/314eter/tree-sitter-ocamllex" +commit = "c5cf996c23e38a1537069fbe2d4bb83a75fc7b2f" diff --git a/languages/menhir/config.toml b/languages/menhir/config.toml new file mode 100644 index 0000000..ed2eafd --- /dev/null +++ b/languages/menhir/config.toml @@ -0,0 +1,13 @@ +name = "Menhir" +grammar = "menhir" +path_suffixes = ["mly"] +block_comment = ["(* ", " *)"] +autoclose_before = ";,=)}]" +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "<", end = ">", close = true, newline = true }, + { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] } +] +tab_size = 2 diff --git a/languages/menhir/highlights.scm b/languages/menhir/highlights.scm new file mode 100644 index 0000000..ba7b26e --- /dev/null +++ b/languages/menhir/highlights.scm @@ -0,0 +1,21 @@ +(comment) @comment +(type) @type +; (identifier) @identifier + +(uid) @constant +(lid) @variable +["=" "|"] @operator +["<" ">" "[" "]" "(" ")" "{" "}"] @punctuation.bracket +[ + "%prec" + "%left" + "%right" + "%nonassoc" + "%token" + "%attribute" + "%parameter" + "%on_error_reduce" + "%type" + "%start" +] @keyword +("%%") @punctuation.delimiter diff --git a/languages/menhir/injections.scm b/languages/menhir/injections.scm new file mode 100644 index 0000000..f209dd1 --- /dev/null +++ b/languages/menhir/injections.scm @@ -0,0 +1,2 @@ +((ocaml) @injection.content + (#set! injection.language "ocaml")) diff --git a/languages/ocamllex/config.toml b/languages/ocamllex/config.toml new file mode 100644 index 0000000..41101c0 --- /dev/null +++ b/languages/ocamllex/config.toml @@ -0,0 +1,12 @@ +name = "OCamllex" +grammar = "ocamllex" +path_suffixes = ["mll"] +block_comment = ["(* ", " *)"] +autoclose_before = ";,=)}]" +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] } +] +tab_size = 2 diff --git a/languages/ocamllex/highlights.scm b/languages/ocamllex/highlights.scm new file mode 100644 index 0000000..55725d4 --- /dev/null +++ b/languages/ocamllex/highlights.scm @@ -0,0 +1,26 @@ +; Regular expressions +;-------------------- + +(regexp_name) @variable +[(any) (eof)] @constant +[(string) (character)] @string +(escape_sequence) @escape +(character_set "^" @punctuation.special) +(character_range "-" @punctuation.delimiter) +(regexp_difference "#" @operator) +(regexp_repetition ["*" "+" "?"] @operator) +(regexp_alternative "|" @operator) + +; Rules +(lexer_entry_name) @function +(lexer_argument) @variable.parameter +(lexer_entry ["=" "|"] @punctuation.delimiter) + +; Keywords +["and" "as" "parse" "refill" "rule" "shortest"] @keyword + +; Punctuation +["[" "]" "(" ")" "{" "}"] @punctuation.bracket + +; Comments +(comment) @comment diff --git a/languages/ocamllex/injections.scm b/languages/ocamllex/injections.scm new file mode 100644 index 0000000..f209dd1 --- /dev/null +++ b/languages/ocamllex/injections.scm @@ -0,0 +1,2 @@ +((ocaml) @injection.content + (#set! injection.language "ocaml"))