Skip to content

Commit 4f1fb5e

Browse files
iluuu1994felixfbecker
authored andcommitted
feat: add insertTextFormat property to CompletionItem (#11)
1 parent 00b54d0 commit 4f1fb5e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/CompletionItem.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ class CompletionItem
9696
*/
9797
public $data;
9898

99+
/**
100+
* The format of the insert text. The format applies to both the `insertText` property
101+
* and the `newText` property of a provided `textEdit`.
102+
*
103+
* @var int|null
104+
* @see InsertTextFormat
105+
*/
106+
public $insertTextFormat;
107+
99108
/**
100109
* @param string $label
101110
* @param int|null $kind
@@ -108,6 +117,7 @@ class CompletionItem
108117
* @param TextEdit[]|null $additionalTextEdits
109118
* @param Command|null $command
110119
* @param mixed|null $data
120+
* @param int|null $insertTextFormat
111121
*/
112122
public function __construct(
113123
string $label = null,
@@ -120,7 +130,8 @@ public function __construct(
120130
TextEdit $textEdit = null,
121131
array $additionalTextEdits = null,
122132
Command $command = null,
123-
$data = null
133+
$data = null,
134+
int $insertTextFormat = null
124135
) {
125136
$this->label = $label;
126137
$this->kind = $kind;
@@ -133,5 +144,6 @@ public function __construct(
133144
$this->additionalTextEdits = $additionalTextEdits;
134145
$this->command = $command;
135146
$this->data = $data;
147+
$this->insertTextFormat = $insertTextFormat;
136148
}
137149
}

src/InsertTextFormat.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace LanguageServerProtocol;
4+
5+
/**
6+
* Defines whether the insert text in a completion item should be interpreted as
7+
* plain text or a snippet.
8+
*/
9+
class InsertTextFormat
10+
{
11+
/**
12+
* The primary text to be inserted is treated as a plain string.
13+
*/
14+
const PLAIN_TEXT = 1;
15+
16+
/**
17+
* The primary text to be inserted is treated as a snippet.
18+
*
19+
* A snippet can define tab stops and placeholders with `$1`, `$2`
20+
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
21+
* the end of the snippet. Placeholders with equal identifiers are linked,
22+
* that is typing in one will update others too.
23+
*/
24+
const SNIPPET = 2;
25+
}

0 commit comments

Comments
 (0)