-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
[WIP] Add keyword pairs for ocaml #886
base: master
Are you sure you want to change the base?
Conversation
What does it mean that the |
Toplevel means it is at the root of a module, not in a function or a another let. (* this is toplevel *)
let v = 1
(* this is also toplevel *)
let f a b =
(* this is not toplevel *)
let c = a + b in
print_int c
(* toplevel *)
let v =
(* not toplevel *)
let a = 1 in
a + 1
module M = struct
(* this is toplevel *)
let v = 1
(* this is also toplevel *)
let f a b =
(* this is not toplevel *)
let c = a + b in
print_int c
(* toplevel *)
let v =
(* not toplevel *)
let a = 1 in
a + 1
end |
If I understand correctly, the build is not failing because of my changes, right? |
About the build, probably not. Things sometimes break as we always pull the latest versions of other packages so they might have introduced some changes. About the top-level let, I see. I think indentation is a bit dangerous if ocaml is not indentation-driven. I don't know ocaml, but say in Haskell (or even Python) this would work as the blocks there are handled by indent. If module/end is a pair we can ask for |
ocaml is indeed not indentation-driven. I can give a try to the |
One issue with current implementation is missing space during slurping. With module M1 = struct
end
module M2 = struct
end It gives this code, with a space missing between module M1 = struct
moduleend M2 = struct
end```
and when it happens I can't slurp anymore. Not sure how to fix that properly. |
Right. You can look into the ruby/elixir configurations, there are some examples, though for ruby it is a bit too complicated because of many optional features. In short what you can do is you write a function and place it either on the |
Though actually, in your example the Edit: nevermind, it's the |
I didn't have time to manage to make the keywords work properly yet. So I extracted the removal of quote and back quote to the PR #900 as they force me to disable strict mode in ocaml currently. Will try again to work on the keywords, but it shouldn't block the other PR. Note that in elixir their is the same problem of missing space than what I have. Before defmodule ModuleName do
def hello do
IO.puts "Hello World"<|>
end
end
defmodule ModuleName do
def hello do
IO.puts "Hello World"
end
end
After: defmodule ModuleName do
def hello do
IO.puts "Hello World"<|>
end
defmodule ModuleName do
def hello do
IO.puts "Hello World"
end
endend |
I read a comment saying that for ruby smartparens would outsource the parsing the ruby-mode which is based on SMIE. Has it been done? Tuareg for ocaml is also based on SMIE. So ocaml support in smartparens could use the same technique if ruby-mode parser is used. |
Nope, haven't been done yet. |
I added a rule to try to support |
Also remove the pair of back quotes as is it used for polymorphic variants.
The pair
let
in
is missing, becausein
is optional whenlet
is used at toplevel and I don't know how to express that.