Skip to content

Commit 49f0ef9

Browse files
Anthony Leonardo GracioAnthonyLeonardoGracio
authored andcommitted
V609-058: Add useCompletionSnippets flag
And an associated VS Code preference, disabled by default.
1 parent b93bd59 commit 49f0ef9

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

doc/settings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ The value is a boolean.
103103
'renameInComments': false
104104
```
105105

106+
## useCompletionSnippets
107+
Whether we should use snippets in completion results. Snippets can be
108+
returned in case of subprogram calls for instance, with placeholders
109+
for each parameter needed by the subprogram.
110+
The value is a boolean.
111+
112+
```javascript
113+
'useCompletionSnippets': true
114+
```
115+
106116
## displayMethodAncestryOnNavigation
107117
This setting controls the policy for displaying overriding and overridden
108118
subprograms on navigation requests such as `textDocument/definition`,

integration/vscode/ada/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@
333333
"default": true,
334334
"description": "The emission of diagnostics."
335335
},
336+
"ada.useCompletionSnippets": {
337+
"scope": "resource",
338+
"type": "boolean",
339+
"default": false,
340+
"description": "Enable snippets in completion results (e.g: subprogram calls)."
341+
},
336342
"ada.renameInComments": {
337343
"scope": "resource",
338344
"type": "boolean",
@@ -455,4 +461,4 @@
455461
"vscode-languageclient": "7.0.0",
456462
"ws": "8.5.0"
457463
}
458-
}
464+
}

source/ada/lsp-ada_handlers.adb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4057,6 +4057,8 @@ package body LSP.Ada_Handlers is
40574057
"followSymlinks";
40584058
documentationStyle : constant String :=
40594059
"documentationStyle";
4060+
useCompletionSnippets : constant String :=
4061+
"useCompletionSnippets";
40604062

40614063
Ada : constant LSP.Types.LSP_Any := Value.settings.Get ("ada");
40624064
File : VSS.Strings.Virtual_String;
@@ -4135,6 +4137,14 @@ package body LSP.Ada_Handlers is
41354137
Self.Named_Notation_Threshold := Ada.Get (namedNotationThreshold);
41364138
end if;
41374139

4140+
-- Check the 'useCompletionSnippets' flag to see if we should use
4141+
-- snippets in completion (if the client supports it).
4142+
if Ada.Has_Field (useCompletionSnippets) then
4143+
Self.Use_Completion_Snippets :=
4144+
Self.Completion_Snippets_Enabled
4145+
and then Ada.Get (useCompletionSnippets);
4146+
end if;
4147+
41384148
-- Retrieve the policy for displaying type hierarchy on navigation
41394149
-- requests.
41404150
if Ada.Has_Field (displayMethodAncestryOnNavigation) then
@@ -5257,7 +5267,7 @@ package body LSP.Ada_Handlers is
52575267
LSP.Ada_Completions.Attributes.Attributes_Completion_Provider;
52585268

52595269
P6 : aliased LSP.Ada_Completions.Names.Name_Completion_Provider
5260-
(Self.Completion_Snippets_Enabled);
5270+
(Self.Use_Completion_Snippets);
52615271
P7 : aliased LSP.Ada_Handlers.Invisibles.Invisible_Completion_Provider
52625272
(Self, Context);
52635273
P8 : aliased

source/ada/lsp-ada_handlers.ads

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ private
268268
Completion_Snippets_Enabled : Boolean := False;
269269
-- True if the client supports completion snippets
270270

271+
Use_Completion_Snippets : Boolean := True;
272+
-- True if we should use snippets for completion (e.g:
273+
-- subprogram calls).
274+
271275
Completion_Resolve_Properties : VSS.String_Vectors.Virtual_String_Vector;
272276
-- The list of CompletionItem properties that can be resolved
273277
-- lazily (i.e: when the item is selected on client-side) via

0 commit comments

Comments
 (0)