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

[workspace] use rootPath to detect _CoqProject file. #261

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
resumption, still cached sentences will display the cached timing
tho (@ejgallego, #257)
- Set Coq library name correctly (@ejgallego, #260)
- `_CoqProject` file is now detected using LSP client `rootPath`
(@ejgallego, #261)

# coq-lsp 0.1.3: Event
----------------------
Expand Down
3 changes: 2 additions & 1 deletion controller/coq_lsp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ let rec lsp_init_loop ic ofmt ~cmdline ~debug : Coq.Workspace.t =
LIO.logMessage ~lvl:3 ~message:"Server initialized";
(* Workspace initialization *)
let debug = debug || !Fleche.Config.v.debug in
let workspace = Coq.Workspace.guess ~cmdline ~debug in
let dir = string_field "rootPath" params in
let workspace = Coq.Workspace.guess ~cmdline ~debug ~dir in
log_workspace workspace;
workspace
| LSP.Message.Request { id; _ } ->
Expand Down
11 changes: 6 additions & 5 deletions coq/workspace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ let apply ~uri
Declaremods.start_library (dirpath_of_uri ~uri);
load_objs require_libs

let workspace_from_coqproject ~coqlib ~debug : t =
let workspace_from_coqproject ~coqlib ~debug cp_file : t =
(* Io.Log.error "init" "Parsing _CoqProject"; *)
let open CoqProject_file in
let to_vo_loadpath f implicit =
Expand All @@ -173,7 +173,7 @@ let workspace_from_coqproject ~coqlib ~debug : t =
}
in
let { r_includes; q_includes; ml_includes; extra_args; _ } =
read_project_file ~warning_fn:(fun _ -> ()) "_CoqProject"
read_project_file ~warning_fn:(fun _ -> ()) cp_file
in
let ml_include_path = List.map (fun f -> f.thing.path) ml_includes in
let vo_path = List.map (fun f -> to_vo_loadpath f.thing false) q_includes in
Expand Down Expand Up @@ -206,7 +206,8 @@ let workspace_from_cmdline ~debug
let w = default ~implicit ~coqlib ~kind ~debug in
add_loadpaths w ~vo_load_path ~ml_include_path

let guess ~debug ~cmdline =
if Sys.file_exists "_CoqProject" then
workspace_from_coqproject ~coqlib:cmdline.CmdLine.coqlib ~debug
let guess ~debug ~cmdline ~dir =
let cp_file = Filename.concat dir "_CoqProject" in
if Sys.file_exists cp_file then
workspace_from_coqproject ~coqlib:cmdline.CmdLine.coqlib ~debug cp_file
else workspace_from_cmdline ~debug cmdline
2 changes: 1 addition & 1 deletion coq/workspace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module CmdLine : sig
}
end

val guess : debug:bool -> cmdline:CmdLine.t -> t
val guess : debug:bool -> cmdline:CmdLine.t -> dir:string -> t

(** [apply libname w] will prepare Coq for a new file [libname] on workspace [w] *)
val apply : uri:string -> t -> unit