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

Wrong indent for topkg file (#require) #254

Open
emillon opened this issue Aug 30, 2017 · 1 comment
Open

Wrong indent for topkg file (#require) #254

emillon opened this issue Aug 30, 2017 · 1 comment

Comments

@emillon
Copy link

emillon commented Aug 30, 2017

Hi,

It seems that ocp-indent gets confused by #-directives.

The following:

#use "topfind"
#require "topkg"
open Topkg

indents to:

#use "topfind"
     #require "topkg"
open Topkg

Similarly with a shebang line:

#!/usr/bin/env ocaml
#use "topfind"
#require "topkg"
open Topkg

becomes:

#!/usr/bin/env ocaml
               #use "topfind"
                    #require "topkg"
open Topkg

Thanks!

@AltGr
Copy link
Member

AltGr commented Nov 23, 2017

This is not very easy to solve. Well, technically, it is, but the trouble is that there is an ambiguity at the OCaml syntax level. Indeed, the above are not, properly speaking, OCaml syntax, but directives for the toplevel.

What I mean by this is that ocaml #use "topfind" is valid OCaml code outside of the toplevel (call method use with argument "topfind" from object ocaml). So how to indent really depends on your setting.

The workaround to this so far has been to add ;; separators, since you are using the toplevel. It would be nice to handle the leading shebang, though.

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

No branches or pull requests

2 participants