aboutsummaryrefslogtreecommitdiffstats
path: root/queries/ocaml
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2023-05-01 20:42:21 +0900
committerGitHub <noreply@github.com>2023-05-01 20:42:21 +0900
commitb4d2640eab4b1f6373e1ded84ab9f6db0c02c756 (patch)
tree65db194311dc1cf7a89ba61c73aba8eefcfad886 /queries/ocaml
parentUpdate parsers: janet_simple, swift, vimdoc (diff)
downloadnvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar.gz
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar.bz2
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar.lz
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar.xz
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.tar.zst
nvim-treesitter-b4d2640eab4b1f6373e1ded84ab9f6db0c02c756.zip
feat: add indents for ocaml and ocaml interface (#4725)
Diffstat (limited to 'queries/ocaml')
-rw-r--r--queries/ocaml/indents.scm69
1 files changed, 69 insertions, 0 deletions
diff --git a/queries/ocaml/indents.scm b/queries/ocaml/indents.scm
new file mode 100644
index 000000000..48049dd0d
--- /dev/null
+++ b/queries/ocaml/indents.scm
@@ -0,0 +1,69 @@
+[
+ (let_binding) ; let = ...
+ (type_binding)
+
+ (external)
+ (record_declaration) ; { foo: bar ... }
+ (structure) ; struct ... end
+ (signature) ; sig ... end
+ (value_specification) ; val x: bar
+
+ (do_clause) ; do ... done
+ (match_case)
+
+ (field_expression)
+ (application_expression)
+ (parenthesized_expression) ; ( ... )
+ (record_expression) ; { foo = bar ... }
+ (list_expression) ; [...;...]
+ (try_expression) ; try ... with
+] @indent.begin
+
+; handle if-else if-else case
+(if_expression
+ condition: (_) @indent.begin)
+(then_clause) @indent.begin
+((else_clause
+ (_) @_not_if) @indent.begin
+ (#not-has-type? @_not_if if_expression))
+
+((parameter) @indent.begin
+ (#set! indent.start_at_same_line))
+
+(_ (ERROR) @indent.begin
+ (#set! indent.start_at_same_line))
+
+(ERROR "|" @indent.begin
+ (#set! indent.start_at_same_line))
+
+
+(try_expression
+ "with" @indent.branch
+ [
+ (match_case) @indent.dedent
+ (match_case
+ [
+ (parenthesized_expression)
+ (list_expression)
+ ] @indent.dedent)
+ ]
+)
+
+[
+ "}"
+] @indent.branch @indent.end
+
+
+(list_expression "]" @indent.branch)
+(parenthesized_expression ")" @indent.branch)
+
+";;" @indent.end
+
+(do_clause "done" @indent.end @indent.branch)
+(structure "end" @indent.end @indent.branch)
+(signature "end" @indent.end @indent.branch)
+
+[
+ (string)
+ (comment)
+] @indent.auto