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

Custom server request registration #532

Merged
merged 5 commits into from
Jun 15, 2021
Merged

Conversation

Vtec234
Copy link
Member

@Vtec234 Vtec234 commented Jun 15, 2021

This allows registering custom LSP request handlers in the server via builtin_initialize or initialize in plugins. We maintain a global IO.Ref table of handlers.

For now registering request handlers as-you-go in standard Lean files (via the environment) is unsupported as the semantics of that are quite unclear. In particular, the watchdog needs to know which worker to route requests to, but the Environment object is only accessible within one given worker. We could require all custom requests to contain a uri : DocumentUri field. In any case I'm leaving this feature for later if it's desired.

Other possible features which might be useful in the future:

  • custom notification handlers which run after the standard ones so that plugins can e.g. directly observe changes to the document state
  • custom no-response handlers for requests with responding handlers already registered, for the same reason (observing the system state)

src/Lean/Server/FileWorker/Utils.lean Outdated Show resolved Hide resolved
src/Lean/Server/Requests.lean Outdated Show resolved Hide resolved
@Kha Kha merged commit 7485ab5 into leanprover:master Jun 15, 2021
@Kha
Copy link
Member

Kha commented Jun 15, 2021

Good work!

@Vtec234 Vtec234 deleted the custom-reqs branch July 17, 2022 20:05
ChrisHughes24 pushed a commit to ChrisHughes24/lean4 that referenced this pull request Dec 2, 2022
I started porting logic/lemmas.lean, but found that I needed cc_lemmas.lean first.

Compare to
 * the Lean 3 version: https://github.com/leanprover-community/lean/blob/fc13c8c72a15dab71a2c2b31410c2cadc3526bd7/library/init/cc_lemmas.lean
 * the lean3port version: https://github.com/leanprover-community/lean/blob/fc13c8c72a15dab71a2c2b31410c2cadc3526bd7/library/init/cc_lemmas.lean

The main adjustments I needed to make were of the form `(true_iff_iff _)` -> `true_iff_iff`, because the mathlib4 version of [`true_iff_iff`](https://github.com/leanprover-community/mathlib4/blob/172bedc47e099f17a6dad47ed2bb4789c5ad1618/Mathlib/Init/Logic.lean#L192) (and similar lemmas) takes its argument implicitly, which the mathlib3 version takes it explicitly.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
ChrisHughes24 pushed a commit to ChrisHughes24/lean4 that referenced this pull request Dec 2, 2022
For some funny reason there were aliases to lemmas from `init.cc_lemmas`, which is PR'd to mathlib4 as leanprover#532.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants