blob: cb2c0e4dc7dc683745fe9590d0c5e6cc25b9efaf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from pygls.server import LanguageServer
from lsprotocol.types import (
TEXT_DOCUMENT_COMPLETION,
CompletionItem,
CompletionList,
CompletionParams,
)
server = LanguageServer("example-server", "v0.1")
@server.feature(TEXT_DOCUMENT_COMPLETION)
def completions(params: CompletionParams):
items = []
document = server.workspace.get_document(params.text_document.uri)
current_line = document.lines[params.position.line].strip()
if current_line.endswith("hello."):
items = [
CompletionItem(label="world"),
CompletionItem(label="friend"),
]
return CompletionList(
is_incomplete=False,
items=items,
)
server.start_io()
|