-
Notifications
You must be signed in to change notification settings - Fork 16
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
[WIP] 🐕🦺 Cooltt Server v2.0 #289
Open
TOTBWF
wants to merge
39
commits into
main
Choose a base branch
from
cooltt-server-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,116
−53
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
1bab8ff
Add socket communication code for a cooltt display server
TOTBWF 856f19b
Add syntax for "Probe Holes"
TOTBWF bc5b903
Use a 'ref' to hold the cooltt server handle
TOTBWF 331d422
Add 'probe_goal' family of tactics
TOTBWF 2eb241f
Add server communication inside elaborator
TOTBWF bba9713
Server initialization + command line args
TOTBWF e42d970
Fix issue with emacs mode + extra args
TOTBWF 115b838
Update protocol to perform more heavy lifting on the cooltt side
TOTBWF f2b3c71
Update zsh completion
favonia d79782d
Merge remote-tracking branch 'origin/main' into cooltt-server
TOTBWF 5a8aeb1
Replace ProbeHole with Visualize
TOTBWF c30a940
Update syntax highlighting
TOTBWF 10e4fff
Add ability to pass in server hostname, rework options handling a bit
TOTBWF a568129
Update message format to track changes to coolttviz
TOTBWF 36717bd
Fix Test Suite
TOTBWF 3d8480a
Remove old server code
TOTBWF 2777db2
Add a message queue for emitting metadata from the refiner
TOTBWF 2beea3a
Thread through a null job queue into the refiner
TOTBWF b03d146
Start implementing LSP server
TOTBWF af99c13
Fix some issues with the core lsp impl
TOTBWF 3435bfa
Add 'Executor.ml' for running server actions
TOTBWF 0b24b1c
Add emacs config for lsp integration
TOTBWF 10e5aaf
Pull 'elaborate_typed_term' into the elaborator
TOTBWF c5f6839
Remove job queue in favor of metadata list
TOTBWF 1306aac
Update main.ml with server command
TOTBWF a72fd57
Add type hovers
TOTBWF f018ff6
Tweak printing for subtypes with trivial cofibrations
TOTBWF f2b74ff
[WIP] Start working on holes/commands
TOTBWF 26c8989
Add segment trees
favonia ea21988
Remove stupid parentheses
favonia a9e2309
Refactor and clean up code
favonia 425b0f0
Add a README
favonia 6ad5196
Add visualize code action
TOTBWF 75cb430
Wire up code actions
TOTBWF 45042be
Fix minor bug in SegmentTree
TOTBWF 16ddd81
Add some extra stuff to the segment tree API
TOTBWF 75e8550
Add pp_range
TOTBWF 34fcefa
Rework how metadata is stored
TOTBWF 0b0db06
Remove IntervalTree
TOTBWF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;;; cooltt-lsp --- -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
(require 'cooltt) | ||
(require 'lsp-mode) | ||
|
||
(lsp-register-client | ||
(make-lsp-client | ||
:new-connection (lsp-stdio-connection (list cooltt-command "--mode" "server")) | ||
:major-modes '(cooltt-mode) | ||
:server-id 'cooltt)) | ||
|
||
(lsp-consistency-check cooltt-lsp) | ||
(add-to-list 'lsp-language-id-configuration '(cooltt-mode . "cooltt")) | ||
|
||
;;; Code: | ||
|
||
(provide 'cooltt-lsp) | ||
;;; cooltt-lsp.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module type POSITION = | ||
sig | ||
include Map.OrderedType | ||
type range = { start : t; stop: t } | ||
val cut_range_after : t -> range -> range | ||
val cut_range_before : t -> range -> range | ||
end | ||
|
||
module type S = functor (Pos: POSITION) -> | ||
sig | ||
type !+'a t | ||
val lookup : Pos.t -> 'a t -> 'a option | ||
val containing : Pos.t -> 'a t -> 'a list | ||
val of_list : (Pos.range * 'a) list -> 'a t | ||
val empty : 'a t | ||
|
||
val pp : (Format.formatter -> Pos.range -> unit) -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit | ||
end | ||
|
||
module Make : S = functor (Pos : POSITION) -> | ||
struct | ||
|
||
module Range = struct | ||
type t = Pos.range | ||
let compare (x : t) (y : t) = | ||
CCOrd.(Pos.compare x.start y.start <?> (opp Pos.compare, x.stop, y.stop)) | ||
end | ||
|
||
module SegTree = CCMap.Make(Range) | ||
|
||
type !+'a t = 'a SegTree.t | ||
|
||
let lookup pos t = | ||
match SegTree.find_last_opt (fun k -> Range.compare k {start = pos; stop = pos} <= 0) t with | ||
| None -> None | ||
| Some (r, v) -> | ||
if Pos.compare r.stop pos >= 0 then Some v else None | ||
|
||
let containing pos t = | ||
(* FIXME: This is suboptimal *) | ||
CCList.of_iter @@ SegTree.values @@ SegTree.filter (fun range _ -> range.start <= pos && pos <= range.stop) t | ||
|
||
let of_sorted_list l = | ||
let rec loop tree stack l = | ||
match stack, l with | ||
| _, [] -> SegTree.add_list tree stack | ||
| [], x :: l -> loop tree [x] l | ||
| ((xk, xv) as x) :: stack, ((yk, _) as y :: l) -> | ||
if Pos.compare yk.stop xk.start < 0 then | ||
loop tree (y :: x :: stack) l | ||
else if Pos.compare xk.stop yk.start < 0 then | ||
loop (SegTree.add xk xv tree) stack (y :: l) | ||
else | ||
let tree = | ||
if Pos.compare xk.start yk.start < 0 then | ||
SegTree.add (Pos.cut_range_after yk.start xk) xv tree | ||
else | ||
tree | ||
in | ||
if Pos.compare xk.stop yk.stop > 0 then | ||
loop tree (y :: (Pos.cut_range_before yk.stop xk, xv) :: stack) l | ||
else | ||
loop tree stack (y :: l) | ||
in | ||
loop SegTree.empty [] l | ||
|
||
let of_list l = | ||
of_sorted_list (CCList.sort (CCOrd.(>|=) Range.compare fst) l) | ||
|
||
let empty = SegTree.empty | ||
|
||
let pp pp_range pp_elem : Format.formatter -> 'a t -> unit = SegTree.pp pp_range pp_elem | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module type POSITION = | ||
sig | ||
include Map.OrderedType | ||
type range = { start : t; stop: t } | ||
val cut_range_after : t -> range -> range | ||
val cut_range_before : t -> range -> range | ||
end | ||
|
||
module type S = functor (Pos: POSITION) -> | ||
sig | ||
type !+'a t | ||
val lookup : Pos.t -> 'a t -> 'a option | ||
val containing : Pos.t -> 'a t -> 'a list | ||
val of_list : (Pos.range * 'a) list -> 'a t | ||
val empty : 'a t | ||
|
||
val pp : (Format.formatter -> Pos.range -> unit) -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit | ||
end | ||
|
||
module Make : S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 might not be correct, because the "same" span can show up as multiple segments, and "shadowed" spans will not even be in the tree.
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 would suggest eventually removing
containing
completely---or we have to rethink the entire framework.