Does it make sense to add a field with just the string representation of the hypotheses and goals to the Goal
Object returned by the proof/goals request? If I'm looking at it right, the information returned isn't very human readable, and I'm working on something where just the literal string representation of the goal would be useful. Thanks!
It is not meant to be human readable
You can try to use Printer.Debug.pr_goal on it I guess
@Bhakti Shah yes, I think it would make sense, actually if you look at the current type definition , https://github.com/ejgallego/coq-lsp/blob/936f73a992be2a10445304f35beec572963f9923/editor/code/lib/types.ts#L18
it is already parameterized by the return type Pp
.
So we can extend that to be like in SerAPI, and include a format type for users.
As of today note we can return either strings or that type you see now CoqPp
, which is actually not so complex.
Let me review your PR and I can provide more feedback.
Yeah so I experimented a bit and when I set pp_type
to 0 in package.json
(so just the string), i get the information exactly as I want it. obviously i dont want to make such a big change given that the jscoq formatting is so much nicer, but I don't see a way of sending a request to the server with a specific type I want my output in -- if I could send a standalone request that returned the object in the string representation that would be perfect, but as far as i can tell the requests arent parameterized by this and pp_type
is just declared in package.json
and globally constant. Is this actually true? I might just be missing something here.
I see two solutions to my issue -- if there is in fact a way to make a request with a specific output type, that would be pretty simple for me to add. if there isn't, and making this actually variable seems like a big task, I can also just see a field being added to the jscoq object type that just has the string representation.
I'm more than happy to work with either of these solutions, and happy to make a PR for the same, but I would just want to know if you have a preference regarding the same. Particularly if making the pp_type
variable in a single instance is something you plan on doing anyway in the future, it would be great to know. Thank you!
Hi @Bhakti Shah , sorry I'm not very responsive, pretty busy this week.
I think the best way would be to add the type of object your extension needs to a registration API, so indeed, you would register a callback requiring the goals to have a string carrier, and coq-lsp will provide you a goals object with the right type.
Adding an extra field scales poorly as in general we have N output formats.
So what I propose is:
proof/goals
request type as to include the desired output type (like done in SerAPI)registerGoalProccesor
API that would take the method with the right goals typeHow does that plan sound to you?
I think indeed that for your use case, string will become quickly too weak, and indeed you may want a higher-level representation of what's on the goal, like the one provided by the layout-printer, so going this way would allow you to experiment better with alternatives
First item done in https://github.com/ejgallego/coq-lsp/pull/470
That's great, thank you! Yes, adding the API sounds good -- I think that was the best possible result but it seemed like a much bigger change. I can work on making a PR for that if you aren't working on it already. Let me know if there are other things you would want to add to the API too, although I suspect it'll either be bare bones suited to user needs or a full fledged API depending on what you want.
For now I'll use the parameter for the proof/goals request and possibly make an updated PR once I've tested that it is what I want.
Great! I suggest you do whatever you need to make things working smoothly for you
For now we can just make the request twice, it will be cached server-side
and we dispatch the right result type to the right place
I think it'd be great if you make a PR so that you can register your plugin for the action that you need
At some point if you have a test suite let me know so I can test your plugin in the CI to ensure that it is not broken
Hm okay so I'm playing around with it and it seems I should just be sending a request with the pp_format
specified -- and this is what I'm using:
let strCursor: GoalRequest = {textDocument, position, pp_format: "Str"};
and I'm basically using the same pipeline as the requestDisplay but you can see the code here if you'd like
I'm still getting the same goals object in response, not the one I was seeing when I set the pp_format parameter globally. I'm guessing this isn't the desired behavior?
Indeed it seems like a bug
Let me re-test (I should have added a test to my PR)
Works fine here @Bhakti Shah , maybe check you did recompile the binary ?
I did recompile, but i wonder if having lsp installed globally is an issue? like maybe it's using the globally installed version
Yeah, I'm not sure how to make it look at the new binary and not the globally installed one? I did the dune exec and everything but it always seems to use the global install.
I believe dune exec is not actually updating my env variables as when there is no global install, the server does not run. I'll manually make the changes and see if that works
When you do dune exec
the env vars will only be available to whatever you are running
Are you running an editor or something?
For example, for vscode I do dune exec -- code .
.
That gives the correct PATH with coq-lsp in it
yeah i just ran dune exec --code editor/code
Try dune exec --root=editor/code -- code .
isntead
or nevermind that won't work
If you do dune exec -- echo $PATH
you should see _build/install appear
hm yeah it does
And make sure you have actually built coq-lsp with dune build @install
.
Since dune exec
is not running anything that Dune knows the deps of it won't force a build of coq-lsp
yeah I have
the coq file i'm testing is not in the editor/code
directory (so the one i open when i launch the extension) -- could that be an issue? when i echo $PATH
in the extension development host window it doesn't show me _build/install
yes thats probably the issue
I usually symlink editor/code to my extesnions folder
that way when I start vscode in dune exec -- code .
at the root of the repo, vscode finds the extension through the symlink
There is a detailed guide how to do this in https://github.com/ejgallego/coq-lsp/blob/main/CONTRIBUTING.md
If you don't need the latest extension (typically you dont) then just install the extension from the vscode store
look up coq-lsp you will find it
Then when you dune exec -- code .
it will have the correct coq-lsp in path
So I've been following exactly what's in the contributing guide
and i do think I need the latest extension because i need the changes just pushed to the server to test my client side code
let me try symlinking
though i don't think the extension is the problem - it's the server that the extension cannot find
yeah symlinking didn't do anything
The issue with vscode is that when you start a debug session or whatever it is called, it doesn't inherit the env
That would be my guess to what is going on
yeah that is what i am thinking because the path isnt updating in the development server -- but i'm wondering how anyone is able to test server side code within the extension then
I just run dune exec -- code editor/code
like you said
ah you did symlink
but did you "build" the extension
do make extension
Then when you run do dune exec -- code .
you should have the latest extension and coq-lsp (if you built it)
yeah i tried it manually but no luck; and also the vscode debug session automatically builds it too
when i launch it it seems to be running the right version:
coq-lsp@0.1.7 watch
npm run esbuild -- --watch
coq-lsp@0.1.7 esbuild
node esbuild.mjs "--watch"
because if im not wrong 0.1.7 is not released yet and has to be the version I have locally
Yes, 0.1.7 is not released yet
That's bizarre, looking forward to a better setup, especially that now we gotta test 2 extensions
What I always do on Linux, and so far with success is
dune exec -- code editor/code
this sets the path rightmake
the serverSetting path directly in options can be of help too
Yeah so I tried manually adding all the env variables that i think were modified by dune exec, dont know if this is something that's listed more clearly somewhere but i don't think it worked :( will try possibly running on linux instead of mac?
Linux or mac shouldn't matter, most reliable is just add the path to coq-lsp in the config section.
Are you sure the problem is not elsewhere? It seems to me you may be running the good binary, what commit are you, what is your concrete test that fails?
Here, using this diff I can observe the difference on main
:
diff --git a/editor/code/src/goals.ts b/editor/code/src/goals.ts
index 1866e33..08e396e 100644
--- a/editor/code/src/goals.ts
+++ b/editor/code/src/goals.ts
@@ -99,6 +99,7 @@ export class InfoPanel {
// LSP Protocol extension for Goals
sendGoalsRequest(client: BaseLanguageClient, params: GoalRequest) {
+ params.pp_format = "Str";
this.requestSent(params);
client.sendRequest(infoReq, params).then(
(goals) => this.requestDisplay(goals),
So basically I've deleted my opam installed lsp binary as well as the extension. when i launch it using the development host, it just gives me the standard could not connect to server error:
[Error - 6:29:09 PM] Coq LSP Server client: couldn't create connection to server.
Launching server using command coq-lsp failed. Error: spawn coq-lsp ENOENT
it's not an issue in the code, i just think my computer won't recognize the non opam lsp binary even after i set all the environment variables manually? which doesn't really make sense
What does _build/install/default/bin
contain?
Also there is a thing about code
If you do dune exec -- code editor/code
You need code
to be not open already I think
otherwise it will reuse the existing session elsewhere
and I think indeed PATH won't be altered
very likely this is your issue
You can check running echo PATH
from the VS Code terminal
Beware the vscode terminal might not show the vscode PATH: That starts a new shell, which will likely load ~/.bashrc or the like (but not ~/.profile or the like; shell init is complex)
I see -- yeah, I was opening it while vscode was open, and you were right -- it works fine now ! i was checking the env from the vscode terminal and the information wasn't populated there so yeah that makes sense
thank you so much for the help!
I think code -n
forces the opening of a new session. I forgot about htis because I configured code to always do this unless a project is already open.
Last updated: Apr 20 2024 at 06:02 UTC