-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat: jump to definition proof of concept #911
Conversation
Changes to coq look good too. |
That logic is on the loc -> pp side though, vscoq only calls the qualid -> loc part from coq and does the rest on its own. |
match get_context st o_pos with | ||
| None -> log "No context found"; None | ||
| Some _ -> | ||
match parse_entry st loc (Pcoq.Prim.smart_global) pattern with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
match parse_entry st loc (Pcoq.Prim.smart_global) pattern with | |
match parse_entry st loc Pcoq.Prim.qualid pattern with |
since you're only using the AN
case of smart_global
It may still make sense to have the api on the coq side and let vscoq call it on the loc, no? Anyway, good job! |
I do not know if it's feasible, but as a user that would be fantastic if possible. Company-coq does indeed jumps to dune source, and it has always been a major pain. |
I guess in the meantime something that works in most cases but not all is better than nothing? |
begin match Nametab.locate qid with | ||
| ConstRef x -> begin match Declare.get_loc x with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need updating as I moved get_loc and made it apply to more than constants
something like
begin match Nametab.locate qid with | |
| ConstRef x -> begin match Declare.get_loc x with | |
let extref = Nametab.locate_extended qid in | |
match Nametab.cci_src_loc extref with |
should work
Not sure how well this works with an editable document, I mean start with (* some comment *)
Definition foo := 0.
Check foo. evaluate the Definition, then edit the comment, then jump to def of the if editing the comment doesn't force re-evaluating the Definition then the loc will be wrong, but we don't want to re execute after editing comments (or whatever other edits we can detect as being trivial) |
That is certainly true, although it seems a minor problem in practice. I'm thinking loud here: if we manage to perform some pieces of the globalization phase at parse time, then parsing "Definition foo := ..." could tell us that we will generate In a way, since the map is about locs, it should be part of the parsing state, not the interp one. |
That's impossible IMO
The map is about objects like globrefs which are part of the interp state. |
AFAIK synterp already computes the current modpath. From that one can compute the final KN of "foo". Am I missing something? (I know today the kn data type is generated using the env, etc... but in principle we know all the data to compute it even without the env) |
9c40be5
to
337844c
Compare
@gares @SkySkimmer could you review before merge ? |
flake.nix
Outdated
@@ -4,7 +4,7 @@ | |||
inputs = { | |||
flake-utils.url = "github:numtide/flake-utils"; | |||
|
|||
coq-master = { url = "github:coq/coq/668dc3ca9735a2b008f5ce52c14969af59cc24e1"; }; # Should be kept in sync with PIN_COQ in CI workflow | |||
coq-master = { url = "github:rtetley/coq/d6dd8a618cbf628a6580c9a42db0cf5f44606bea"; }; # Should be kept in sync with PIN_COQ in CI workflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be necessary anymore
let o_pos = RawDocument.position_of_loc raw_doc stop in | ||
match get_context st o_pos with | ||
| None -> log "No context found"; None | ||
| Some _ -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fishy, why we check for a context and then don't use it?
was this preliminary code to use the proof context when available?
At least it deserves a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think its just a way to check that we are indeed in an executed context.
If I just jump to def with no execution state than I just get an uncaught Not_found exception. But I suppose I should probably catch the exception and return None in that case. Or check that the sentence at the cursor is executed ?
I still get errors if I try to use Jump to Def in certain cases. For example:
Was that not fixed ? |
log ("jumpToDef: found word at cursor: \"" ^ pattern ^ "\""); | ||
try | ||
let qid = parse_entry st loc (Procq.Prim.qualid) pattern in | ||
let ref = Nametab.locate_extended qid in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is where Not_found can come from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I just enclosed it in a big try [...] with
and it no longer breaks the server so that's okay
in the vscoq log do you see |
Yes you are right. I get
|
Right, we don't install _CoqProject so there's nothing to find. |
I'm not sure I understand how that pertains to the error I find ? I was under the impression that this is the error you get if you load it twice ? Unless you mean the |
Answered my own question... https://github.com/coq/coq/blob/master/theories/Init/_CoqProject |
I suppose this is a Coq/Rocq issue then ? |
Yes, but we should be sure someone is fixing it .. |
Agreed, just double checking ! |
Should I just merge in the mean time ? |
I guess so |
I'll merge and wait from news in coq/coq#15924 |
WIP
cf coq/coq#19584