Skip to content

Commit

Permalink
Merge pull request #527 from coq-community/completion-settings
Browse files Browse the repository at this point in the history
Add setting to enable/disable completion
  • Loading branch information
rtetley authored Aug 1, 2023
2 parents c393825 + 934e45d commit 5ec155a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
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 = [] }, []
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

0 comments on commit 5ec155a

Please sign in to comment.