You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a PPX that will transform [@myppx "name"] into Format.eprintf "%s" name
And this PPX is only active if the PROFILER environment variable is set to any value like this:
olet make_ppx_profiler ()=matchSys.getenv_opt "PROFILER"withSome""|None -> false|_ ->true(** [mapper] inherits from Ast_traverse.map because we want to take a parsetree and return a new parsetree that have been rewritten or not by this ppx *)let mapper =if make_ppx_profiler ()thenobjectinheritPpxlib.Ast_traverse.map as super
method! expression e =let detected_rewriters =(* The list of attributes is reverted to make sure that we preprocess them from left to right *)Rewriter.extract_rewriters (List.rev e.pexp_attributes)
in(* Remove the handled attributes that have been transformed in rewriters *)Expression.remove_attributes e
(* Transform the expression with the help of the list of rewriters *)|>Expression.rewrite detected_rewriters
(* Gives the hand back to Ast_travers.map to keep iterating *)|> super#expression
endelseobjectinheritPpxlib.Ast_traverse.map
endlet()=Ppxlib.Driver.register_transformation "ppx_profiler"~impl:mapper#structure
The issue now is that in my editor, if I start editing code and add improper values, no errors will be displayed and I'll only find them when compiling with PROFILER=true dune build
I found two solutions for this:
PROFILER=true dune build -w
export PROFILER=true && emacs main.ml
I wondered if there was a solution to ask the ocaml-lsp-server to compile with some environment variables.
The text was updated successfully, but these errors were encountered:
I don't think there is such an option, but starting your editor (which itself will start the lsp server) with the correct environment variable like you do in your second solution looks like a reasonable thing to do.
Yep, that's what I feared. At least my solution is easy to use (I can even set the environment variable directly in my editor and restart the lsp server)
Let's say I have a PPX that will transform
[@myppx "name"]
intoFormat.eprintf "%s" name
And this PPX is only active if the
PROFILER
environment variable is set to any value like this:The issue now is that in my editor, if I start editing code and add improper values, no errors will be displayed and I'll only find them when compiling with
PROFILER=true dune build
I found two solutions for this:
PROFILER=true dune build -w
export PROFILER=true && emacs main.ml
I wondered if there was a solution to ask the ocaml-lsp-server to compile with some environment variables.
The text was updated successfully, but these errors were encountered: