Gbury / dolmen

Dolmen provides a library and a binary to parse, typecheck, and evaluate languages used in automated deduction
BSD 2-Clause "Simplified" License
80 stars 17 forks source link

Run `realpath` on the paths of LSP prelude files #181

Closed hra687261 closed 1 year ago

hra687261 commented 1 year ago

To make all paths absolute, the server can't find them otherwise.

Gbury commented 1 year ago

That seems reasonable, however Unix.realpath only exists on ocaml >= 4.13 (as seen by the CI that fails on earlier version of the compiler). It's not clear what could be the solution.

hra687261 commented 1 year ago

Right, that's unfortunate, there doesn't seem to be any other stdlib alternative, Core offers a realpath function but I don't think we want to add a dependency just for that, or call the C realpath function, or open a process ... I think I'll just add a minimal one that replaces ~, environment variables, . and ...

bclement-ocp commented 1 year ago

Is realpath actually needed? Maybe simply prepending relative paths to the current directory would suffice:

let f = if Filename.is_relative f then Filename.concat (Sys.getcwd ()) f else f in

It doesn't handle ~ or environment variables, but then Unix.realpath doesn't either.

Gbury commented 1 year ago

@hra687261 did you try @bclement-ocp 's suggestion ?

hra687261 commented 1 year ago

Sorry, forgot about this one. The lsp server is run on the working directory, so giving it a relative path to the working directory works without appending the relative path to the absolute path of the working directory. The text of the PR is wrong, I must've tried to use a relative path to the home directory. Which was my initial goal as it would allow to keep common configs in one place instead of duplicating them over work-spaces, but it's fine, I suppose we can keep it this way for now.