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

Add setting to enable/disable completion #527

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
"title": "Code Completion",
"type": "object",
"properties": {
"vscoq.completion.enable": {
"scope": "window",
"type": "boolean",
"default": false,
"description": "Enable completion support from the VsCoq language server"
},
"vscoq.completion.unificationLimit": {
"scope": "window",
"type": "number",
Expand Down
1 change: 1 addition & 0 deletions language-server/dm/executionManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type options = {
let default_options = {
delegation_mode = CheckProofsInMaster;
completion_options = {
enable = false;
algorithm = StructuredSplitUnification;
unificationLimit = 100;
atomicFactor = 5.;
Expand Down
1 change: 1 addition & 0 deletions language-server/lsp/lspData.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ module Settings = struct
end

type t = {
enable: bool;
algorithm: RankingAlgoritm.t;
unificationLimit: int;
atomicFactor: float [@default 5.]; (** Controls how highly specific types are prioritised over generics *)
Expand Down
2 changes: 1 addition & 1 deletion language-server/tests/em_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let uri = Uri.make ~scheme:"file" ~path:"foo" ()
let init text = openDoc uri ~text

let set_delegation_mode mode =
ExecutionManager.(set_options { delegation_mode = mode; completion_options = { unificationLimit = 100; algorithm = StructuredSplitUnification; atomicFactor = 5.; sizeFactor = 5. }; enableDiagnostics = true })
ExecutionManager.(set_options { delegation_mode = mode; completion_options = { enable = false; unificationLimit = 100; algorithm = StructuredSplitUnification; atomicFactor = 5.; sizeFactor = 5. }; enableDiagnostics = true })

let%test_unit "exec: finished proof" =
let st, init_events = init "Lemma x : True. trivial. Qed. Check x." in
Expand Down
4 changes: 3 additions & 1 deletion language-server/vscoqtop/lspManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ let coqtopStepForward params =
filterText = (if label == insertText then None else Some (insertText));
}


let textDocumentCompletion ~id params =
if not (Dm.ExecutionManager.get_options ()).completion_options.enable then
Ok Request.Client.CompletionResult.{ isIncomplete = false; items = [] }, []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
let Request.Client.CompletionParams.{ textDocument = { uri }; position } = params in
let st = Hashtbl.find states (Uri.path uri) in
match Dm.DocumentManager.get_completions st position with
Expand Down
Loading